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

echarts之折线柱状图

echarts实现折线柱状图

echarts中文官网:https://echarts.apache.org/examples/zh/index.html

效果图如下:
在这里插入图片描述
整体代码如下(注释很详细):

<template><div id="lineColumnarChart" style="width:100%;height:400px;"></div>
</template><script setup lang="ts">
import * as echarts from "echarts";
import { onMounted } from "vue";// 横坐标data数据
const xData = ["05-01","05-02","05-03","05-04","05-05","05-06","05-07","05-08","05-09","05-10","05-11","05-12","05-13","05-14","05-15","05-16","05-17","05-18","05-19","05-20",
];// 折线柱状图data数据
const lineColumnarData = [[48, 65, 24, 39, 67, 48, 65, 24, 39, 67, 48, 65, 24, 39, 67, 48, 65, 24, 39,67,],[32, 19, 72, 63, 51, 32, 19, 72, 63, 51, 32, 19, 72, 63, 51, 32, 19, 72, 63,41,],[60, 75, 32, 53, 26, 60, 75, 32, 53, 26, 60, 75, 32, 53, 26, 60, 75, 32, 53,26,],[32, 19, 72, 63, 51, 32, 19, 72, 63, 51, 32, 19, 72, 63, 51, 32, 19, 72, 63,51,],
];onMounted(() => {const myLineColumnarChart = echarts.init(document.getElementById("lineColumnarChart"));const lineColumnarOption = {tooltip: {trigger: "axis",backgroundColor: "rgba(7,18,26, 1)",borderWidth: 0,textStyle: {color: "#fff",fontSize: 14,},axisPointer: {lineStyle: {color: "rgba(69, 173, 175, 1)",},},},// 图例组件legend: {icon: "rect",show: true, // 是否显示图例orient: "horizontal", // 图例的朝向    vertical-垂直显示  horizontal-水平显示data: ["尖", "峰", "平", "谷"],itemWidth: 8,itemHeight: 8,itemGap: 15, // 间隔left: "50%", // x轴方向取值 left/center/right  具体像素值或百分比top: 24, // y轴方向取值 top/center/bottomtextStyle: {// 设置图例文字样式color: "#fff",fontSize: 12,},},// 上下左右及大小-设置图表占总面积的地方grid: {left: "4%", //左侧 y轴内容距离边框的距离(类似padding-left)top: "27%", // 与容器顶部的距离right: "1%",bottom: "12%", // 与容器底部的距离},// grid坐标系的x轴xAxis: [{type: "category",data: xData,axisPointer: {type: "shadow",},axisTick: {show: false, // 不显示坐标轴刻度线},// show: false, // 不显示坐标轴线、坐标轴刻度线和坐标轴上的文字// axisTick: {// 	show: false // 不显示坐标轴刻度线// },axisLine: {lineStyle: {color: "#415264",width: 2,type: "solid",},},axisLabel: {color: "#A6C6E1",fontSize: 12,},// splitLine: {// 	show: false // 不显示网格线// }},],// grid坐标系的y轴yAxis: [{type: "value",axisTick: {show: false,},axisLine: {lineStyle: {color: "#284556",},},splitLine: {//分割线配置show: true,lineStyle: {color: "#284556",type: "dashed",},},axisLabel: {// formatter: "{value}",color: "#9FA3A8",fontSize: 12,},},{type: "value",show: false,},],// 系列列表。每个系列通过 type 决定自己的图表类型series: [{name: "尖",type: "bar",itemStyle: {normal: {color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{//代表渐变色从正上方开始offset: 0, //offset范围是0~1,用于表示位置,0是指0%处的颜色color: "#042230",}, //柱图渐变色{offset: 1, //指100%处的颜色color: "#45B1BD",},]),barBorderRadius: [2, 2, 0, 0],},},tooltip: {valueFormatter: function (value: any) {return value;},},data: lineColumnarData[0],},{name: "峰",type: "bar",itemStyle: {normal: {color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{//代表渐变色从正上方开始offset: 0, //offset范围是0~1,用于表示位置,0是指0%处的颜色color: "#042231",}, //柱图渐变色{offset: 1, //指100%处的颜色color: "#09B1F7",},]),barBorderRadius: [2, 2, 0, 0],},},tooltip: {valueFormatter: function (value: any) {return value;},},data: lineColumnarData[1],},{name: "平",type: "line",lineStyle: {width: 1, // 设置线条宽度为5},symbol: "circle", // 设置为圆形symbolSize: 5, // 设置圆形的大小color: "#FFA668", //颜色itemStyle: {color: "#FFA668", // 设置圆形的填充颜色borderColor: "rgba(255,166,104, 0.4)", // 设置圆形的边框颜色borderWidth: 5,},tooltip: {valueFormatter: function (value: string) {return value;},},data: lineColumnarData[2],},{name: "谷",type: "bar",itemStyle: {normal: {color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{//代表渐变色从正上方开始offset: 0, //offset范围是0~1,用于表示位置,0是指0%处的颜色color: "#042231",}, //柱图渐变色{offset: 1, //指100%处的颜色color: "#3ACA73",},]),barBorderRadius: [2, 2, 0, 0],},},tooltip: {valueFormatter: function (value: any) {return value;},},data: lineColumnarData[3],},],};myLineColumnarChart.setOption(lineColumnarOption);
});
</script>

Challenges are what make life interesting and overcoming them is what makes life meaningful.‌

http://www.dtcms.com/a/209754.html

相关文章:

  • 【普及+/提高】洛谷P2613 ——【模板】有理数取余
  • bi平台是什么意思?bi平台具体有什么作用?
  • 【递归、搜索与回溯算法】专题三:穷举vs暴搜vs深搜vs回溯vs剪枝
  • 文章记单词 | 第112篇(六级)
  • 交安公路水运安全员考试的科目有哪些?
  • 从外部平台通过接口获取数据,初始全量同步 和 后续带版本管理的增量同步
  • 常见证书格式区别
  • SOC-ESP32S3部分:9-GPIO输入按键状态读取
  • 提示词工程框架——CO-STAR 框架实战
  • Unity 踩坑记录 UnityWebRequest.Delete(url) downloadHandler 空指针
  • [原理理解] 基于diffusion的超分任务时候遇到的CLIPTokenizer和CLIPTextModel
  • 通过vps命令行向dropbox上传文件
  • lua脚本实战—— Redis并发原子性陷阱
  • 文章记单词 | 第102篇(六级)
  • 深度剖析并发I/O模型select、poll、epoll与IOCP核心机制
  • ”故茗”茶文化网站
  • 【【嵌入式开发 Linux 常用命令系列 19 -- linux top 命令的交互使用介绍】
  • 谢飞机的Java面试奇遇:AIO、BIO、NIO与Netty深度解析
  • 【心海资源】【原创开发】TG,飞机,电报,协议号及直登号转API
  • RK常见系统属性设置/获取命令使用
  • 推进可解释人工智能迈向类人智能讨论总结分享
  • canal实现mysql数据同步
  • python web flask专题-Flask入门指南:从安装到核心功能详解
  • 人脸识别技术合规备案最新政策详解
  • NC IntellisysIQ QP、QPA和QPD QP3 Slave buried slave ON RS232 等通讯接口针脚定义
  • 多语种多场景的的分页详解
  • Linux下MySQL的安装与使用
  • Linux C/C++编程 —— 线程技术总结
  • NGINX如何处理静态文件?你会如何优化静态文件的传输?
  • 1538. 【中山市第十一届信息学邀请赛决赛】互质(different)