Skip to content

How can I sort the tooltip and legend by values for line series chart? #2660

Open
@baurine

Description

@baurine

hi, I want to know, how can I sort the tooltip and legend by their values for line series chart.

example code: https://bolt.new/~/sb1-cgcnmq

case 1:
when hover to the line, I want to make the tooltip sorted by their values from high to low.
for example, the following chart, the expected result should be "Month2 104" -> "Month1 76" -> "Month3 71"
Image

case 2:
for legend, I want to show the legend sorted by their values from high to low ( or from low to high if possible).

Image

The example in grafana, you can control rank from high to low, or from low to high:

Image


another example from elastic chart story book:

Image

https://elastic.github.io/elastic-charts/storybook/?path=/story/line-chart--multiple-with-axis-and-legend&globals=toggles.showHeader:true;toggles.showChartTitle:false;toggles.showChartDescription:false;toggles.showChartBoundary:false;theme:light&knob-default%20sort=true&knob-enable%20legend%20size=true&knob-legend%20size=200&knob-position=right&knob-reverse=true


The only doc about sort legend is here: https://elastic.github.io/elastic-charts/storybook/?path=/story/legend--sort-items&globals=toggles.showHeader:true;toggles.showChartTitle:false;toggles.showChartDescription:false;toggles.showChartBoundary:false;theme:light&knob-default%20sort=true&knob-enable%20legend%20size=true&knob-legend%20size=200&knob-position=right&knob-reverse=true

But I don't know how to make it work for line series chart. I tried some ways but it totally doesn't work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions