首页 前端知识 echarts图表标线-markLine(阈值线、警戒线) 箭头

echarts图表标线-markLine(阈值线、警戒线) 箭头

2024-01-27 01:01:54 前端知识 前端哥 709 698 我要收藏

series里面添加markLine

    const echart = () =>{
     var xData=["xxx","xxx","xxx","xxx","xxx","xxx","xxx","xxx,"xxx","xxx","xxx"],
          serieData=[10, 30, 20, 30, 80, 20, 10,30,30,20,30,20],
          marks=[20];
      let myEcharts = echarts.init(document.getElementById("hdechart7"))
      myEcharts.setOption({
        grid: {
          top:"15%",
          left: '3%',
          right: '8%',
          bottom: '3%',
          containLabel: true
        },
        xAxis : [
          {
            type : 'category',
            data :xData,
            axisTick: {
              show:false,
              alignWithLabel: true
            },
            axisLabel: {
              textStyle: {
                color: '#fff',
                fontWeight: 'normal',
                fontSize: '12',
              },
              interval: 0,
            },
            axisLine: {
              show: true,
              lineStyle: {
                color: '#456980 ',
              }
            },

          }
        ],
        yAxis: {
          name: "xxx",
          nameTextStyle: {
            color: "#fff",
            fontSize:".12rem"
          },
          type: 'value',
          axisTick: {
            alignWithLabel: true,
          },
          axisLine: {
            show: true,
            lineStyle: {
              color: '#456980',
            }
          },
          splitLine: {
            show: true,
            lineStyle: {
              color: '#456980',
            }
          },
          axisLabel: {
            textStyle: {
              color: '#fff',
              fontWeight: 'normal',
              fontSize: '12',
            },
          }
        },
        series : [
          {
            name:'',
            type:'bar',
            barWidth: '18',
            data:serieData,
            label: {
              normal: {
                show: true,
                position: 'top',
                formatter: '{c}',
                textStyle: {
                  color: '#fff',
                  fontWeight: 'normal',
                  fontSize: '12',
                },
              }
            },
            itemStyle: {
              normal: {
                show: true,
                color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                  offset: 0,
                  color: 'rgba(49, 200,190, 0.8)'
                }, {
                  offset: 1,
                  color: 'rgba(16, 127,159, 0.8)'
                }]),
                shadowColor: 'rgba(0, 0, 0, 0.1)',
                shadowBlur: 10
              }
            },
            //标记的线1
            markLine: {
              symbol:['circle', 'arrow'], //箭头
              silent: true,
              lineStyle: {
                type: 'dashed'
              },
              data: [
                {
                  yAxis:marks,
                  lineStyle: {
                    width: 1.656,
                    color: '#00ff00'
                  },
                  label: {
                    show: true,
                    color: '#00ff00',
                    fontSize: '14',
                  }
                }

              ]
            },
          },

        ],

      });
      window.addEventListener("resize", function () {
        myEcharts.resize();
      });
    }

在这里插入图片描述

转载请注明出处或者链接地址:https://www.qianduange.cn//article/570.html
标签
echarts
评论
发布的文章
大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!