123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- import * as echarts from '../../ec-canvas/echarts';
- import {
- getToDayChartOpt
- } from './today-chart-opt.js';
- import {
- getSourceChartOpt
- } from './source-chart-opt.js';
- let toDayAata = {
- dayTime: [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24],
- visitorNum: [17, 6, 12, 7, 9, 12, 19, 8, 14, 15, 17, 8, 18],
- clickNum: [7, 19, 5, 15, 6, 11, 17, 14, 12, 16, 9, 11, 14]
- }
- Page({
- data: {
-
- toDayChartType: 'line',
-
- todayEc: {
- lazyLoad: true,
- isLoaded: false
- },
-
- sourceEc: {
- lazyLoad: true,
- isLoaded: false
- }
- },
-
- switchToDayChartType: function() {
- if (this.data.toDayChartType === 'line') {
- this.setData({
- toDayChartType: 'bar',
- })
- } else {
- this.setData({
- toDayChartType: 'line',
- })
- }
- if (this.toDayChart) {
- this.toDayChart.setOption(getToDayChartOpt(toDayAata,this.data.toDayChartType))
- }
- },
-
- initToDayChart: function() {
- this.toDayComponent.init((canvas, width, height) => {
-
-
- const chart = echarts.init(canvas, null, {
- width: width,
- height: height
- });
- chart.setOption(getToDayChartOpt(toDayAata, this.data.toDayChartType));
-
- this.toDayChart = chart;
- this.setData({
- isLoaded: true,
- isDisposed: false
- });
-
- return chart;
- });
- },
-
- initSourceChart: function () {
- this.sourceComponent.init((canvas, width, height) => {
-
-
- const chart = echarts.init(canvas, null, {
- width: width,
- height: height
- });
- chart.setOption(getSourceChartOpt([100,500,450]));
-
- this.sourceDayChart = chart;
- this.setData({
- isLoaded: true,
- isDisposed: false
- });
-
- return chart;
- });
- },
- onReady() {
- this.toDayComponent = this.selectComponent('#today-chart');
- this.sourceComponent = this.selectComponent('#source-chart');
-
-
- setTimeout(()=>{
- this.initToDayChart();
- this.initSourceChart();
- },300)
- }
- });
|