欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

使用 vue-charts 切换主题

最编程 2024-04-10 21:33:41
...

首先安装echarts、vue-echarts不一一赘述

一、定制下载主题
echarts官网下载:https://echarts.apache.org/zh/theme-builder.html
下载json文件到项目中,颜色参数也可直接在json中修改

二、页面上图表上加上主题
// template
<chart theme="dark" :options="optionOne" autoresize ref="chartOne" />

// script
import ECharts from '@/components/ECharts'
import themeDark from '@/assets/echarts-theme/dark.json'
import themeLight from '@/assets/echarts-theme/light.json'
ECharts.registerTheme('dark', themeDark)
ECharts.registerTheme('light', themeLight)

三、可动态切换主题(比如light和dark切换)

推荐阅读