smartmeter-app/echarts-for-weixin-master/pages/gauge/index.js
2023-12-05 16:45:28 +08:00

55 lines
930 B
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 option = {
backgroundColor: "#ffffff",
series: [{
name: '业务指标',
type: 'gauge',
detail: {
formatter: '{value}%'
},
axisLine: {
show: true
},
data: [{
value: 40,
name: '完成率',
}]
}]
};
chart.setOption(option, true);
return chart;
}
Page({
onShareAppMessage: function (res) {
return {
title: 'ECharts 可以在微信小程序中使用啦!',
path: '/pages/index/index',
success: function () { },
fail: function () { }
}
},
data: {
ec: {
onInit: initChart
}
},
onReady() {
}
});