微信小程序 画统计图

如图:

微信小程序 画统计图_第1张图片

用canvas画图以及wxcharts.js

wxcharts.js我修改了一些东西

参考wxcharts文档修改

wxml:

js:

const Charts = require('../../dist/wxcharts.js')

Page({

 
  data: {
    
  },

  onLoad: function (options) {
    new Charts({
      canvasId: 'Statistical',
      type: 'area',
      categories: ['1月', '2月', '3月', '4月', '5月', '6月'],
      series: [{
        name: '成交量1',
        color: '#BDE1F3', // 配色,不传入则使用系统默认配色方案
        background: '#1F9CEC',
        data: [6.4, 6.5, 6.9, 6.8, 6.8, 6.7],
        format: function (val) {
          console.log('统计图', val)
          return val.toFixed(2);
        }
      }],
      yAxis: {
        min: 0, // Y轴起始值
        disableGrid: true
      },
      extra: {
        lineStyle: 'curve' // (仅对line, area图表有效) 可选值:curve曲线,straight直线 (默认)
      },
      dataPointShape: true,
      width: 320,
      height: 175
    });
  }
})

 

你可能感兴趣的:(微信小程序)