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

[Lens] Custom Breakdown Presentation Order #191988

Open
MichaelMarcialis opened this issue Sep 3, 2024 · 14 comments
Open

[Lens] Custom Breakdown Presentation Order #191988

MichaelMarcialis opened this issue Sep 3, 2024 · 14 comments
Labels
discuss Feature:ElasticCharts Issues related to the elastic-charts library Feature:Lens Team:Visualizations Visualization editors, elastic-charts and infrastructure

Comments

@MichaelMarcialis
Copy link
Contributor

As part of the One Discover contextual logs effort, we would like to present a histogram of documents broken down by the log.level field. To make this information easier to interpret, it would be ideal if we could have greater control over the breakdown presentation order, allowing us to order the legend and breakdown stacking by log.level severity (see example in mockup below). As I understand it, this is currently not possible on either the Lens and Elastic Charts side.

Image

Related issue: #86184

CCing @stratoula, @teresaalvarezsoler, @nickofthyme.

@MichaelMarcialis MichaelMarcialis added Feature:ElasticCharts Issues related to the elastic-charts library Feature:Lens Team:Visualizations Visualization editors, elastic-charts and infrastructure labels Sep 3, 2024
@elasticmachine
Copy link
Contributor

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

@teresaalvarezsoler
Copy link

@stratoula is this chart only for ES|QL or also for the dataview mode?

@stratoula
Copy link
Contributor

stratoula commented Sep 4, 2024

Both! right @davismcphee ?

@teresaalvarezsoler teresaalvarezsoler changed the title [Lens] [Elastic Charts] Custom Breakdown Presentation Order [Spike] [Lens] [Elastic Charts] Custom Breakdown Presentation Order Sep 4, 2024
@teresaalvarezsoler
Copy link

Scope for this issue: we need a bit more investigation to figure out how to solve this problem so we are repurposing this as a spike and time-boxing it to < 1 week

@davismcphee
Copy link
Contributor

@stratoula correct! This is needed for both data view and ES|QL mode.

@nickofthyme nickofthyme self-assigned this Sep 12, 2024
@nickofthyme nickofthyme changed the title [Spike] [Lens] [Elastic Charts] Custom Breakdown Presentation Order [Lens] Custom Breakdown Presentation Order Oct 8, 2024
@nickofthyme
Copy link
Contributor

This functionality will be available in kibana when #195447 is merged.

@nickofthyme nickofthyme removed their assignment Oct 13, 2024
@markov00
Copy link
Member

#195447 is merged but this can be achieved today only through Lens override functions, that are not persisted into Lens nor into a Dashboard.
I'd like to propose adding this feature in Lens by reusing the sorting order of the color mapping for rendering purposes too.
The sorting order of the data is inherently connected to the breakdown. This should be part of the breakdown configuration, where you can specify the data sorting (not the ranking): usually you can specify it with asc/desc/numerical/alphabetical but you can also specify it via in a list/index of terms/values to follow.
For now, we can probably also consider using the color mapping for that functionality, because it aligns with that concept.
This can be applied on a request basis via a switch in the color mapping like the following example:

In the long run, probably these operations should be described in the "data processing" part of Lens and not connected to the data styling.

@MichaelMarcialis
Copy link
Contributor Author

MichaelMarcialis commented Oct 15, 2024

I'd like to propose adding this feature in Lens by reusing the sorting order of the color mapping for rendering purposes too.

@markov00: I agree that we should provide configuration controls for users to apply a custom order to their visualization breakdowns. However, I do have a few concerns about relegating that control to the color mapping interface:

  1. I fear it will have very low discoverability there. What if a user doesn't wish to change their breakdown colors (which I believe is a majority of users)? Would they know to find such sorting controls there?
  2. Using a breakdown dimension isn't the only way for users to stack bar or area charts. For example, what if a user has multiple stacked bar layers with no breakdowns? Would we need to accommodate for adjusting the sort order in such a scenario? If so, I don't think the color mapping interface would be viable, as it is attributed to a single layer.
  3. The current color mapping interface has no drag-and-drop support for the reordering of terms. We can of course add drag-and-drop to it, but I fear that it would make an already complex UI even more complex.

