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

[Meta] Statistics in chart legends #176583

Closed
teresaalvarezsoler opened this issue Feb 9, 2024 · 4 comments
Closed

[Meta] Statistics in chart legends #176583

teresaalvarezsoler opened this issue Feb 9, 2024 · 4 comments
Assignees
Labels
enhancement New value added to drive a business result Feature:Lens impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. Team:Visualizations Visualization editors, elastic-charts and infrastructure

Comments

@teresaalvarezsoler
Copy link

teresaalvarezsoler commented Feb 9, 2024

Describe the feature:
Users want to see some statistics (e.g., avg, min, max, etc.) for their metrics in the legend so they can get their insights faster by easily accessing more information within the chart.
image

Requirements

  • Bar, Line and Area charts will show the following options:
    -- Value: The exact value when mousing over a specific data point
    -- Average: Average value considering all data points in the chart
    -- Median: Median value considering all data points in the chart
    -- Max: Maximum value considering all data points in the chart
    -- Min: Minimum value considering all data points in the chart
    -- First: First value considering all data points in the chart
    -- First non-null: First non-null value
    -- Last: Last value considering all data points in the chart
    -- Last non-null: Last non-null value
    -- Total: Sum of al values plotted in the chart
    -- Count: number of data points plotted in the chart
    -- Distinct Count: number of data points with different values plotted in the chart
    -- Variance: Variance of all data points plotted in the chart
    -- Std Deviation: Standard deviation of all data points plotted in the chart
    -- Range: Difference between min and max values
    -- Difference: Difference between first and last values
    -- Different percent: % difference between first and last values
  • All statistics will be compute considering the entire time range selected and the aggregated data points shown in the chart (NOT the original data coming from ES). For example, if the metric plotted in the chart is Median(system.cpu) and the time range is last 24 hours, when the user selects Max to be shown in the Legend, it will be computed as the Max[Median(system.cpu)] for the last 24 hours.
  • Pie charts will only have two static options:
    -- Value
    -- Percentage
  • Users will be able to configure the values from the legend configuration pop-up:
    -- Include the "Current value" option in the dropdown and remove the switcher
    -- Users can select between Table (default) and List layouts.
    -- Users will still be able to select truncation and multi-line for the series labels (only for the Table layout)
    -- Users can select the "Inside" legend location
    -- Include a default "Auto" option for the Legend width to automatically adapt to the values selected although the user can override it by selecting a fixed width
image image
@botelastic botelastic bot added the needs-team Issues missing a team label label Feb 9, 2024
@dej611 dej611 added Team:Visualizations Visualization editors, elastic-charts and infrastructure Feature:Lens labels Feb 12, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-visualizations (Team:Visualizations)

@botelastic botelastic bot removed the needs-team Issues missing a team label label Feb 12, 2024
@dej611 dej611 added the enhancement New value added to drive a business result label Feb 12, 2024
@stratoula
Copy link
Contributor

Duplicate of #16096

@teresaalvarezsoler can you decide which one of the 2 we are going to keep? 🙏

@stratoula
Copy link
Contributor

I closed the old one and I am keeping this instead

@stratoula stratoula added the impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. label Feb 12, 2024
@markov00 markov00 self-assigned this Mar 11, 2024
@markov00 markov00 changed the title [Meta] Show metric values in chart legends [Meta] Statistics in chart legends Apr 2, 2024
@markov00 markov00 assigned mbondyra and nickofthyme and unassigned markov00 Apr 4, 2024
mbondyra added a commit that referenced this issue Apr 10, 2024
## Summary

These changes are just small redesign of the Legend popover in
preparation for Legend stats changes (following the design from
#176583)

I also rewrote the tests to testing library and removed deprecated
`name` prop for EuiButtonGroup that it doesn't need anymore.

Design:
<img width="426" alt="Screenshot 2024-04-09 at 11 44 00"
src="https://github.com/elastic/kibana/assets/4283304/2995f048-2ced-46be-9fb4-cf52d7d7c134">

Changes that I could implement in this PR:
for xy:
<img width="467" alt="Screenshot 2024-04-09 at 15 49 11"
src="https://github.com/elastic/kibana/assets/4283304/2b2bf0c8-9cb2-422d-883e-a74c79cca9a5">

<img width="465" alt="Screenshot 2024-04-09 at 15 49 16"
src="https://github.com/elastic/kibana/assets/4283304/4aa10d0e-eac3-4d77-b564-7b391c3155e8">


for pie:
<img width="468" alt="Screenshot 2024-04-09 at 15 49 28"
src="https://github.com/elastic/kibana/assets/4283304/57cda18d-f390-4a29-88e5-99cdb7b24be5">
mbondyra added a commit that referenced this issue Apr 26, 2024
…on for legend statistics (#180917)

## Summary

This PR addresses phase one of
#181035.

Doesn't introduce any user facing changes. 
It starts supporting a new saved object property `legendStats` while
supporting a old `valuesInLegend` property. In this PR, `legendStats:
['values']` and `valuesInLegend:true` are treated as equal. When loading
the saved object, `valuesInLegend:true` is transformed to
`legendStats:['values']`. After loading the document, the Lens app logic
is built around the new `legendStats` property.
When user saves the saved object, we do a reverse operation- we save the
runtime state `legendStats:['values']` as `valuesInLegend: true` to
ensure backwards compatibility.


![image](https://github.com/elastic/kibana/assets/4283304/5e09b062-b4d3-424d-b8a8-79a08f4d6260)


Changes for runtime state:

- For xyCharts, the `valuesInLegend?: boolean ` property is replaced
with a more extensible `legend.legendStats?: LegendStats[]` interface

- For partition charts, the `showValuesInLegend?: boolean` property is
replaced with `legendStats?: LegendStats[]`.

after loading - in initialize function:

```ts
export function convertToRuntime(
  state: XYPersistedState,
  annotationGroups?: AnnotationGroups,
  references?: SavedObjectReference[]
) {
  const outputState = needsInjectReferences(state)
    ? injectReferences(state, annotationGroups, references)
    : state;
  if ('valuesInLegend' in outputState) {
    return convertToLegendStats(outputState);
  }
  return outputState;
}
```

before saving :

```ts
export function convertToPersistable(state: XYState) {
  const persistableState: XYPersistedState = convertToValuesInLegend(state);
  /.../
}
```

In the future the `legendStats` prop would contain also other types of
stats -see the [issue](#176583).
@gvnmagni gvnmagni self-assigned this May 29, 2024
@mbondyra
Copy link
Contributor

Closing as the table version was implemented. We'll track the delivery of the list version in a separate issue: #186965

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New value added to drive a business result Feature:Lens impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. Team:Visualizations Visualization editors, elastic-charts and infrastructure
Projects
None yet
Development

No branches or pull requests

8 participants