<!-- 微信小程序的echart的使用 --> <view> <ec-canvas id="mychart-dom-bar" canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas> </view>
ec-canvas { width: 100%; height: 100%; } .container { position: absolute; top: 0; bottom: 0; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; justify-content: space-between; box-sizing: border-box; }
import * as echarts from "../../base-ui/ec-canvas/echarts"; let chart = null; function initChart(canvas, width, height, dpr) { chart = echarts.init(canvas, null, { width: width, height: height, devicePixelRatio: dpr // new }); canvas.setChart(chart); var option = { tooltip: { trigger: "axis", axisPointer: { type: "shadow" } }, xAxis: { type: "category", data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], axisLabel:{ fontSize:10 }, }, yAxis: { type: "value", }, series: [ { data: [-120, 200, 150, 80, -70, 110, 130], type: "bar" } ] }; chart.setOption(option); return chart; } Page({ onShareAppMessage: function (res) { return { title: "ECharts 可以在微信小程序中使用啦!", path: "/pages/index/index", success: function () { }, fail: function () { } } }, data: { ec: { onInit: initChart } }, onReady() { setTimeout(function () { // 获取 chart 实例的方式 // console.log(chart) }, 2000); } });
到此这篇关于echart在微信小程序的使用的文章就介绍到这了,更多相关echart在微信小程序的使用内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!