111 lines
1.8 KiB
JavaScript
111 lines
1.8 KiB
JavaScript
import * as echarts from '../../ec-canvas/echarts';
|
|
|
|
const app = getApp();
|
|
|
|
function initChart(canvas, width, height, dpr) {
|
|
const chart = echarts.init(canvas, null, {
|
|
width: width,
|
|
height: height,
|
|
devicePixelRatio: dpr // new
|
|
});
|
|
canvas.setChart(chart);
|
|
|
|
var data = [];
|
|
var data2 = [];
|
|
|
|
for (var i = 0; i < 10; i++) {
|
|
data.push(
|
|
[
|
|
Math.round(Math.random() * 100),
|
|
Math.round(Math.random() * 100),
|
|
Math.round(Math.random() * 40)
|
|
]
|
|
);
|
|
data2.push(
|
|
[
|
|
Math.round(Math.random() * 100),
|
|
Math.round(Math.random() * 100),
|
|
Math.round(Math.random() * 100)
|
|
]
|
|
);
|
|
}
|
|
|
|
var axisCommon = {
|
|
axisLabel: {
|
|
textStyle: {
|
|
color: '#C8C8C8'
|
|
}
|
|
},
|
|
axisTick: {
|
|
lineStyle: {
|
|
color: '#fff'
|
|
}
|
|
},
|
|
axisLine: {
|
|
lineStyle: {
|
|
color: '#C8C8C8'
|
|
}
|
|
},
|
|
splitLine: {
|
|
lineStyle: {
|
|
color: '#C8C8C8',
|
|
type: 'solid'
|
|
}
|
|
}
|
|
};
|
|
|
|
var option = {
|
|
backgroundColor: '#eee',
|
|
xAxis: axisCommon,
|
|
yAxis: axisCommon,
|
|
legend: {
|
|
data: ['aaaa', 'bbbb']
|
|
},
|
|
visualMap: {
|
|
show: false,
|
|
max: 100,
|
|
inRange: {
|
|
symbolSize: [20, 70]
|
|
}
|
|
},
|
|
series: [{
|
|
type: 'scatter',
|
|
name: 'aaaa',
|
|
data: data
|
|
},
|
|
{
|
|
name: 'bbbb',
|
|
type: 'scatter',
|
|
data: data2
|
|
}
|
|
],
|
|
animationDelay: function (idx) {
|
|
return idx * 50;
|
|
},
|
|
animationEasing: 'elasticOut'
|
|
};
|
|
|
|
|
|
chart.setOption(option);
|
|
return chart;
|
|
}
|
|
|
|
Page({
|
|
onShareAppMessage: function (res) {
|
|
return {
|
|
title: 'ECharts 可以在微信小程序中使用啦!',
|
|
path: '/pages/index/index',
|
|
success: function () { },
|
|
fail: function () { }
|
|
}
|
|
},
|
|
data: {
|
|
ec: {
|
|
onInit: initChart
|
|
}
|
|
},
|
|
|
|
onReady() {
|
|
}
|
|
});
|