echarts [Feature] Dynamic label positon with dataset

b1zrtrql  于 2个月前  发布在  Echarts
关注(0)|答案(4)|浏览(27)

What problem does this feature solve?

This feature solves the need to dynamically set the label position when using the dataset data source.

Here are two examples, one using the data array and the other using dataset. When using dataset, I can't customize the position of the label based on the data.

  1. example use data array
  2. example use dataset

There was another issue that discussed a similar issue before.

What does the proposed API look like?

I can think of 3 different solutions so far

  1. add more label position enum value support for more situations
  2. add callback function support for series.label.positon
  3. add new encode dimension for get label position value from dataset.
f45qwnt8

f45qwnt81#

one solution is to add filter transformation datasets and attach separate series to them - Demo .

x33g5p2x

x33g5p2x2#

Thanks @helgasoft , this is indeed a good solution.
But for the case of dynamically generated chart options, this can create additional headaches.
For instance, in my project, I use the Web UI to dynamically configure which way to visualize the data,
the reason for using dataset is that it can provide a consistent data mapping scheme for almost any type of chart,
but transformation obviously destroys this advantage, this separated the unified data sources again.

5gfr0r5j

5gfr0r5j3#

ok, I understand, label position needs to be a data column in dataset.
Then you could pre-process the dataset and generate a data array, like in your (1.example).

w8f9ii69

w8f9ii694#

@helgasoft
Yes, this is one of the solutions I was looking forward to,
If it is possible to enhance series-xxx.encode so that other options can also get data through it, just like seriesName, tooltip, etc...

  • https://echarts.apache.org/zh/option.html#series-line.encode

Of course, it would also be great if all options could support callbacks, as mentioned in #15997 .

相关问题