位置: IT常识 - 正文

在vue中使用echarts(vue中用echarts)

编辑:rootadmin
在vue中使用echarts

推荐整理分享在vue中使用echarts(vue中用echarts),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:vue中echarts怎么用,在Vue中使用Axios的步骤是什么?,在vue中引入echarts,vue用echarts,vue+echarts,vue+echarts,在Vue中使用______属性可以指定组件的名称,vue+echarts,内容如对您有帮助,希望把文章链接给更多的朋友!

欢迎大家加入我的社区:http://t.csdn.cn/Q52km 社区中不定时发红包

文章目录1、安装2、在vue中引入(全局引入)3、在vue中的使用4、模板代码放在哪个位置5、完整的一个vue页面实例:6、实现效果7、可能遇到的问题,下载不成功。使用8、11:25-32 "export 'default' (imported as 'echarts') was not found in 'echarts1、安装npm install echarts --save2、在vue中引入(全局引入)// 引入echartsimport echarts from 'echarts'Vue.prototype.$echarts = echarts3、在vue中的使用

需要用到echart的地方先设置一个div的id、宽高

在vue中使用echarts(vue中用echarts)

提示: 可以在一个页面中引入多个数据报表模板 使用div进行位置的排版放置

4、模板代码放在哪个位置

重点注意:其中const option = { }就是我们需要引进echart图表的代码

<template> <div> <div ref="chart" style="width:50%;height:376px"></div> </div></template>

要在mounted生命周期函数中实例化echarts对象。确保dom元素已经挂载到页面中。

