Commit 374b76ad by 前端
2 parents cc5fec92 55920f4b
......@@ -28,7 +28,7 @@ Component({
text: '年',
type: 3
}, ],
timePeriod: 2
timePeriod: 1
},
......@@ -50,7 +50,6 @@ Component({
this.triggerEvent('selectEvent')
},
selectTime() {
console.log(122)
this.triggerEvent('selectTime')
},
......
import * as echarts from '../../../../ec-canvas/echarts';
import * as echarts from '../../../outDetail/ec-canvas/echarts';
Component({
/**
......@@ -24,16 +24,8 @@ Component({
},
observers: {
'chartData': function (data) {
if (data.length == 0) {
this.setData({
chartShow: true,
ec: {
onInit: this.onInitChart() //这里就是在js中用到的方法名
}
})
} else {
// this.data.chart.changeData(data)
}
console.log(data, '9999999999')
this.initData(data)
},
......@@ -43,7 +35,7 @@ Component({
*/
data: {
ec: {
onInit: null
lazyLoad: true
}
},
......@@ -51,112 +43,116 @@ Component({
* 组件的方法列表
*/
methods: {
onInitChart() {
return (canvas, width, height, dpr) => {
onInitChart(xData, yData) {
this.ecComponent && this.ecComponent.init((canvas, width, height, dpr) => {
const chart = echarts.init(canvas, null, {
width: width,
height: height,
devicePixelRatio: dpr, // new
padding:[10, 20,10,20]
devicePixelRatio: dpr,
});
canvas.setChart(chart);
this.setOption(chart, xData, yData);
return chart;
})
var option = {
grid: {
left: 8,
right: 10,
top: 50,
bottom: 0,
containLabel: true
},
tooltip: {
trigger: 'axis',
triggerOn: "mousemove",
axisPointer: {
lineStyle: {
type: 'solid'
}
},
padding: [2, 10],
borderWidth: 2,
borderColor: this.data.color,
borderRadius: 10,
textStyle: {
color: this.data.color,
fontSize: 10
},
// position: function(pt) {
// console.log(pt)
// return [pt[0], pt[1]+20];
// },
formatter: function (item) {
console.log(item)
return `${item[0].value}` + '人'
},
setOption(chart, xData, yData) {
var option = {
grid: {
left: 8,
right: 10,
top: 50,
bottom: 0,
containLabel: true
},
tooltip: {
trigger: 'axis',
triggerOn: "mousemove",
axisPointer: {
lineStyle: {
type: 'solid'
}
},
xAxis: {
type: 'category',
axisLabel: {
fontSize: 11,
color: '#A6A6A6'
},
axisLine: {
show: false //坐标轴线线
},
axisTick: {
show: false //坐标轴刻度
},
data: ['Mon', 'Tue', 'Wed', 'Thu']
padding: [2, 10],
borderWidth: 2,
borderColor: this.data.color,
borderRadius: 10,
textStyle: {
color: this.data.color,
fontSize: 10
},
// position: function(pt) {
// console.log(pt)
// return [pt[0], pt[1]+20];
// },
formatter: function (item) {
console.log(item)
return `${item[0].value}` + '人'
}
},
xAxis: {
type: 'category',
axisLabel: {
fontSize: 11,
color: '#A6A6A6'
},
axisLine: {
show: false //坐标轴线线
},
axisTick: {
show: false //坐标轴刻度
},
yAxis: {
x: 'center',
type: 'value',
axisLabel: {
fontSize: 11,
color: '#A6A6A6'
},
axisLine: {
show: false //坐标轴线线
},
axisTick: {
show: false //坐标轴刻度
},
splitLine: {
lineStyle: {
type: 'dashed'
}
data: xData
},
yAxis: {
x: 'center',
type: 'value',
axisLabel: {
fontSize: 11,
color: '#A6A6A6'
},
axisLine: {
show: false //坐标轴线线
},
axisTick: {
show: false //坐标轴刻度
},
splitLine: {
lineStyle: {
type: 'dashed'
}
}
},
series: [{
data: yData,
type: 'bar',
color: this.data.color,
itemStyle: {
borderRadius: [50, 50, 0, 0],
padding: [50, 50, 0, 0]
},
series: [{
data: [820, 932, 901, 934],
type: 'bar',
color: this.data.color,
itemStyle: {
borderRadius: [50, 50, 0, 0],
padding:[50, 50, 0, 0]
},
barWidth: 24
}]
};
chart.setOption(option);
return chart;
}
barWidth: 24
}]
};
chart.setOption(option)
},
//初始化数据
initData() {
let {
chartData,
keys,
viewData
} = this
chartData.forEach(item => {
viewData.push({
name: item[keys[0]],
value: item[keys[1]]
})
initData(data) {
const xData = [],
yData = [];
const [x, y] = this.data.keys
data.forEach(item => {
xData.push(item[x])
yData.push(item[y])
})
this.setData({
xData,
yData
})
this.onInitChart(xData, yData)
},
},
ready() {
// 获取组件
this.ecComponent = this.selectComponent('#mychart-dom-bar');
}
})
\ No newline at end of file
{
"component": true,
"usingComponents": {
"ec-canvas": "../../../../ec-canvas/ec-canvas"
"ec-canvas": "../../../outDetail/ec-canvas/ec-canvas"
}
}
import * as echarts from '../../../../ec-canvas/echarts';
import * as echarts from '../../../outDetail/ec-canvas/echarts';
Component({
/**
* 组件的属性列表
......@@ -24,18 +24,6 @@ Component({
observers: {
'chartData': function (data) {
this.initData(data)
if (data.length == 0) {
this.setData({
chartShow: true,
ec: {
onInit: this.onInitChart()
}
})
} else {
// this.data.chart.changeData(data)
}
},
},
/**
......@@ -43,10 +31,8 @@ Component({
*/
data: {
ec: {
onInit: null
},
xData:[],
yData:[]
lazyLoad: true
}
},
......@@ -54,114 +40,119 @@ Component({
* 组件的方法列表
*/
methods: {
onInitChart() {
return (canvas, width, height, dpr) => {
console.log(width, height, )
onInitChart(xData,yData) {
this.ecComponent&&this.ecComponent.init((canvas, width, height, dpr) => {
const chart = echarts.init(canvas, null, {
width: width,
height: height,
devicePixelRatio: dpr // new
});
canvas.setChart(chart);
this.setOption(chart,xData,yData);
return chart;
})
},
setOption(chart,xData,yData) {
var option = {
grid: {
left: 8,
right: 30,
top: 50,
bottom: 0,
containLabel: true
},
tooltip: {
trigger: 'axis',
triggerOn: "mousemove",
axisPointer: {
lineStyle: {
type: 'solid'
}
},
padding: [2, 10],
borderWidth: 2,
borderColor: '#6ED0BE',
borderRadius: 10,
textStyle: {
color: '#6ED0BE',
fontSize: 10
},
// position: function(pt) {
// console.log(pt)
// return [pt[0], pt[1]+20];
// },
formatter: function (item) {
console.log(item)
return `${item[0].value}` + '人'
}
},
xAxis: {
type: 'category',
boundaryGap: false,
// min:1,
// max: 5,
var option = {
grid: {
left: 8,
right: 10,
top: 50,
bottom: 0,
containLabel: true
axisLabel: {
fontSize: 11,
color: '#A6A6A6'
},
tooltip: {
trigger: 'axis',
triggerOn: "mousemove",
axisPointer: {
lineStyle: {
type: 'solid'
}
},
padding: [2, 10],
borderWidth: 2,
borderColor: '#6ED0BE',
borderRadius: 10,
textStyle: {
color: '#6ED0BE',
fontSize: 10
},
// position: function(pt) {
// console.log(pt)
// return [pt[0], pt[1]+20];
// },
formatter: function (item) {
console.log(item)
return `${item[0].value}` + '人'
}
axisLine: {
show: false //坐标轴线线
},
xAxis: {
type: 'category',
boundaryGap: false,
axisLabel: {
fontSize: 11,
color: '#A6A6A6'
},
axisLine: {
show: false //坐标轴线线
},
axisTick: {
show: false //坐标轴刻度
},
data:this.data.xData
axisTick: {
show: false //坐标轴刻度
},
yAxis: {
x: 'center',
type: 'value',
axisLabel: {
fontSize: 11,
color: '#A6A6A6'
},
axisLine: {
show: false //坐标轴线线
},
axisTick: {
show: false //坐标轴刻度
},
splitLine: {
lineStyle: {
type: 'dashed'
}
}
data: xData
},
yAxis: {
x: 'center',
type: 'value',
axisLabel: {
fontSize: 11,
color: '#A6A6A6'
},
dataZoom: {
start: 10,
type: "inside"
axisLine: {
show: false //坐标轴线线
},
series: [{
data: this.data.yData,
type: 'line',
smooth: true,
color: this.data.color
}]
};
chart.setOption(option);
return chart;
axisTick: {
show: false //坐标轴刻度
},
splitLine: {
lineStyle: {
type: 'dashed'
}
}
},
dataZoom: {
type: "inside",
maxSpan: 10
},
series: [{
data: yData,
type: 'line',
smooth: true,
color: this.data.color
}]
}
chart.setOption(option)
},
//初始化数据
initData(data) {
let {
xData,
yData
} = this.data
const xData = [],
yData = [];
const [x, y] = this.data.keys
data.forEach(item => {
xData.push(item.abscissaValue)
yData.push(item.ordinateValue)
xData.push(item[x])
yData.push(item[y])
})
this.setData({
xData,
yData
})
this.onInitChart(xData, yData)
},
},
ready() {
// 获取组件
this.ecComponent = this.selectComponent('#mychart-dom-line');
}
})
\ No newline at end of file
{
"component": true,
"usingComponents": {
"ec-canvas": "../../../../ec-canvas/ec-canvas"
"ec-canvas": "../../../outDetail/ec-canvas/ec-canvas"
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!