[Feature] echarts多个柱状图如何只显示单个markLine

wwwo4jvm  于 4个月前  发布在  Echarts
关注(0)|答案(4)|浏览(119)

What problem does this feature solve?

line线图,业务需求上需要配置最大值和最小值,然后再echarts上绘制,通过官方文档最合适的是line的markLine配置,现在遇到如下问题:

  1. 因为是多个线图,如果markLine只设置在series第一项中,因为存在legend,这时关闭掉了第一个line,则不显示markLine
  2. 如果series每项都绘制,则会出现性能上浪费,并且会重叠markLine

当然我知道此设计是合理的,但是我认为这个业务需求也是合理的,echarts方面可有此处的替代方案呢?

What does the proposed API look like?

希望一个全局生效的markLine,可以像title,tooltip那样的配置

kwvwclae

kwvwclae1#

@qqfei1858 It seems you are not using English, I've helped translate the content automatically. To make your issue understood by more people and get helped, we'd like to suggest using English next time. 🤗
TRANSLATED

TITLE

[Feature] echarts how multiple bar charts show only a single markLine

BODY

What problem does this feature solve?

line diagram, business needs to configure the maximum and minimum values, and then draw on echarts, through the official document the most suitable is the markLine configuration of line, now encounter the following problems:

  1. Because it is a multi-line chart, if the markLine is only set in the first item of the series, and the first line is turned off because there is a legend, the markLine will not be displayed
  2. If each item of the series is drawn, there will be a performance waste and the markLine will be overlapped

Of course I know this design is reasonable, but I think this business need is also reasonable, is there an alternative here for echarts?

What does the proposed API look like?

I want a global markLine to be able to be configured like title and tooltip

yv5phkfx

yv5phkfx2#

suggestion: 1) precalculate min and max for all series, 2) add a line with no name and no data 3) add min/max marklines to this extra line

0wi1tuuw

0wi1tuuw3#

建议:1)预先计算所有系列的最小值和最大值,2)添加一条没有名称和数据的行 3)为这个额外的行添加最小值/最大标记线

@helgasoft I know you can do this, but you need to set up the stack, which feels weird, so I mentioned feature issues

7ivaypg9

7ivaypg94#

@helgasoft I did this the other way around, with stack there was a bar misalignment, I used line, which always felt weird

series: [
  {
    type: 'bar',
    data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  },
  {
    type: 'bar',
    data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  },
  {
    type: 'bar',
    data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  },
  {
    type: 'line',
    markLine: {
      silent: true,
      data: [
        {
          name: 'Max',
          yAxis: 9
        },
        {
          name: 'Min',
          yAxis: 2
        }
      ]
    }
  }
];

相关问题