vue echarts折线图 折线堆积图和折线面积图

2024-04-27 09:52

本文主要是介绍vue echarts折线图 折线堆积图和折线面积图,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

vue echarts折线图 折线堆积图和折线面积图

1、折线堆积图和折线面积图的结合;

上代码

<template><section><divid="performaceLineChart"ref="performaceLineChartRef"style="width: 100%; height: 500px"></div></section>
</template><script>
import * as echarts from "echarts";
export default {name: "", components: {},props: {
},data() {return {chart: null,_thisForChart: null,_thisForWindow: null,};},watch: {},mounted() {this.$nextTick(() => {this.initLineChart();this.addEventListenerToSidebarContainer(this)this.addEventListenerToWindowResize(this)});},beforeDestroy() {if (!this.chart) {return;}this.removeEventListenerToSidebarContainer()this.removeEventListenerToWindowResize()this.chart.dispose();this.chart = null;},methods: {initLineChart() {var chartDom = document.getElementById("performaceLineChart");this.chart = echarts.init(chartDom);this.setOptions();},setOptions(option) {this.chart.setOption({color: ["#ee6666", "#5470c6", "#aeaeae", "#f9c858",],toolbox: {top: "0",right: "10",itemSize: 18,iconStyle: {borderColor: "#aeaeae",borderWidth: 2,},feature: {saveAsImage: {title: "导出图片",name: '导出图片名称'},},},tooltip: {trigger: "axis",backgroundColor: 'rgba( 0, 0, 0,0.7)',borderColor: 'rgba( 0, 0, 0,0.7)',formatter: function (params) {var str = params[0].name + "</br>";for (let item of params) {str =`<span style='color: #fff;'>${str}</span><div style='display:flex;align-items:center;justify-content:space-between;'><span>${item.marker}<span style='color: #fff;'>${item.seriesName}</span></span>&nbsp;&nbsp;&nbsp;&nbsp;<span style='color: #fff;'>${item.value}%</span></div>`;}return str;},},legend: {x: "center",y: "bottom",icon: "circle",textStyle: {},data: ['上海','广州','北京']},grid: {left: "0.5%",right: "1%",bottom: "15%",containLabel: true,},xAxis: {type: "category",boundaryGap: false,axisLabel: {},axisLine: {show: true,lineStyle: {},onZero: false, // X轴线始终位于底部},splitLine: {show: false,},data: ['2024-01-01','2024-01-02','2024-01-03','2024-01-04','2024-01-05','2024-01-06']},yAxis:[{type: "value",scale: true,// interval:  5,splitNumber: 5,// min: 'dataMin',// max: 'dataMax',// min: function(value) {//   return value.min// },// max: function(value) {//   return value.max// },alignTicks: true,// max: function (val) {//   if (Math.abs(val.max)>Math.abs(val.min)) {//     return (Math.abs(val.max)*1.2).toFixed(0);} //   else {//     return (Math.abs(val.min)*1.2).toFixed(1);}},// min: function (val) {//   if(Math.abs(val.max)>Math.abs(val.min)){//     return-(Math.abs(val.max)*1.2).toFixed(0);} //   else {//     return -(Math.abs(val.min)*1.2).toFixed(1);}},axisLabel: {show: true,formatter: (value) => {return `${value.toFixed(1)}%`}},axisLine: {show: false,},splitLine: {show: true,lineStyle: {type: "dotted",},},},{type: "value",// interval:  5,splitNumber: 5,// min: 'dataMin',// max: 'dataMax',// min: function(value) {//   return value.min// },// max: function(value) {//   return value.max// },// alignTicks: true,// max: function (val) {//   if (Math.abs(val.max)>Math.abs(val.min)) {//     return (Math.abs(val.max)*1.2).toFixed(0);} //   else {//     return (Math.abs(val.min)*1.2).toFixed(1);}},// min: function (val) {//   if(Math.abs(val.max)>Math.abs(val.min)){//     return-(Math.abs(val.max)*1.2).toFixed(0);} //   else {//     return -(Math.abs(val.min)*1.2).toFixed(1);}},axisLabel: {show: true,formatter: (value) => {return `${value}%`}},axisLine: {show: false,},splitLine: {show: true,lineStyle: {type: "dotted",},},},{type: "value",// interval:  5,splitNumber: 5,// min: 'dataMin',// max: 'dataMax',// min: function(value) {//   return value.min// },// max: function(value) {//   return value.max// },alignTicks: true,// max: function (val) {//   if (Math.abs(val.max)>Math.abs(val.min)) {//     return (Math.abs(val.max)*1.2).toFixed(0);} //   else {//     return (Math.abs(val.min)*1.2).toFixed(1);}},// min: function (val) {//   if(Math.abs(val.max)>Math.abs(val.min)){//     return-(Math.abs(val.max)*1.2).toFixed(0);} //   else {//     return -(Math.abs(val.min)*1.2).toFixed(1);}},axisLabel: {show: true,formatter: (value) => {return `${value.toFixed(1)}%`}},axisLine: {show: false,},splitLine: {show: true,lineStyle: {type: "dotted",},},},{type: "value",// interval:  5,splitNumber: 5,// min: 'dataMin',// max: 'dataMax',// min: function(value) {//   return value.min// },// max: function(value) {//   return value.max// },// alignTicks: true,// max: function (val) {//   if (Math.abs(val.max)>Math.abs(val.min)) {//     return (Math.abs(val.max)*1.2).toFixed(0);} //   else {//     return (Math.abs(val.min)*1.2).toFixed(1);}},// min: function (val) {//   if(Math.abs(val.max)>Math.abs(val.min)){//     return-(Math.abs(val.max)*1.2).toFixed(0);} //   else {//     return -(Math.abs(val.min)*1.2).toFixed(1);}},axisLabel: {show: true,formatter: (value) => {return `${value}%`}},axisLine: {show: false,},splitLine: {show: true,lineStyle: {type: "dotted",},},},],series: [{name: '上海',type: "line",// stack: "total",yAxisIndex: null,// smooth: true,showSymbol: false,lineStyle: { width: 2 },itemStyle: {normal: {label: {show: false,},},},       areaStyle: null,data: ["-4.11", "11.12", "-5.13", "17.13", "2.13", "-19.13",],},{name: '广州',type: "line",// stack: "total",yAxisIndex: null,// smooth: true,showSymbol: false,lineStyle: { width: 2 },itemStyle: {normal: {label: {show: false,},},},       areaStyle: null,data: ["13.51", "-6.12", "10.13", "4.13", "-10.13", "10.99",],},{name: '北京',type: "line",// stack: "total",yAxisIndex: 2,// smooth: true,showSymbol: false,lineStyle: { width: 0 },itemStyle: {normal: {label: {show: false,},},},       areaStyle: {color: new echarts.graphic.LinearGradient(0,0,0,1,[{offset: 0,color: "rgb(174,174,174)",},{offset: 1,color: "rgb(174,174,174)",},],),},data: ["4.11", "1.12", "-5.13", "-7.13", "-5.93", "-6.13",],}]});},// 监听侧边栏导航的宽度发生变化addEventListenerToSidebarContainer(_this) {let sidebarContainer = document.getElementsByClassName("sidebar-container")[0];this._thisForChart = _this;sidebarContainer &&sidebarContainer.addEventListener("transitionend", this.sidebarResizeHandler);},removeEventListenerToSidebarContainer() {let sidebarContainer = document.getElementsByClassName("sidebar-container")[0];this._thisForChart = nullsidebarContainer &&sidebarContainer.removeEventListener("transitionend", this.sidebarResizeHandler);},sidebarResizeHandler(e) {if (e.propertyName === "width") {this._thisForChart.chart.resize();}},// window 的尺寸发生变化的时候 会执行图表的resizeaddEventListenerToWindowResize(_this) {this._thisForWindow = _this;window.addEventListener("resize", this.windowResizeHandler);},removeEventListenerToWindowResize(_this) {this. _thisForWindow = nullwindow.removeEventListener("resize", this.windowResizeHandler);},windowResizeHandler(e) {this._thisForWindow.chart.resize();},},
};
</script><style lang="scss" scoped></style>

展示效果图
在这里插入图片描述

这篇关于vue echarts折线图 折线堆积图和折线面积图的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/940185

相关文章

Vue中组件之间传值的六种方式(完整版)

《Vue中组件之间传值的六种方式(完整版)》组件是vue.js最强大的功能之一,而组件实例的作用域是相互独立的,这就意味着不同组件之间的数据无法相互引用,针对不同的使用场景,如何选择行之有效的通信方式... 目录前言方法一、props/$emit1.父组件向子组件传值2.子组件向父组件传值(通过事件形式)方

css中的 vertical-align与line-height作用详解

《css中的vertical-align与line-height作用详解》:本文主要介绍了CSS中的`vertical-align`和`line-height`属性,包括它们的作用、适用元素、属性值、常见使用场景、常见问题及解决方案,详细内容请阅读本文,希望能对你有所帮助... 目录vertical-ali

浅析CSS 中z - index属性的作用及在什么情况下会失效

《浅析CSS中z-index属性的作用及在什么情况下会失效》z-index属性用于控制元素的堆叠顺序,值越大,元素越显示在上层,它需要元素具有定位属性(如relative、absolute、fi... 目录1. z-index 属性的作用2. z-index 失效的情况2.1 元素没有定位属性2.2 元素处

Python实现html转png的完美方案介绍

《Python实现html转png的完美方案介绍》这篇文章主要为大家详细介绍了如何使用Python实现html转png功能,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 1.增强稳定性与错误处理建议使用三层异常捕获结构:try: with sync_playwright(

Vue 调用摄像头扫描条码功能实现代码

《Vue调用摄像头扫描条码功能实现代码》本文介绍了如何使用Vue.js和jsQR库来实现调用摄像头并扫描条码的功能,通过安装依赖、获取摄像头视频流、解析条码等步骤,实现了从开始扫描到停止扫描的完整流... 目录实现步骤:代码实现1. 安装依赖2. vue 页面代码功能说明注意事项以下是一个基于 Vue.js

CSS @media print 使用详解

《CSS@mediaprint使用详解》:本文主要介绍了CSS中的打印媒体查询@mediaprint包括基本语法、常见使用场景和代码示例,如隐藏非必要元素、调整字体和颜色、处理链接的URL显示、分页控制、调整边距和背景等,还提供了测试方法和关键注意事项,并分享了进阶技巧,详细内容请阅读本文,希望能对你有所帮助...

Nginx实现前端灰度发布

《Nginx实现前端灰度发布》灰度发布是一种重要的策略,它允许我们在不影响所有用户的情况下,逐步推出新功能或更新,通过灰度发布,我们可以测试新版本的稳定性和性能,下面就来介绍一下前端灰度发布的使用,感... 目录前言一、基于权重的流量分配二、基于 Cookie 的分流三、基于请求头的分流四、基于请求参数的分

基于Canvas的Html5多时区动态时钟实战代码

《基于Canvas的Html5多时区动态时钟实战代码》:本文主要介绍了如何使用Canvas在HTML5上实现一个多时区动态时钟的web展示,通过Canvas的API,可以绘制出6个不同城市的时钟,并且这些时钟可以动态转动,每个时钟上都会标注出对应的24小时制时间,详细内容请阅读本文,希望能对你有所帮助...

HTML5 data-*自定义数据属性的示例代码

《HTML5data-*自定义数据属性的示例代码》HTML5的自定义数据属性(data-*)提供了一种标准化的方法在HTML元素上存储额外信息,可以通过JavaScript访问、修改和在CSS中使用... 目录引言基本概念使用自定义数据属性1. 在 html 中定义2. 通过 JavaScript 访问3.

CSS模拟 html 的 title 属性(鼠标悬浮显示提示文字效果)

《CSS模拟html的title属性(鼠标悬浮显示提示文字效果)》:本文主要介绍了如何使用CSS模拟HTML的title属性,通过鼠标悬浮显示提示文字效果,通过设置`.tipBox`和`.tipBox.tipContent`的样式,实现了提示内容的隐藏和显示,详细内容请阅读本文,希望能对你有所帮助... 效