微信小程序使用Echarts

效果

 下载

github上的下载地址

 

把标红的下载下来

也可以在echarts中定制  js文件 

在需要的地方引入js文件

js

// components/typeEcharts/typeEcharts.js
import * as  echarts from '../ec-canvas/echarts'
function initChart(canvas, width, height, dpr) {
  console.log(echarts)
  const chart = echarts.init(canvas, null, {
    width: width,
    height: height,
    devicePixelRatio: dpr
  });
  canvas.setChart(chart);

  var option = {
    backgroundColor: "#ffffff",
    series: [{
      label: {
        normal: {
          fontSize: 14
        }
      },
      type: 'pie',
      center: ['50%', '50%'],
      radius: ['20%', '40%'],
      data: [{
        value: 55,
        name: '北京'
      }, {
        value: 20,
        name: '武汉'
      }, {
        value: 10,
        name: '杭州'
      }, {
        value: 20,
        name: '广州'
      }, {
        value: 38,
        name: '上海'
      }]
    }]
  };
  chart.setOption(option);

  return chart;
}

Page({
  

  /**
   * 页面的初始数据
   */
  data: {
    ec: {
      onInit: initChart

  },
  },
})

在json文件中注册

wxml

  <view class="ec-container">
     <ec-canvas style="width: 500rpx;height: 300rpx;" canvas-id="echart-pie" ec="{{ec}}" ></ec-canvas>
</view>

wxss 自己写就行

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值