WeChat applet ECHARTS chart component usage method

1: Download the item on Github

2: But after the project is downloaded, open the small program development tool, you can see the effects, adaptive Still relatively perfect. 微信小程序Echarts图表组件使用方法详解

微信小程序Echarts图表组件使用方法详解 If it is introduced into the component in the project, open the code downloaded from the github, and copy the EC-Canvas folder. Inside your project.


Ok, the component has been copied to my project, and now I want to implement a line chart, now start to carry in the component. Copy the paste code.




  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: 'Test the red area below Legend should not be cropped', 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: ['Monday', 'Tuesday', 'Wednesday', 'Thursday,' Friday ',' Sixth ',' Week Day '], // show: false}, yaxis: {x:' center ', type:' value ', splitline: {lineestyle: {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 can be used in WeChat applets!', Path: ' / PAGES / INDEX / INDEX ', SUCCESS: FUNCTION () {}, fail: functION () {}}}, data: {ec: {onInit: initchart}}, onready () {}});      JSON  

{“UsingComponents”: {“EC-Canvas”: “../../ec-canvas/ec-canvas”} :

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

This step, the code handling ends, refresh the button, but why is the interface display blank? There is no error, the code is also exactly the same. It is true that it is a matter of consuming, it is still here, it is tight to eat.

   Continue to write 
Yes, yes, blank does not display the reason for the CSS file, as long as we write some code in 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: space; justify-content: space-between; box-zing: border-box;}. ​​picker-pos {margin-top: -130 rpx; margin-left: 150 rpx; color: blueviolet;

This time
  The small program Echarts chart component is already available in the project  

The above is all the content of this article, I hope to help everyone’s learning, I hope everyone supports Tumi Cloud.

© Copyright Notice
Just support it if you like
comment Grab the couch

Please log in to comment