Vue3调用Apache Echarts

编程入门 行业动态 更新时间:2024-10-27 01:28:19

Vue3调用<a href=https://www.elefans.com/category/jswz/34/1769910.html style=Apache Echarts"/>

Vue3调用Apache Echarts

先下载

npm install echarts

那个网页用就在那引入

import * as echarts from "echarts";

写代码

在template写一个div

<div ref="main" style="background:#eee; width: 1300px; height: 500px"></div>

在script 标签要带setup属性

//声明main的ref
const main = ref();
//
onMounted(() => {init()})function init () {var myChart = echarts.init(main.value);var option = {legend: {},tooltip: {},dataset: {
//dimensions: ['product', '套装门', '亮窗门', '套装门套'],source: [{ product: '周一', 套装门: 43.3, 亮窗门: 85.8, 套装门套: 93.7 },{ product: '周二', 套装门: 83.1, 亮窗门: 73.4, 套装门套: 55.1 },{ product: '周三', 套装门: 86.4, 亮窗门: 65.2, 套装门套: 82.5 },]},xAxis: { type: 'category' },yAxis: {},series: [{ type: 'bar' }, { type: 'bar' }, { type: 'bar' }]}option && myChart.setOption(option);};

如果有更好的方法欢迎留言

更多推荐

Vue3调用Apache Echarts

本文发布于:2024-03-13 09:17:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1733648.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Apache   Echarts

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!