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

uniapp使用echarts

uniapp使用echarts

  • 1.下载资源包
    • 2.引入资源包
    • 3.代码示例
    • 注意事项

1.下载资源包

https://echarts.apache.org/zh/download.html

2.引入资源包

将资源包放入项目内
在这里插入图片描述

3.代码示例

<template><div style="width:100%;height:500rpx" id="line" ref="line"></div>
</template><script>import * as echarts from '@/config/echarts.min.js';export default {data() {return {chartDom: "",myChart: "",option: "",};},// onLoad() {// 	this.$nextTick(() => {// 		this.chartDom = document.getElementById("main");// 		this.myChart = echarts.init(this.chartDom);// 		this.initChart();// 	});// },mounted() {this.$nextTick(() => {this.initChart();});},methods: {initChart() {this.chartDom = document.getElementById("line");this.myChart = echarts.init(this.chartDom);// return;// this.chart = echarts.init(this.$el, "macarons");this.option = {tooltip: {trigger: 'axis',axisPointer: {type: 'shadow'}},legend: {},grid: {left: '3%',right: '4%',bottom: '3%',containLabel: true},xAxis: [{type: 'category',data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']}],yAxis: [{type: 'value'}],series: [{name: 'Direct',type: 'bar',emphasis: {focus: 'series'},data: [320, 332, 301, 334, 390, 330, 320]},{name: 'Email',type: 'bar',stack: 'Ad',emphasis: {focus: 'series'},data: [120, 132, 101, 134, 90, 230, 210]},{name: 'Union Ads',type: 'bar',stack: 'Ad',emphasis: {focus: 'series'},data: [220, 182, 191, 234, 290, 330, 310]},{name: 'Video Ads',type: 'bar',stack: 'Ad',emphasis: {focus: 'series'},data: [150, 232, 201, 154, 190, 330, 410]},{name: 'Search Engine',type: 'bar',data: [862, 1018, 964, 1026, 1679, 1600, 1570],emphasis: {focus: 'series'},markLine: {lineStyle: {type: 'dashed'},data: [[{type: 'min'}, {type: 'max'}]]}},{name: 'Baidu',type: 'bar',barWidth: 5,stack: 'Search Engine',emphasis: {focus: 'series'},data: [620, 732, 701, 734, 1090, 1130, 1120]},// {// 	name: 'Google',// 	type: 'bar',// 	stack: 'Search Engine',// 	emphasis: {// 		focus: 'series'// 	},// 	data: [120, 132, 101, 134, 290, 230, 220]// },// {// 	name: 'Bing',// 	type: 'bar',// 	stack: 'Search Engine',// 	emphasis: {// 		focus: 'series'// 	},// 	data: [60, 72, 71, 74, 190, 130, 110]// },// {// 	name: 'Others',// 	type: 'bar',// 	stack: 'Search Engine',// 	emphasis: {// 		focus: 'series'// 	},// 	data: [62, 82, 91, 84, 109, 110, 120]// }]};this.option && this.myChart.setOption(this.option);},},}
</script><style>
</style>

注意事项

div中的id 需要对应document中的id,且最好是唯一的,不重复的

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

相关文章:

  • Python命令模式介绍、使用
  • #typescript 使用file-saver模块#
  • 移动端适配布局rem和vw
  • 【Java基础教程】(四十八)集合体系篇 · 上:全面解析 Collection、List、Set常用子接口及集合元素迭代遍历方式~【文末送书】
  • 什么是 DNS ANAME 解析?
  • Neo4j 集群和负载均衡
  • go web框架 gin-gonic源码解读01————Engine
  • windows版docker部署springcloud项目
  • 探索工程机械远程控制新纪元:Intewell-Hyper II震撼发布!
  • DM8 DSC集群实时主备搭建
  • 配置IPv4 over IPv6隧道示例
  • 在中国区部署日志通2.0
  • centos下安装jdk
  • 【HDFS】LocatedBlocks、LocatedBlock、LocatedStripedBlock、ExtendedBlock类分析
  • Oracle 19c 报ORA-704 ORA-01555故障处理---惜分飞
  • D356周赛复盘:滑动窗口+三元问题思路
  • ETHERNET/IP 转ETHERCAT连接倍福和欧姆龙PLC的配置方法
  • Git分布式版本控制工具和GitHub(一)--简介
  • 【Terraform学习】Terraform-AWS部署快速入门(快速入门)
  • 力扣75——深度优先搜索
  • 【C++初阶】C++基础(上)——C++关键字、命名空间、C++输入输出、缺省参数、函数重载
  • 代码随想录训练营Day55动态规划part15|392.判断子序列|115.不同的子序列
  • Linux下安装RabbitMQ教程
  • 如何加强Mysql安全,请给出可行的具体措施
  • 创造自己的宠物医院预约服务小程序,步骤详解
  • MACOM EDI 需求分析
  • 使用Spring Boot AOP实现日志记录
  • 图像中不规则物体的长轴与短轴:OpenCV实现指南
  • C/C++开发,opencv与qt结合播放视频
  • 磁共振图像处理中 fft1c 和 ifft1c 函数的 Python 实现