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

echarts之双折线渐变图

vue3+echarts实现双折线渐变图

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

效果图展示:在这里插入图片描述
整体代码如下:

<template><div id="lineChart" 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 lineData = [[782, 859, 578, 564, 615, 787, 623, 606, 750, 610, 703, 501, 675, 598, 721,550, 767, 600, 692, 987,],[780, 589, 703, 510, 714, 503, 474, 621, 692, 512, 700, 876, 686, 780, 614,781, 489, 700, 621, 600,],
];onMounted(() => {const myLineChart = echarts.init(document.getElementById("lineChart"));const lineOption = {tooltip: {trigger: "axis",type: "line",axisPointer: {lineStyle: {color: "rgba(69, 173, 175, 1)",},},backgroundColor: "rgba(7,18,26, 1)",borderWidth: 0,textStyle: {color: "#fff",fontSize: 14,},},// 图例legend: {icon: "rect", // circle圆形;rect方形;roundRect圆角方形;triangle三角形;diamond菱形;pin定位点;arrow导航三角指针data: ["实际用量", "计划用量"],itemWidth: 8,itemHeight: 8,itemGap: 15, // 间隔right: "50%",top: "8%",textStyle: {fontSize: 12,color: "#fff",},},// 图表位置grid: {left: "1%",right: "2%",top: "27%",bottom: "3%",containLabel: true, // 是否包含坐标刻度},xAxis: [{type: "category",boundaryGap: false, // 散点图的留白策略axisLine: {lineStyle: {color: "#415264",width: 2,type: "solid",},},axisLabel: {color: "#A6C6E1",fontSize: 12,},axisTick: {show: false,},data: xData,},],yAxis: [{type: "value",axisTick: {show: false,},axisLine: {lineStyle: {color: "#284556",},},axisLabel: {//  改变y轴字体颜色和大小// formatter: '{value}间 ', //  给y轴添加单位color: "#9FA3A8",fontSize: 12,},splitLine: {lineStyle: {color: "#284556",type: "dashed",},},},],series: [{name: "实际用量",type: "line",smooth: true, // 是否为平滑曲线lineStyle: {width: 2,},symbol: "circle",symbolSize: 5,showSymbol: false, // 是否显示数据点areaStyle: {// 设置渐变色color: new echarts.graphic.LinearGradient(0,0,0,1,[{offset: 0,color: "rgba(18,166,254,0.6)",},{offset: 0.8,color: "rgba(7,18,26,0.1)",},],false),},itemStyle: {color: "#12A6FE",borderWidth: 1,},data: lineData[0],},{name: "计划用量",type: "line",smooth: true,symbol: "circle",symbolSize: 5,showSymbol: false,lineStyle: {width: 2,},areaStyle: {color: new echarts.graphic.LinearGradient(0,0,0,1,[{offset: 0,color: "rgba(51,181,107,0.6)",},{offset: 0.8,color: "rgba(7,18,26,0.5)",},],false),},itemStyle: {color: "#33B56B",borderWidth: 1,},data: lineData[1],},],};myLineChart.setOption(lineOption);
});
</script>

Genuine effort turns challenges into stepping stones for real growth.‌

http://www.xdnf.cn/news/610669.html

相关文章:

  • 独木桥 Java
  • 基于SpringBoot+Vue的社区医院信息平台设计与实现
  • 软考中级软件设计师——计算机系统篇
  • STM32+腾讯物联网平台OTA升级详细教程
  • 华为OD机试_2025 B卷_爱吃蟠桃的孙悟空(Python,100分)(附详细解题思路)
  • 从逆流监测到智慧用电:ADL200N-CT系列单相导轨表赋能家庭绿色能源
  • ubuntu设置开机不输密码笔记
  • 解决Vue项目依赖错误:使用electron-vite重建
  • 提升开发运维效率:原力棱镜游戏公司的 Amazon Q Developer CLI 实践
  • 使用clickhouse的ReplacingMergeTree引擎表做活跃玩家信息表
  • Unity 打包程序全屏置顶无边框
  • 宽松相等(==) 的转换规则(仅考虑基本数据类型)
  • 怎么判断一个Android APP使用了Ionic这个跨端框架
  • 智能交通红绿灯系统(Python)
  • TCP 三次握手,第二次握手报文丢失会发生什么?
  • IP隧道技术中数据包头部的变化分析:必然增加的封装机制
  • (15)关于窗体的右键菜单的学习与使用,这关系到了信号与事件 event
  • 特殊的完全平方数
  • 【MySQL】 数据库基础数据类型
  • 【c++】: c++11线程库
  • 【Hexo】3.主题
  • Kafka 集群中,Broker和Controller的关系
  • TPDS-2014《Efficient $k$-means++ Approximation with MapReduce》
  • Python匿名函数(lambda)全面详解
  • 黑马k8s(十三)
  • 【机械视觉】Halcon—【二、Halcon算子全面介绍(超详细版)】
  • 免费AI工具整理
  • HarmonyOS NEXT 使用 relationalStore 实现数据库操作
  • 文章记单词 | 第113篇(六级)
  • 数据挖掘算法大汇总