储能智慧云小程序
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. // pages/monitorevent/index.js
  2. import * as echarts from '../../ec-canvas/echarts';
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. // 状态栏高度
  9. statusBarHeight: wx.getStorageSync('statusBarHeight'),
  10. // 导航栏高度
  11. navBarHeight: wx.getStorageSync('navBarHeight'),
  12. // 导航栏和状态栏高度
  13. navStatusBarHeight: wx.getStorageSync('navStatusBarHeight'),
  14. // 胶囊
  15. menu:wx.getStorageSync('menu'),
  16. pieleft: {
  17. onInit: initChart
  18. },
  19. pieright: {
  20. onInit: initChartright
  21. }
  22. },
  23. /**
  24. * 生命周期函数--监听页面加载
  25. */
  26. onLoad(options) {
  27. },
  28. /**
  29. * 生命周期函数--监听页面初次渲染完成
  30. */
  31. onReady() {
  32. },
  33. /**
  34. * 生命周期函数--监听页面显示
  35. */
  36. onShow() {
  37. },
  38. /**
  39. * 生命周期函数--监听页面隐藏
  40. */
  41. onHide() {
  42. },
  43. /**
  44. * 生命周期函数--监听页面卸载
  45. */
  46. onUnload() {
  47. },
  48. /**
  49. * 页面相关事件处理函数--监听用户下拉动作
  50. */
  51. onPullDownRefresh() {
  52. },
  53. /**
  54. * 页面上拉触底事件的处理函数
  55. */
  56. onReachBottom() {
  57. },
  58. /**
  59. * 用户点击右上角分享
  60. */
  61. onShareAppMessage() {
  62. }
  63. })
  64. function initChart(canvas, width, height, dpr) {
  65. const chart = echarts.init(canvas, null, {
  66. width: width,
  67. height: height,
  68. devicePixelRatio: dpr // new
  69. });
  70. canvas.setChart(chart);
  71. var option = {
  72. backgroundColor: "#ffffff",
  73. legend: {
  74. left: 'center', // 图例水平居中
  75. bottom: 0
  76. },
  77. tooltip: {
  78. trigger: 'item'
  79. },
  80. series: [{
  81. type: 'pie',
  82. radius: ['40%', '70%'],
  83. avoidLabelOverlap: false,
  84. label: {
  85. show: false,
  86. position: 'center'
  87. },
  88. emphasis: {
  89. label: {
  90. show: true,
  91. fontSize: 40,
  92. fontWeight: 'bold'
  93. }
  94. },
  95. labelLine: {
  96. show: false
  97. },
  98. data: [{
  99. value: 20,
  100. name: '已结束'
  101. }, {
  102. value: 80,
  103. name: '发生中'
  104. }
  105. ]
  106. }]
  107. };
  108. chart.setOption(option);
  109. return chart;
  110. }
  111. function initChartright(canvas, width, height, dpr) {
  112. const chart = echarts.init(canvas, null, {
  113. width: width,
  114. height: height,
  115. devicePixelRatio: dpr // new
  116. });
  117. canvas.setChart(chart);
  118. var option = {
  119. backgroundColor: "#ffffff",
  120. legend:[ {
  121. left: '40', // 图例水平居中
  122. bottom: 20,
  123. data:[
  124. {name: '未分级'},
  125. {name: '预警'}
  126. ]
  127. },{
  128. left: '40', // 图例水平居中
  129. bottom: 0,
  130. data:[
  131. {name: '告警'},
  132. {name: '故障'}
  133. ]
  134. }],
  135. tooltip: {
  136. trigger: 'item'
  137. },
  138. series: [{
  139. type: 'pie',
  140. radius: ['40%', '70%'],
  141. avoidLabelOverlap: false,
  142. label: {
  143. show: false,
  144. position: 'center'
  145. },
  146. emphasis: {
  147. label: {
  148. show: true,
  149. fontSize: 40,
  150. fontWeight: 'bold'
  151. }
  152. },
  153. labelLine: {
  154. show: false
  155. },
  156. data: [{
  157. value: 20,
  158. name: '未分级'
  159. }, {
  160. value: 80,
  161. name: '预警'
  162. }, {
  163. value: 80,
  164. name: '告警'
  165. }, {
  166. value: 80,
  167. name: '故障'
  168. }
  169. ]
  170. }]
  171. };
  172. chart.setOption(option);
  173. return chart;
  174. }