当前位置: 首页 > news >正文

微信小程序 echarts 画多个横向柱状图

然后是json 

{"usingComponents": {"ec-canvas": "../../common/ec-canvas/ec-canvas"},"navigationBarTitleText": "主题活动"
}

ec-canvas获取方式 在链接里下载代码 然后copy ec-canvas文件夹到自己的项目

https://gitcode.net/mirrors/ecomfe/echarts-for-weixin?utm_source=csdn_github_accelerator&from_codechina=yeshttps://gitcode.net/mirrors/ecomfe/echarts-for-weixin?utm_source=csdn_github_accelerator&from_codechina=yes

//js里引入echarts 在page上面
import * as echarts from '../../common/ec-canvas/echarts'
Page({...})getStatisticThemeActivitiesTrend(){const that = thislet oUserInfo = this.data.userInfoutil.request(api.statisticThemeActivitiesTrend + oUserInfo.userId + '&startDate=' + that.data.startDate + '&endDate=' + that.data.endDate, '', 'get').then(res => {if (res.code == 200) {let odata = res.datathis.setData({info: odata})if(!odata.themeList || odata.themeList.length == 0){util.alert("暂无数据")return}//主要代码odata.themeList.forEach(function (item, index) {        let echartsComponnet = that.selectComponent('#area-dom-'+index);echartsComponnet.init((canvas, width, height, dpr) => {// 初始化图表const Chart = echarts.init(canvas, null, {width: width,height: height,devicePixelRatio: dpr});Chart.setOption(that.getAreaPie(item));// 注意这里一定要返回 chart 实例,否则会影响事件处理等return Chart;});          })} else {wx.showModal({title: res.msg,icon: 'error',showCancel: false,duration: 3000});}});},getAreaPie(odata) {    let option = {grid: { //图表距边框的距离top: 0,right: 30,        bottom: 0,left: 0,containLabel: false,},xAxis: {type: 'value',"splitLine": {     //网格线"show": false}},yAxis: {show : false,type: 'category',data: ['','','','']},series: [{data: [odata.countActivityNumber, odata.countPhysicalRecordNumber, odata.countDetailNumber, odata.countObservationNumber],type: 'bar',itemStyle: {   //通常情况下:normal:{  label : {show: true,position: 'right',},//每个柱子的颜色即为colorList数组里的每一项,如果柱子数目多于colorList的长度,则柱子颜色循环使用该数组color: function (params){var colorList = ['#70b603', '#00bfbf', '#027db4', '#6300bf']return colorList[params.dataIndex];}},//鼠标悬停时:emphasis: {shadowBlur: 10,shadowOffsetX: 0,shadowColor: 'rgba(0, 0, 0, 0.5)'},},}]};return option},

http://www.lryc.cn/news/135176.html

相关文章:

  • 【二叉树】572. 另一棵树的子树
  • 220V转5V芯片三脚芯片-AH8652
  • windows系统丢失mfc120u.dll的解决方法
  • css 实现电梯导航
  • 【Spring Boot】Spring Retry减少1000 行代码讲解
  • 【数据结构OJ题】相交链表
  • 【华为OD机试】最小传输时延I【2023 B卷|200分】
  • Android13 网络 Adb 默认开启
  • Git分享-规范/建议/技巧
  • vue3文件下载功能
  • Python调用文心一言的API
  • 【计算机网络八股】计算机网络(一)
  • 记录一次arcgis engine开发版本引入问题
  • 2023年Java毕业设计怎样选题,有哪些注意事项,300道Java毕业设计题目
  • 算法-滑动窗口-串联所有单词的子串
  • 2023年7月京东美妆护肤品小样行业数据分析(京东数据挖掘)
  • 记录Taro巨坑,找不到sass类型定义文件
  • CS1988|C#无法在异步方法中使用ref,in,out类型的参数的问题
  • ubuntu开机失败——ACPI Error
  • 搭建开发环境-操作系统篇(一键搭建开发环境)
  • 人工智能AI绘画接入使用文档
  • 如何使用PyQt进行文件操作
  • 阿里云CDN加速器基本概念与购买开通
  • 2023河南萌新联赛第(六)场:河南理工大学-F 爱睡大觉的小C
  • [C++ 网络协议编程] 域名及网络地址
  • Java【HTTP】什么是 Cookie 和 Session? 如何理解这两种机制的区别和作用?
  • 使用U盘重装Windows10系统详细步骤及配图【官方纯净版】
  • 数据结构之——(手撕)顺序表
  • 冠达管理:非银金融是什么?
  • go 结构体