Echarts之折线图背景区域等级划分

编程入门 行业动态 更新时间:2024-10-08 22:46:18

Echarts之折线图<a href=https://www.elefans.com/category/jswz/34/1771046.html style=背景区域等级划分"/>

Echarts之折线图背景区域等级划分

需求:

鼠标移入:

实现:

<template><div class="grade"><div id="grade-echart"></div><div class="legend-list"><div class="legend-item" v-for="(item, index) in legendList" :key="index"><spanclass="item-color":style="{ background: item.legendColor }"></span><span class="item-name">{{ item.legendName }}</span></div></div></div>
</template><script>
export default {data() {return {legendList: [{legendName: "一级",legendColor: "#66FFFF",},{legendName: "二级",legendColor: "#FC5A5A",},{legendName: "三级",legendColor: "#00EA9C",},{legendName: "四级",legendColor: "#F3D74A",},{legendName: "五级",legendColor: "#4F9EFD",},],};},methods: {initChart() {let colors = ["#66FFFF","#FC5A5A","#00EA9C","#F3D74A","#4F9EFD","#FF923F","#7662D6",];let normolColor = "#A0B2D3";let option = {color: ["#FF923F"],tooltip: {trigger: "axis",},grid: {left: "3%",right: "3%",top: "8%",bottom: "2%",containLabel: true,},xAxis: {type: "category",data: ["00.00","02:00","04:00","06:00","08:00","10:00","12:00","14:00","16:00","18:00","20:00","22:00","24:00",],axisLabel: {color: normolColor,fontSize: 16,},axisTick: {show: false,},axisLine: {show: false,},// boundaryGap: false, // type: "value" 设置boundaryGap: ["20%", "20%"], //type: "category" 设置},yAxis: {type: "value",axisLabel: {color: normolColor,fontSize: 16,},axisTick: {show: false,},axisLine: {show: false,},},series: [{data: [0.2, 2, 5, 4, 6, 9, 6.5, 5, 4.2, 3.6, 2.5, 1.6, 5],type: "line",// lineStyle: {//   color: "#FF923F", //折线颜色// },markArea: {silent: true,data: [[{yAxis: 0,itemStyle: {color: colors[0],},},{yAxis: 2,},],[{yAxis: 2,itemStyle: {color: colors[1],},},{yAxis: 4,},],[{yAxis: 4,itemStyle: {color: colors[2],},},{yAxis: 6,},],[{yAxis: 6,itemStyle: {color: colors[3],},},{yAxis: 8,},],[{yAxis: 8,itemStyle: {color: colors[4],},},{yAxis: 10,},],],},},],};let myChart = this.$echarts.init(document.getElementById("grade-echart"));myChart.setOption(option);window.addEventListener("resize", function () {myChart.resize();});},},mounted() {this.initChart();},
};
</script><style lang="scss" scoped>
.grade {width: 700px;height: 380px;background: rgba(2, 15, 43, 0.7);#grade-echart {width: 700px;height: 350px;}.legend-list {width: 100%;display: flex;justify-content: center;color: #a0b2d3;.legend-item {margin: 0 15px;span {display: inline-block;}.item-color {width: 10px;height: 10px;margin-right: 5px;}}}
}
</style>

以上

更多推荐

Echarts之折线图背景区域等级划分

本文发布于:2024-03-07 21:42:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1718978.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:背景   等级   区域   折线图   Echarts

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!