Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort DataSeries #795

Closed
markov00 opened this issue Aug 26, 2020 · 6 comments
Closed

Sort DataSeries #795

markov00 opened this issue Aug 26, 2020 · 6 comments
Labels
:data Data/series/scales related issue enhancement New feature or request

Comments

@markov00
Copy link
Member

markov00 commented Aug 26, 2020

Is your feature request related to a problem? Please describe.
We should add the ability to sort every DataSeries created due to a splitAccessor or due to multiple specs ids.
Different sorting order can be applied to rendering, tooltip, legend.

Describe the solution you'd like
A first-class component should be built to handle such sorting. Its id can be used inside other specific props to reuse the same sorting in multiple places.

// sort the tooltip values by specId alphabetically ascenting
<Sort
  id="tooltipOrder"
  by={(spec: Spec, splitAccessorValues: string|number[], datum: Datum ) => {
    return [spec.id];
  }}
  order={['alphaAsc']}
/>
<Tooltip
order="tooltipOrder"
/>

// sort legend items: by specId alphabetically ascending, then by split accessor value numerically descending
<Sort
  id="legendOrder"
  by={(spec: Spec, splitAccessorValues: string|number[], datum: Datum ) => {
    return [spec.id, ...splitAccessorValues];
  }}
  order={['alphaAsc', 'numDesc']}
/>
<Legend
...
order="legendOrder"
/>

// sorting rendering of bars: first stacked series then non stacked series by split accessors values
<Sort
  id="renderingOrder"
  by={(spec: Spec, splitAccessorValues: string|number[], datum: Datum ) => {
    const stackKey = spec.isStacked ? 'A' : 'B';
    const stackKey = spec.isStacked ? 'A' : 'B';
    return [[stackKey, ...splitAccessorValues].join('-')];
  }}
  order={['alphaAsc']}
/>
<BarSeries
...
renderingOrder="renderingOrder"
/>

Describe alternatives you've considered
Implement this mechanism for each specific component can be too difficult to maintain in the long run and difficult to reuse across multiple chart elements

Additional context
Kibana vislib has a different rendering order than the one we currently use, the same happens for TSVB

@markov00 markov00 added enhancement New feature or request :data Data/series/scales related issue labels Aug 26, 2020
@markov00 markov00 added this to the Kibana 7.11 milestone Aug 26, 2020
@nickofthyme
Copy link
Collaborator

Sort should include SeriesIdentifier and if available the given value (per elastic/kibana#46466).

@nickofthyme
Copy link
Collaborator

@markov00 is this closed with #924?

@markov00
Copy link
Member Author

markov00 commented Feb 5, 2021

@nickofthyme the #924 doesn't cover the case requested in TSVB where we need to sort the legend by the extra value.
There is also another reason to keep this open: the API is not exposed yet

@nickofthyme
Copy link
Collaborator

Oh yeah I forgot it's a secret 🤫

@markov00 markov00 removed this from the Kibana 7.11 milestone May 26, 2021
@markov00
Copy link
Member Author

@nickofthyme probably we can close also this one

@nickofthyme
Copy link
Collaborator

Yeah

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:data Data/series/scales related issue enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants