shebeidetail.js 3.0 KB
// pages/shebei/shebeidetail/shebeidetail.js
import * as echarts from '../../../ec-canvas/echarts';
const app=getApp();

function initChart1(canvas, width, height) {
  const chart = echarts.init(canvas, null, {
    width: width,
    height: height
  });
  canvas.setChart(chart);

  var option = {
    title: {
      text: '半年度开工曲线',
      left: 'center'
    },


    toolbox: {

    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      data: ['2018-11', '2018-12', '2019-01', '2019-02', '2019-03', '2019-04'],
      axisLabel: {
        interval: 0,
      },
      name: '日期'


    },
    yAxis: {
      type: 'value',
      axisLabel: {
        formatter: '{value}'
      },
      min: 100,
      max: 500,
      splitNumber: 5,
      name: '小时(h)'

    },
    series: [
      {
        name: '',
        type: 'line',
        smooth: true,
        color: '#FCB237',
        data: [112, 115, 454, 135, 125, 135, 170],
        markPoint: {
          data: [
            { type: 'max', name: '最大值' },
            { type: 'min', name: '最小值' }
          ]
        },
        markLine: {
          data: [
            { type: 'average', name: '平均值' }
          ]
        },
        // areaStyle: {
        //   // normal: {
        //   //   color: '#F8E9DD' //改变区域颜色
        //   // }
        // },
      },

    ]
  };

  chart.setOption(option);
  return chart;
}
Page({

  onShareAppMessage: function (res) {
    return {
      title: 'ECharts 可以在微信小程序中使用啦!',
      path: '',
      success: function () { },
      fail: function () { }
    }
  },

  /**
   * 页面的初始数据
   */
  data: {
    state:1,
    statedate: "",
    date: '',
    
    ec: {
      onInit: initChart1,

      // onInit: initChart1

    },
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      statedate: app.monthnowDate(),
      date: app.monthnowDate()
    })
  },
  selectshebei(e){
    this.setData({
      state:e.currentTarget.dataset.id
    })
  },

  bindstateDateChange(e){
    console.log('picker发送选择改变,携带值为', e.detail.value)
    this.setData({
      statedate: e.detail.value
    })
  },
  bindDateChange: function (e) {
    console.log('picker发送选择改变,携带值为', e.detail.value)
    this.setData({
      date: e.detail.value
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})