2024-06-21 如何在React/Vue中使用ECharts
要安装两个插件echarts和echarts-for-react,前者是一个js图标库,后者是对前者封装的react组件库,该库可以帮助我们节省大量的dom操作事件,省却许多麻烦。
yarn add echarts echarts-for-react
例子:
import React, { Component } from "react"; import ReactECharts from "echarts-for-react"; class Workbench extends Component { constructor() { super(); this.state = { options: { title: { text: "在React引入ECharts", }, tooltip: {}, xAxis: { data: [ "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日", ], }, yAxis: {}, series: [ { name: "使用量", type: "bar", data: [5, 20, 36, 10, 10, 20, 10], }, ], }, }; } componentWillMount() {} componentWillUnmount() {} render() { return ( <> <ReactECharts option={this.state.options} /> </> ); } } export default Workbench;
效果图:
ps:vue直接装echarts就行,然后照着echarts官网给的文档直接复用即可。
echarts官网:https://echarts.apache.org/zh/index.html
示例文档:https://echarts.apache.org/examples/zh/index.html
分类:
EChart.js
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
· SQL Server 2025 AI相关能力初探
· 为什么 退出登录 或 修改密码 无法使 token 失效
2023-06-21 2023-06-21 vue 变量赋值失败
2022-06-21 2022-06-21 react-native 添加多个style
2022-06-21 2022-06-21 iview select 清除默认值