echarts icon indicating copy to clipboard operation
echarts copied to clipboard

[Feature] series-bar.markLine.label.formatter 可以返回配置项或配置项都支持函数

Open Bob2100 opened this issue 3 months ago • 1 comments

What problem does this feature solve?

markLine: {
  symbol: ['none', 'none'],
  label: {
    show: true,
    formatter(params) {
      return params.data.value
    },
    position: 'middle',
    distance: (params) => params.data.space/ 2,
  }
}

比如我期望 distance 可以是动态计算的,像上例一样:distance: (params) => params.data.space/ 2,但目前 distance 并不支持函数,要是所有配置项都支持函数,那么编程能力将大大增强。

或者formatter已经支持了函数,formatter 的返回值可以改成这样:

{
  distance: xxx,
  position: yyy,
  ...
}

distance 、position 等就是外层的配置,同样可以增强编程能力。

现在方便是方便,就是不够灵活。

What does the proposed API look like?

Bob2100 avatar Dec 02 '25 08:12 Bob2100

@Bob2100 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] series-bar.markLine.label.formatter can return a configuration item or a function that both configuration items support

BODY

What problem does this feature solve?

markLine: {
  symbol: ['none', 'none'],
  label: {
    show: true,
    formatter(params) {
      return params.data.value
    },
    position: 'middle',
    distance: (params) => params.data.space/ 2,
  }
}

For example, I expect distance to be dynamically calculated, like in the example above: 'distance: (params) => params.data.space/ 2', but currently distance does not support functions, if all configuration items support functions, then the programming ability will be greatly enhanced.

Or if 'formatter' already supports the function, the return value of 'formatter' can be changed to look like this:

{
  distance: xxx,
  position: yyy,
  ...
}

distance, position, etc. are the outer layer configurations, which can also enhance programming capabilities.

Convenience is convenience now, but it is not flexible enough.

What does the proposed API look like?

echarts-bot[bot] avatar Dec 02 '25 08:12 echarts-bot[bot]