Also, this related issue from Wylie seemed to indicate that there were use cases beyond just breakdowns.

Personally, my initial instinct is to add any sort of sorting controls at the global visualization level (i.e. toolbar menus), if we need to account for that multi-layer example I describe above. If we don't have to account for the multi-layer example, then at the root-level of the appropriate layer dimension's configuration flyout (i.e. not within the deeper color mapping configuration) would be my preference. Thoughts?

@markov00
Copy link
Member

@MichaelMarcialis let's discuss this offline and understand what/where we can go

@kertal
Copy link
Member

kertal commented Nov 25, 2024

What's the current state of this issue, as it appears to block #194549? thx

@markov00
Copy link
Member

markov00 commented Dec 3, 2024

Unfortunately we don't have the capacity to take this fully right now. We suggested some other workarounds that involves revisiting the way UnifiedHistogram works to unblock this in the mean time.
This currently has a low priorities. Please contact @ghudgins if this priority needs to be escalated

@ghudgins
Copy link
Contributor

ghudgins commented Dec 6, 2024

we spoke about it this AM for an hour and likely need to sync with @ninoslavmiskovic and @davismcphee to figure out how important this is and which alternative path is the right one:

  1. change query in histogram to use a sort column discover team says unified histogram isn't safe to change and will be refactored
FROM kibana_sample_data_logs
  | EVAL sortIndex = CASE(extension.keyword == "zip", 1, extension.keyword == "deb", 2, extension.keyword == "css", 3, extension.keyword == "gz", 4, extension.keyword == "rpm", 5, 100)
  | STATS COUNT(*) BY time = BUCKET(@timestamp, 100, ?_tstart, ?_tend),  extension.keyword, sortIndex
  | SORT sortIndex ASC, time ASC
  | DROP sortIndex
  1. implement the sort logic in lens hard coded on log.level - not a great solution as it would be broken in the UI when you use logs data
  2. a bad lens custom sort text box we have to live with forever (it's in saved object--would be some delimiter separated list of strings and would have issues) - commits us to a somewhat limited solution in the client. would require us to clean it up later or double down on it with more user experience. most of the work to do 3 is the same as 5 so we might as well do 5
  3. override sort in discover but visualization changes when you save to dashboard, sort is broken not a viable solution because it breaks the promise that the visualization is something you can use in a dashboard
  4. a good lens custom sort user experience that is like color by term that we live with forever (it's in the saved object) - would take 1 month to do. up against priorities and other enhancements but would provide a good user experience
  5. ESQL adds custom SORT (list of strings) - added to ESQL list, not prioritized yet
  6. ESQL adds dynamic SORT by query (how we do breakdown order in DSL for date histogram) - additional functionality ESQL needs beyond the custom SORT in the long run (or we double down on the client)

@davismcphee
Copy link
Contributor

Thanks for the update @ghudgins 👍 I agree we should do a sync about it to work through some of the details and make sure we're all on the same page.

discover team says unified histogram isn't safe to change and will be refactored

I don't want to mislead here, we can definitely make changes to Unified Histogram to support custom breakdown orders. There are issues with it currently so we intend to refactor regardless, but it wouldn't stop us from making necessary changes.

I think the main issue with that approach is just that it's ES|QL only, which may be ok since we've been asked to focus primarily on ES|QL now, but of course a solution that works for all use cases would be preferred if feasible. Maybe this would work in combination with #7 to support both cases though:

ESQL adds dynamic SORT by query (how we do breakdown order in DSL for date histogram)

I think I'm missing some context though since I'm not familiar with "how we do breakdown order in DSL for date histogram". Definitely something to explore in our sync.

@kertal
Copy link
Member

kertal commented Dec 6, 2024

should we already use our Monday DataDiscovery sync for this? however it collides with VisEditors sync, but we had nice VisEditior folks at the start of our sync the last 2 weeks, it could become a tradition ... or we setup a seperate one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss Feature:ElasticCharts Issues related to the elastic-charts library Feature:Lens Team:Visualizations Visualization editors, elastic-charts and infrastructure
Projects
None yet
Development

No branches or pull requests

9 participants