echarts添加辅助线markLine

      var chartDom = document.getElementById("columnBar");
      var myChart = echarts.init(chartDom);
      var option;
      option = {
        color: "#288ce1",
        xAxis: {
          type: "category",
          data: [
            "机构1",
            "机构2",
            "机构3",
            "机构4",
            "机构5",
            "机构6",
            "机构7",
            "机构8",
            "机构9",
            "机构10",
            "机构11",
          ],
          axisLabel: {
            interval: 0,
            formatter: function (value) {
              //x轴的文字改为竖版显示
              var str = value.split("");
              return str.join("\n");
            },
            textStyle: {
              color: "#b7b7b7",
            },
          },
        },
        yAxis: {
          type: "value",
          show: false,
          axisLabel: {
            textStyle: {
              color: "#b7b7b7",
            },
          },
        },
        series: [
          {
            data: [
              120,
              200,
              150,
              80,
              70,
              110,
              130,
              120,
              200,
              150,
              80,
              70,
              110,
              130,
            ],
            type: "bar",
            showBackground: false, // 不显示图形背景
            backgroundStyle: {
              color: "rgba(180, 180, 180, 0.2)",
            },
            // 辅助线相关配置markLine
            markLine: {
              silent: true, //基线显示 隐藏
               symbol:'none',// 不显示箭头和圆点
              lineStyle: {
                normal: {
                  color: "red", // 这儿设置安全基线颜色
                },
              },

              data: [
                {
                  name: "标线1起点",
                  yAxis: 150, // 安全基线 1
                  label: {
                    formatter: "BBB",
                  },
                },
                {
                  name: "标线1终点",
                  yAxis: 100, // 安全基线 2
                  label: {
                    formatter: "AAA",
                  },
                },
              ],
            },
            label: {
              show: true, // 开启显示
              rotate: 0, // 旋转角度度
              position: "insideTop", // 在上方显示
              distance: 15, // 距离图形元素的距离。当 position 为字符描述值(如 'top'、'insideRight')时候有效。
              verticalAlign: "middle",
              textStyle: {
                // 数值样式
                color: "#fff",
                fontSize: 12,
              },
            },
          },
        ],
      };
 option && myChart.setOption(option);

在这里插入图片描述

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值