小工具知识网

当前位置: 首页 > 行业知识 > 小程序图形:echarts-weixin 入门使用

行业知识

小程序图形:echarts-weixin 入门使用

2026-10-31 14:47:57 来源:互联网转载

去官���下载整个项目:

https://github.com/ecomfe/echarts-for-weixin

 

拷贝ec-canvs文件夹到小程序里面

index.js里面的写法

import * as echarts from "../../components/ec-canvas/echarts"const app = getApp();function initChart(canvas, width, height, dpr) {  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}  }})

index.json里面的写法

{  "usingComponents": {    "ec-canvas":"../../components/ec-canvas/ec-canvas"  }}

页面的写法

      

上一篇:揭秘真相,如何判断一个人是否失去灵魂?涉政深度探究

下一篇:云服务器怎么打开ssl?