当前位置: 首页 > news >正文

【vue3/echarts】vue3中使用echarts/饼图/双轴双数据柱状图

在这里插入图片描述

在这里插入图片描述

npm下载echarts

引入使用

<script>
import Box from "@/components/box.vue";
import { onMounted } from 'vue';
import { init } from 'echarts';
export default {components: {Box: Box},setup() {onMounted(() => {// 饼图const charEle = document.getElementById('echarts1');const charEch = init(charEle);const colorList = ['#2FD7D7 ', '#83F767', '#59CB74', '#FBD444', '#7F6AAD', '#585247', '#ff0000']const option = {tooltip: {show: true,trigger: 'item',backgroundColor: 'transparent',borderColor: '#2FD7D7',textStyle: {color: '#fff'}},color: colorList,series: [{name: '',type: 'pie',radius: [65, 90],center: ['48%', '49%'],label: {show: false},labelLine: {show: false},itemStyle: {borderWidth: 13,borderColor: '#112841'},data: [{ name: '编号1 200米', value: 200 },{ name: '编号2 200米', value: 20 },],}]};charEch.setOption(option);const charEle2 = document.getElementById('echarts2');const charEch2 = init(charEle2);var xData = ['1月', '2月', '3月', '4月', '5月', '6月'];var moneyData = [118.0, 123.2, 125.6, 176.7, 115.6, 162.2];var numData = [120.1, 128.1, 120.1, 120.1, 128.1, 128.1];const option2 = {tooltip: {// show: false,trigger: 'axis',backgroundColor: '#112841',borderColor: '#2FD7D7',textStyle: {color: '#fff'},axisPointer: {type: 'cross',crossStyle: {color: '#999',},},},grid: {top: 50},legend: {data: ['数据1','数据2'],top: '20',itemWidth: 6,itemHeight: 6,textStyle: {color: '#fff'}},xAxis: [{type: 'category',data: xData,axisPointer: {type: 'shadow',},axisLabel: {formatter: '{value} ',color: '#fff'},},],yAxis: [{type: 'value',name: '',min: 0,max: 250,interval: 50,splitLine: {lineStyle: {type: "dashed",color: "#fff",opacity: 0.3}},axisLabel: {formatter: '{value} ',color: '#fff'},},// y右侧轴// {//     type: 'value',//     name: '',//     min: 0,//     max: 25,//     interval: 5,//     axisLabel: {//         formatter: '{value} ',//     },// },],series: [{name: '数据1',type: 'bar',data: moneyData,color: '#1FEBC0',tooltip: {valueFormatter: function (value) {return value + '';},},// 柱体上方显示数值label: {show: false,position: 'top',},barWidth: 10},{name: '数据2',type: 'bar',data: numData,color: '#81F466',// 柱体上方显示数值label: {show: false,position: 'top',},barWidth: 10},],};charEch2.setOption(option2);});return {}},
}
</script>
http://www.lryc.cn/news/221240.html

相关文章:

  • 【左程云算法全讲4】比较器和堆
  • 【计算机组成与设计】Chisel取指和指令译码设计
  • 「Verilog学习笔记」位拆分与运算
  • protobufjs实现protobuf序列化与反序列化
  • el-select多选以tag展示时,超过显示长度以...省略号显示,且在一行展示
  • 计算机网络第4章-通用转发和SDN
  • DDD技术方案落地实践 | 京东云技术团队
  • MySQL 案例:update set 和 and 的坑
  • VSCode remote-ssh 连接远端服务器失败
  • 通达信动量线MTM指标原理详解及MTM底背离选股公式
  • 汇编-DUP操作符
  • 2311C++抽象工厂
  • Lavarel定时任务的使用
  • Java开发者的网络安全指南(二)
  • Python基础学习016__UnitTest
  • 一物一码需求,标签制作功能轻松解决
  • 【Linux】七、基础IO
  • Elasticsearch语法之Term query不区分大小写
  • 远程管理SSH服务
  • Linux 实现原理 — NUMA 多核架构中的多线程调度开销与性能优化
  • Oracle锁处理
  • 持续集成交付CICD:安装Jenkins Slave(从节点)
  • Dart(一):Dart入门
  • [动态规划] (十一) 简单多状态 LeetCode 面试题17.16.按摩师 和 198.打家劫舍
  • 【EI会议投稿】第三届计算机、人工智能与控制工程国际学术会议 (CAICE 2024)
  • python 之 列表推导式
  • 【左程云算法全讲2】链表、栈、队列、递归、哈希表和有序表
  • SQL第三次上机作业
  • 前端事件案例补充
  • 3.8 Android eBPF HelloWorld调试(二)