123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- const app = getApp()
- import * as echarts from '../../../commpents/ec-canvas/echarts'
- Page({
- data: {
- frameStyle: { useTop: true, name: '授课情况', leftArrow: true, useBar: false },
- // xdata: []
- },
- // 返回
- back(e) {
- wx.navigateBack({ delta: 1 })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- },
- // 监听用户是否登录
- watchLogin: async function () {
- const that = this;
- wx.getStorage({
- key: 'user',
- success: async res => {
- that.setData({ ec: { onInit: that.initChart } })
- that.data.xdata = [
- { value: 2, name: '1月' },
- { value: 10, name: '2月' },
- { value: 19, name: '3月' },
- { value: 20, name: '4月' },
- { value: 70, name: '5月' },
- { value: 9, name: '6月' },
- { value: 12, name: '7月' },
- { value: 41, name: '8月' },
- { value: 31, name: '9月' },
- { value: 13, name: '10月' },
- { value: 16, name: '11月' },
- { value: 10, name: '12月' }
- ];
- },
- fail: async res => {
- wx.redirectTo({ url: '/pages/index/index' })
- }
- })
- },
- // 饼图
- initChart(canvas, width, height, dpr) {
- let that = this;
- var xdata = that.data.xdata;
- const chart = echarts.init(canvas, null, { width: width, height: height, devicePixelRatio: dpr });
- canvas.setChart(chart);
- var option = {
- tooltip: { trigger: 'item' },
- legend: {
- orient: 'vertical',
- height: 40,
- padding: 50
- },
- series: [
- {
- name: '课时',
- type: 'pie',
- radius: '50%',
- data: xdata,
- emphasis: {
- itemStyle: { shadowBlur: 10, shadowOffsetX: 0, shadowColor: 'rgba(0, 0, 0, 0.5)' }
- }
- }
- ]
- };
- chart.setOption(option, true);
- return chart;
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () { },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- const that = this;
- // 监听用户是否登录
- that.watchLogin();
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function (res) {
- },
- })
|