| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- // pages/monitorevent/index.js
- import * as echarts from '../../ec-canvas/echarts';
-
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- // 状态栏高度
- statusBarHeight: wx.getStorageSync('statusBarHeight'),
- // 导航栏高度
- navBarHeight: wx.getStorageSync('navBarHeight'),
-
- // 导航栏和状态栏高度
- navStatusBarHeight: wx.getStorageSync('navStatusBarHeight'),
-
- // 胶囊
- menu:wx.getStorageSync('menu'),
- pieleft: {
- onInit: initChart
- },
- pieright: {
- onInit: initChartright
- }
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
-
- },
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
-
- }
- })
-
- 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",
- legend: {
- left: 'center', // 图例水平居中
- bottom: 0
- },
- tooltip: {
- trigger: 'item'
- },
- series: [{
- type: 'pie',
- radius: ['40%', '70%'],
- avoidLabelOverlap: false,
- label: {
- show: false,
- position: 'center'
- },
- emphasis: {
- label: {
- show: true,
- fontSize: 40,
- fontWeight: 'bold'
- }
- },
- labelLine: {
- show: false
- },
- data: [{
- value: 20,
- name: '已结束'
- }, {
- value: 80,
- name: '发生中'
- }
- ]
- }]
- };
-
- chart.setOption(option);
- return chart;
- }
-
- function initChartright(canvas, width, height, dpr) {
- const chart = echarts.init(canvas, null, {
- width: width,
- height: height,
- devicePixelRatio: dpr // new
- });
- canvas.setChart(chart);
-
- var option = {
- backgroundColor: "#ffffff",
- legend:[ {
- left: '40', // 图例水平居中
- bottom: 20,
- data:[
- {name: '未分级'},
- {name: '预警'}
- ]
- },{
- left: '40', // 图例水平居中
- bottom: 0,
- data:[
- {name: '告警'},
- {name: '故障'}
- ]
- }],
- tooltip: {
- trigger: 'item'
- },
- series: [{
- type: 'pie',
- radius: ['40%', '70%'],
- avoidLabelOverlap: false,
- label: {
- show: false,
- position: 'center'
- },
- emphasis: {
- label: {
- show: true,
- fontSize: 40,
- fontWeight: 'bold'
- }
- },
- labelLine: {
- show: false
- },
- data: [{
- value: 20,
- name: '未分级'
- }, {
- value: 80,
- name: '预警'
- }, {
- value: 80,
- name: '告警'
- }, {
- value: 80,
- name: '故障'
- }
- ]
- }]
- };
-
- chart.setOption(option);
- return chart;
- }
|