mounted(){ this.getEchartData() }, methods: { getEchartData() { const chart = this.$refs.chart if (chart) { const myChart = this.$echarts.init(chart) const option = {...} myChart.setOption(option) window.addEventListener("resize", function() { myChart.resize() }) } this.$on('hook:destroyed',()=>{ window.removeEventListener("resize", function() { myChart.resize(); }); }) } }5、完整的一个vue页面实例:<template> <div> <div ref="chart" style="width:50%;height:376px"></div> <div ref="chart1" style="width:50%;height:376px"></div> </div></template><script> export default { data() { }, mounted() { this.getEchartData() this.getEchartData1() }, methods: { getEchartData() { const chart = this.$refs.chart if (chart) { const myChart = this.$echarts.init(chart) const option = { legend: {}, tooltip: {}, dataset: { source: [ ['订单', 43.3, 85.8], ['订单1', 83.1, 73.4], ['订单2', 86.4, 65.2], ['订单3', 72.4, 53.9], ['订单4', 82.4, 53.9], ['订单5', 42.4, 53.9], ['订单6', 72.4, 53.9], ['订单7', 72.4, 53.9] ] }, xAxis: { type: 'category' }, yAxis: {}, series: [ { type: 'bar' }, { type: 'bar' }]} myChart.setOption(option) window.addEventListener("resize", function() { myChart.resize() }) } this.$on('hook:destroyed',()=>{ window.removeEventListener("resize", function() { myChart.resize(); }); }) }, getEchartData1() { const chart1 = this.$refs.chart1 if (chart1) { const myChart = this.$echarts.init(chart1) const option = { title: { text: 'Stacked Line' }, tooltip: { trigger: 'axis' }, legend: { data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine'] }, grid: { left: '3%', right: '4%', bottom: '3%', containLabel: true }, toolbox: { feature: { saveAsImage: {} } }, xAxis: { type: 'category', boundaryGap: false, data: ['一月', '二月', '三月', '四月', '五月', '六月', '七月','八月','九月','十月','十一月','十二月'] }, yAxis: { type: 'value' }, series: [ { name: 'Email', type: 'line', stack: 'Total', data: [120, 132, 101, 134, 90, 230, 210,120, 132, 101, 134, 90, 230] }, { name: 'Union Ads', type: 'line', stack: 'Total', data: [220, 182, 191, 234, 290, 330, 310,220, 182, 191, 234, 290, 330] }, { name: 'Video Ads', type: 'line', stack: 'Total', data: [150, 232, 201, 154, 190, 330, 410,150, 232, 201, 154, 190, 330] }, { name: 'Direct', type: 'line', stack: 'Total', data: [320, 332, 301, 334, 390, 330, 320,320, 332, 301, 334, 390, 330] }, { name: 'Search Engine', type: 'line', stack: 'Total', data: [820, 932, 901, 934, 1290, 1330, 1320,820, 932, 901, 934, 1290, 1330] } ] } myChart.setOption(option) window.addEventListener("resize", function() { myChart.resize() }) } this.$on('hook:destroyed',()=>{ window.removeEventListener("resize", function() { myChart.resize(); }); }) }, }, watch: {}, created() { } }</script>6、实现效果

7、可能遇到的问题,下载不成功。使用cnpm install echarts --save

8、11:25-32 "export ‘default’ (imported as ‘echarts’) was not found in 'echarts

修改引入的方式

// 引入echartsimport *as echarts from 'echarts'Vue.prototype.$echarts = echarts
本文链接地址:https://www.jiuchutong.com/zhishi/298674.html 转载请保留说明!

上一篇:保姆级教程:Ant Design Vue中 a-table 嵌套子表格(保姆级教程什么意思)

下一篇:GPT-4重磅发布,它究竟厉害在哪?(gpt40)

  • 城建税和教育费附加需要计提吗
  • 工资个人所得税怎么算
  • 房地产企业怎么认定
  • 开票系统技术维护费怎么抵扣
  • 会计账本需要装订的有哪些
  • 工程保险谁负责
  • 帮别人开票收税点怎么做账
  • 编制竣工结算的具体增减内容有哪几个方面?
  • 利税总额计算公式表
  • 淘宝开企业店铺需要什么资料
  • 新领的发票怎么读入开票系统
  • 营改增金融业税收政策
  • 企业所得税是当期收入吗
  • 参展补助
  • 预付账款怎么做账
  • 食堂伙食费账务处理
  • 民间非营利组织会计制度最新版
  • 结转成本是否要等货物卖出后
  • intelin
  • 出口退税的会计分录实例
  • 转包工程款怎么结算
  • 企业废业实收资产怎么算
  • 苹果15手机价格和图片颜色
  • 索尼体积最小的微单
  • 员工离职的类型
  • 资产证券化会计信息披露规范
  • 会计中的计算公式
  • 实收资本的会计编码
  • thinkphp设置伪静态
  • 总分机构 分总机构
  • 没有发票怎么做研发费用
  • 国税代开普票能作废吗
  • php常用数组函数有哪些
  • 稚晖君的学历
  • vue route 参数
  • idea 创建maven项目读取pom报错
  • 电商后台管理系统简介
  • list删除某个元素 python
  • 营改增一般纳税人简易征收的范围
  • 利润表期初余额怎么填
  • 红字发票可以跨越开吗
  • 资本公积根据什么填列
  • 浏览器测试网页
  • python 邮件服务
  • 纳税人的交际应酬消费可以抵扣进项税额
  • 金蝶可以自动结转增值税吗
  • 不单独计价的包装物押金计入什么科目
  • 企业内部交易如何操作
  • 差旅费津贴怎么报税
  • 主营业务成本包括哪些
  • 企业支付宝扣费
  • 现汇账户和现钞账户
  • ubuntu中怎么卸载软件
  • windows命令提示符命令大全
  • Ubuntu开启热点
  • 电脑window8系统怎么样
  • win10更新后电脑黑屏
  • win7禁用开机启动服务
  • 关闭windows输入法
  • win10插上耳机后电脑还是外放如何解决
  • win7无法识别usb设备怎么办 五大方法来解决
  • win8搜索框怎么打开
  • WIN10远程桌面连接一直在配置远程会话
  • cocos 2d x
  • unity3d技术介绍
  • javascript实现2048游戏示例
  • re engine引擎
  • qq聊天背景闪烁
  • shell脚本中获取参数
  • import和export区别
  • nodejs发送图片给前端
  • unity游戏换皮教程
  • android datagridview
  • jquery课程内容总结
  • 江苏省发票真伪查询网站
  • 填了专项附加扣除但没有进行综合年度汇算
  • 国家税务局河北省税务局
  • 河南省焦煤集团董事长
  • 扬州退契税政策
  • 众筹在中国的发展潜力
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设