前端人必看!Vue3 超神可视化大屏,用
ztj100 2025-07-23 19:27 6 浏览 0 评论
1.数据可视化组件库
在数据可视化领域有很多热门的组件库。 例如:
今天要介绍的 ECharts 是当下非常热门的可视化组件库之一。
2.Echarts 介绍
ECharts 是由百度团队开源的前端组件库。
接下来给大家讲一下如何在 Vue3 项目中安装使用 vue-echarts 。
3.ECharts 与 vue-echarts 的区别和联系
vue-echarts 组件库是在 ECharts 的基础之上进行了封装,非常适合 Vue 项目。
它和 echarts 的功能、使用方式基本一致。支持各种图表,也是通过配置 option 去调整图表样式。
它和 Echarts 的不同之处如下所示:
所以 Vue 项目中建议使用 vue-echarts 组件开发可视化大屏。
4.Vue3 项目中安装使用 vue-echarts
1.安装 vue-echarts
因为 vue-echarts 对 echarts 进行了封装,所以安装 vue-echarts 的同时要安装 echarts。
npm install echarts vue-echarts
2.main.js 中注册组件
这里建议按需引入 Echarts 的组件,因为可以大大减少项目的代码体积。
main.js
import { createApp } from 'vue'
import App from './App.vue'
import ECharts from 'vue-echarts' // vue-echarts
import { use } from 'echarts/core' // echarts 核心
import { CanvasRenderer } from 'echarts/renderers'// 渲染器
import { BarChart, LineChart, PieChart } from 'echarts/charts' // 图表
import {
GridComponent,
TooltipComponent,
LegendComponent,
TitleComponent
} from 'echarts/components' // echarts 组件
// 按需注册
use([
CanvasRenderer,
BarChart,
LineChart,
PieChart,
GridComponent,
TooltipComponent,
LegendComponent,
TitleComponent
]);
const app = createApp(App)
app.component('v-chart', ECharts)
app.mount("#app")
5.Vue 组件中使用 vue-echarts
注意:如果使用 div 或者其他布局组件 包裹 v-chart,一定要设置高度!!!!
使用案例:
<div class="chart-container">
<el-row style="height: 100%; padding: 20px">
<el-col :span="12">
基础用法
<v-chart :option="chartOption" autoresize @click="handleChartClick" />
el-col>
<el-col :span="12">
<v-chart :option="initPieOption" autoresize @click="handlePieClick" />
el-col>
el-row>
div>
</template>
相关推荐
- 10条军规:电商API从数据泄露到高可用的全链路防护
-
电商API接口避坑指南:数据安全、版本兼容与成本控制的10个教训在电商行业数字化转型中,API接口已成为连接平台、商家、用户与第三方服务的核心枢纽。然而,从数据泄露到版本冲突,从成本超支到系统崩溃,A...
- Python 文件处理在实际项目中的困难与应对策略
-
在Python项目开发,文件处理是一项基础且关键的任务。然而,在实际项目中,Python文件处理往往会面临各种各样的困难和挑战,从文件格式兼容性、编码问题,到性能瓶颈、并发访问冲突等。本文将深入...
- The Future of Manufacturing with Custom CNC Parts
-
ThefutureofmanufacturingisincreasinglybeingshapedbytheintegrationofcustomCNC(ComputerNumericalContro...
- Innovative Solutions in Custom CNC Machining
-
Inrecentyears,thelandscapeofcustomCNCmachininghasevolvedrapidly,drivenbyincreasingdemandsforprecisio...
- C#.NET serilog 详解(c# repository)
-
简介Serilog是...
- Custom CNC Machining for Small Batch Production
-
Inmodernmanufacturing,producingsmallbatchesofcustomizedpartshasbecomeanincreasinglycommondemandacros...
- Custom CNC Machining for Customized Solutions
-
Thedemandforcustomizedsolutionsinmanufacturinghasgrownsignificantly,drivenbydiverseindustryneedsandt...
- Revolutionizing Manufacturing with Custom CNC Parts
-
Understandinghowmanufacturingisevolving,especiallythroughtheuseofcustomCNCparts,canseemcomplex.Thisa...
- Breaking Boundaries with Custom CNC Parts
-
BreakingboundarieswithcustomCNCpartsinvolvesexploringhowadvancedmanufacturingtechniquesaretransformi...
- Custom CNC Parts for Aerospace Industry
-
Intherealmofaerospacemanufacturing,precisionandreliabilityareparamount.Thecomponentsthatmakeupaircra...
- Cnc machining for custom parts and components
-
UnderstandingCNCmachiningforcustompartsandcomponentsinvolvesexploringitsprocesses,advantages,andcomm...
- 洞察宇宙(十八):深入理解C语言内存管理
-
分享乐趣,传播快乐,增长见识,留下美好。亲爱的您,这里是LearingYard学苑!今天小编为大家带来“深入理解C语言内存管理”...
- The Art of Crafting Custom CNC Parts
-
UnderstandingtheprocessofcreatingcustomCNCpartscanoftenbeconfusingforbeginnersandevensomeexperienced...
- Tailored Custom CNC Solutions for Automotive
-
Intheautomotiveindustry,precisionandefficiencyarecrucialforproducinghigh-qualityvehiclecomponents.Ta...
- 关于WEB服务器(.NET)一些经验累积(一)
-
以前做过技术支持,把一些遇到的问题累积保存起来,现在发出了。1.问题:未能加载文件或程序集“System.EnterpriseServices.Wrapper.dll”或它的某一个依赖项。拒绝访问。解...
你 发表评论:
欢迎- 一周热门
- 最近发表
-
- 10条军规:电商API从数据泄露到高可用的全链路防护
- Python 文件处理在实际项目中的困难与应对策略
- The Future of Manufacturing with Custom CNC Parts
- Innovative Solutions in Custom CNC Machining
- C#.NET serilog 详解(c# repository)
- Custom CNC Machining for Small Batch Production
- Custom CNC Machining for Customized Solutions
- Revolutionizing Manufacturing with Custom CNC Parts
- Breaking Boundaries with Custom CNC Parts
- Custom CNC Parts for Aerospace Industry
- 标签列表
-
- idea eval reset (50)
- vue dispatch (70)
- update canceled (42)
- order by asc (53)
- spring gateway (67)
- 简单代码编程 贪吃蛇 (40)
- transforms.resize (33)
- redisson trylock (35)
- 卸载node (35)
- np.reshape (33)
- torch.arange (34)
- npm 源 (35)
- vue3 deep (35)
- win10 ssh (35)
- vue foreach (34)
- idea设置编码为utf8 (35)
- vue 数组添加元素 (34)
- std find (34)
- tablefield注解用途 (35)
- python str转json (34)
- java websocket客户端 (34)
- tensor.view (34)
- java jackson (34)
- vmware17pro最新密钥 (34)
- mysql单表最大数据量 (35)