echarts custom 系列画直线 如何设置直线格式为虚线

clipboard.png

需要用echarts的自定义方法绘制图形, 有一个需求是需要画虚线, 考虑应该是通过调用api.style()方法设置样式,但是并没有看到这个参数.
所以是用其他方法设置, 还是根本就不能画虚线呢.

阅读 6.7k
2 个回答
style: {
            fill: "transparent",
            stroke: "black",
            lineDash:[5,5],
          },

用线性渐变,

style: api.style({
          stroke: new echarts.graphic.LinearGradient(
            0,
            0,
            0,
            1,
            [
              {
                offset: 0,
                color: 'red', 
              },
              {
                offset: 0.2,
                color: 'red', 
              },
              {
                offset: 0.2,
                color: 'transparent', 
              },
              {
                offset: 0.4,
                color: 'transparent', 
              },
              {
                offset: 0.4,
                color: 'red',
              },
              {
                offset: 0.6,
                color: 'red', 
              },
              {
                offset: 0.6,
                color: 'transparent',
              },
              {
                offset: 0.8,
                color: 'transparent', 
              },
              {
                offset: 0.8,
                color: 'red', 
              },
              {
                offset: 1,
                color: 'red', 
              },
            ],
            false
          ),
          lineWidth: 4,
        }),
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题