小程序echarts

小程序echarts,第1张

一、引入ec-canvas文件

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

“ec-canvas”

二、配置json

{

"usingComponents":{

"誉竖伍ec-canvas":"../../ec-canvas/ec-canvas"

}

}

三、书写结构

<view class="container log-list">

<ec-canvas id="mychart-dom-line" canvas-id="mychart-line" ec="{{ec}}"></ec-canvas>

</view>

四、js文件

//logs.js

const util = require('../../utils/util.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 = {

color:["#37A2DA","#67E0E3","#9FE6B8"],

legend:{

data:["A","B","C"],

top:20,

left:"center",

z:100

},

grid:{

left:"3%",

right:"4%",

bottom:"3%",

containLabel:true

},

xAxis:{

type:"category",

boundaryGap:false,

data:["周一","周二","周三","周四","周五","周纤帆六","周日"]

}

chart.setOption(option)

return chart

}

Page({

onShareAppMessage:function(res){

return{

title:"Echarts",

path:"/pages/index/index",

success:function(){},

fail:function(){}

}

},

data: {

ec:{

onInit:initChart

},

logs: []

},

onReady(){},

onLoad: function () {

this.setData({

logs: (wx.getStorageSync('庆或logs') || []).map(log =>{

return util.formatTime(new Date(log))

})

})

}

})

uniapp编译钉钉小程序后echrts失效 :

1. 尝试重新编译;2. 查看配置文件中是否引入echarts,如果敏桐衫未引入,则在配置文件中引入echarts;3. 检查echarts版本是否与uni-app兼容,如果不兼容,则需要更新echarts版本;4. 检查钉钉小轮腔程序是否支持echarts,如果不支持,则桥腔需要更换其他图表库。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12220186.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-21
下一篇 2023-05-21

发表评论

登录后才能评论

评论列表(0条)

保存