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

echart在微信小程序的使用

echart在微信小程序的使用

echarts不显示在微信小程序

<!-- 微信小程序的echart的使用 -->
<view class="container"><ec-canvas id="mychart-dom-bar" canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas>
</view>

css样式

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;} 

echarts的grid属性详解

grid配置项:图标离容器的距离
show:是否显示直角坐标系网格-----------值:true?false
left:图表离容器左侧的距离-----------------值:number?百分比
top:图表离容器顶部的距离-----------------值:number?百分比
right:图表离容器右侧的距离---------------值:number?百分比
bottom:图表离容器底部的距离------------值:number?百分比
backgroundColor:网格背景色-------------值:rgba或#000000
borderColor:网格的边框颜色--------------值:rgba或#000000
borderWidth:网格的边框线宽-------------值:number
备注:背景色-边框-线宽生效前提:设置了show:true,边距不受show影响

js

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);}
});

在这里插入图片描述

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

相关文章:

  • 51单片机最强模块化封装(5)
  • 链表学习之判断链表是否回文
  • 【Linux06-基础IO】4.5万字的基础IO讲解
  • c++协程库理解—ucontext组件实践
  • 英语基础-状语
  • 目标检测笔记(八):自适应缩放技术Letterbox完整代码和结果展示
  • 2023年全国最新高校辅导员精选真题及答案1
  • 【Python】Python读写Excel表格
  • Python每日一练(20230218)
  • 基于SSM框架的狼途汽车门店管理系统的设计与实现
  • 视频监控流程图3
  • Linux ARM平台开发系列讲解(CAN) 2.14.3 CANFD协议介绍
  • 参考 | 给C盘 “搬家“
  • 剑指 Offer 53 - II. 0~n-1中缺失的数字
  • 分布式id
  • 创意编程py模拟题
  • uniapp中条件编译
  • 封装 YoloV5 detect.py 成 Python 库以供 python 程序使用
  • PostgreSQL , PostGIS , 球坐标 , 平面坐标 , 球面距离 , 平面距离
  • K3S 系列文章-5G IoT 网关设备 POD 访问报错 DNS ‘i/o timeout‘分析与解决
  • 社会工程学介绍
  • 干货 | 有哪些安慰剂按钮的设计?
  • LeetCode 每日一题 2023/2/13-2023/2/19
  • SAP 关于多种语言配置
  • 万字长文讲述由ChatGPT反思大语言模型的技术精要
  • SpringBoot静态资源访问
  • 【物联网】智慧农业病虫害精准辨识竞赛思路及代码分享
  • Properties类读取配置文件
  • 知其然更要知其所以然,聊聊SQLite软件架构
  • 微服务架构的演变