国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 課堂 > 小程序 > 正文

微信小程序Echarts圖表組件使用方法詳解

2020-03-21 15:53:22
字體:
供稿:網(wǎng)友

1:下載 GitHub 上的 項目

微信小程序,Echarts,圖表組件

2:但項目下載之后,打開小程序開發(fā)工具,可以看到效果如下,適配性還是比較完美的。

微信小程序,Echarts,圖表組件

微信小程序,Echarts,圖表組件

如果是在項目里面引入組件的話,打開從github上面下載的代碼,將ec-canvas文件夾復制黏貼到你的項目里面。

微信小程序,Echarts,圖表組件

微信小程序,Echarts,圖表組件

好的,組件已經(jīng)復制到了我的項目里面,現(xiàn)在我想實現(xiàn)一個折線圖,現(xiàn)在開始去組件里面搬運復制黏貼代碼了。

wxml

<!--index.wxml--><view class="container"><ec-canvas id="mychart-dom-line" canvas-id="mychart-line" ec="{{ ec }}"></ec-canvas></view>

js

import * as echarts from '../../ec-canvas/echarts';const app = getApp();function initChart(canvas, width, height) {const chart = echarts.init(canvas, null, {width: width,height: height});canvas.setChart(chart);var option = {title: {text: '測試下面legend的紅色區(qū)域不應被裁剪',left: 'center'},color: ["#37A2DA", "#67E0E3", "#9FE6B8"],legend: {data: ['A', 'B', 'C'],top: 50,left: 'center',backgroundColor: 'red',z: 100},grid: {containLabel: true},tooltip: {show: true,trigger: 'axis'},xAxis: {type: 'category',boundaryGap: false,data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],// show: false},yAxis: {x: 'center',type: 'value',splitLine: {lineStyle: {type: 'dashed'}}// show: false},series: [{name: 'A',type: 'line',smooth: true,data: [18, 36, 65, 30, 78, 40, 33]}, {name: 'B',type: 'line',smooth: true,data: [12, 50, 51, 35, 70, 30, 20]}, {name: 'C',type: 'line',smooth: true,data: [10, 30, 31, 50, 40, 20, 10]}]};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() {}});

json

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

css

/**index.wxss**/ec-canvas {width: 100%;height: 100%;}

這一步為止,代碼搬運結(jié)束,刷新按鈕,但是,為什么界面顯示空白?沒有報錯,代碼也一模一樣,真實讓人費解,算了,還是先放在這里吧,吃飯要緊。

.......

.......

繼續(xù)寫

對,沒錯,空白不顯示的原因出在了css文件上面,只要我們在css里面再寫上一些代碼之后。

/**index.wxss**/ec-canvas {width: 100%;height: 100%;}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;}.picker-pos {margin-top: -130rpx;margin-left: 150rpx;color: blueviolet;}

這個時候

小程序Echarts圖表組件算是已經(jīng)可以運用在項目里面啦

微信小程序,Echarts,圖表組件

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持VEVB武林網(wǎng)。


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 来凤县| 威海市| 抚远县| 汉源县| 鄂伦春自治旗| 南平市| 二手房| 洪江市| 南木林县| 隆尧县| 虎林市| 恭城| 卢龙县| 瓦房店市| 汉寿县| 安义县| 西华县| 吉林市| 田东县| 吉安市| 呈贡县| 铜山县| 米易县| 南宫市| 金湖县| 柘荣县| 郓城县| 盈江县| 开平市| 长岛县| 绥棱县| 扶风县| 汉寿县| 霍邱县| 任丘市| 三明市| 阿勒泰市| 武义县| 海宁市| 富锦市| 英超|