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

[ES|QL] [Discover] Keeps the preferred chart configuration when possible #197453

Merged
merged 50 commits into from
Nov 5, 2024

Conversation

stratoula
Copy link
Contributor

@stratoula stratoula commented Oct 23, 2024

Summary

Closes #184631

It keeps the chart configuration when the user is doing actions compatible with the current query such as:

  • Adding a where filter (by clicking the table, the sidebar, the chart)
  • Changes the breakdown field and the field type is compatible with the current chart
  • Changing to a compatible chart type (from example from bar to line or pie to treemap)
  • Changing the query that doesnt affect the generated columns mapped to a chart. For example adding a limit or creating a runtime field etc.

The logic depends on the suggestions. If the suggestions return the preferred chart type, then we are going to use this. So it really depends on the api and the type / number of columns. It is as smarter as it can in order to not create bugs. I am quite happy with the result. It is much better than what we have so far.

meow

Next steps

I would love to do the same on the dahsboard too, needs more time though. But the changes made here will def work in favor

Checklist

@stratoula stratoula changed the title Keep vis config esql [ES|QL] [Discover] Keeps the preferred chart configuration when possible Oct 25, 2024
@@ -43,3 +43,18 @@ export interface Suggestion<T = unknown, V = unknown> {
changeType: TableChangeType;
keptLayerIds: string[];
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this here as it is used in many places already

@stratoula stratoula mentioned this pull request Nov 5, 2024
74 tasks
Copy link
Member

@markov00 markov00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving but please consider the comment I've left above

@markov00 markov00 requested review from mbondyra and markov00 November 5, 2024 11:23
@stratoula stratoula enabled auto-merge (squash) November 5, 2024 11:35
@stratoula stratoula disabled auto-merge November 5, 2024 11:55
Comment on lines 12 to 28
export const mapVisToChartType = (visualizationType: string) => {
switch (visualizationType) {
case LensVisualizationType.XY:
return ChartType.XY;
case LensVisualizationType.Metric:
case LensVisualizationType.LegacyMetric:
return ChartType.Metric;
case LensVisualizationType.Pie:
return ChartType.Pie;
case LensVisualizationType.Heatmap:
return ChartType.Heatmap;
case LensVisualizationType.Gauge:
return ChartType.Gauge;
case LensVisualizationType.Datatable:
return ChartType.Table;
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing Marco's comment I actually think he might be right. Changing the code to the one below would make sure that if we add a new lens vis type, typescript will complain. WDYT?

Screenshot 2024-11-05 at 17 00 33
Suggested change
export const mapVisToChartType = (visualizationType: string) => {
switch (visualizationType) {
case LensVisualizationType.XY:
return ChartType.XY;
case LensVisualizationType.Metric:
case LensVisualizationType.LegacyMetric:
return ChartType.Metric;
case LensVisualizationType.Pie:
return ChartType.Pie;
case LensVisualizationType.Heatmap:
return ChartType.Heatmap;
case LensVisualizationType.Gauge:
return ChartType.Gauge;
case LensVisualizationType.Datatable:
return ChartType.Table;
}
};
type ValueOf<T> = T[keyof T];
type LensToChartMap = {
[K in ValueOf<typeof LensVisualizationType>]: ChartType;
};
const lensTypesToChartTypes: LensToChartMap = {
[LensVisualizationType.XY]: ChartType.XY,
[LensVisualizationType.Metric]: ChartType.Metric,
[LensVisualizationType.LegacyMetric]: ChartType.Metric,
[LensVisualizationType.Pie]: ChartType.Pie,
[LensVisualizationType.Heatmap]: ChartType.Heatmap,
[LensVisualizationType.Gauge]: ChartType.Gauge,
[LensVisualizationType.Datatable]: ChartType.Table,
};
function isLensVisualizationType(value: string): value is LensVisualizationType {
return value in LensVisualizationType;
}
export const mapVisToChartType = (visualizationType: string) => {
if (isLensVisualizationType(visualizationType)) {
return lensTypesToChartTypes[visualizationType];
}
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanx MArta, done here 6daa2c8

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This creates a bug actually

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed here cf707f8

@stratoula stratoula enabled auto-merge (squash) November 5, 2024 17:06
@elasticmachine
Copy link
Contributor

elasticmachine commented Nov 5, 2024

💛 Build succeeded, but was flaky

  • Buildkite Build
  • Commit: 4fad39b
  • Kibana Serverless Image: docker.elastic.co/kibana-ci/kibana-serverless:pr-197453-4fad39b1269a

Failed CI Steps

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
aiops 584 587 +3
apm 1882 1885 +3
charts 126 129 +3
cloudSecurityPosture 659 662 +3
dashboard 675 678 +3
dataVisualizer 729 732 +3
discover 1015 1018 +3
esqlDataGrid 368 371 +3
eventAnnotationListing 583 586 +3
expressionHeatmap 179 182 +3
expressionMetricVis 112 115 +3
expressionPartitionVis 193 196 +3
expressionTagcloud 167 170 +3
expressionXY 254 257 +3
graph 300 303 +3
investigateApp 579 582 +3
lens 1468 1472 +4
logsExplorer 568 571 +3
logsShared 700 703 +3
ml 2013 2016 +3
observability 1067 1070 +3
observabilityAIAssistantApp 381 384 +3
securitySolution 6146 6149 +3
slo 853 856 +3
transform 504 507 +3
triggersActionsUi 850 853 +3
unifiedHistogram 190 193 +3
visDefaultEditor 203 206 +3
visTypeTimelion 63 66 +3
visTypeTimeseries 459 462 +3
total +91

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/visualization-utils 17 22 +5
lens 590 591 +1
total +6

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
lens 1.5MB 1.5MB +860.0B
observabilityAIAssistantApp 239.1KB 239.2KB +53.0B
unifiedHistogram 70.1KB 71.0KB +975.0B
total +1.8KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
lens 63 62 -1

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
lens 50.8KB 50.8KB +27.0B
unifiedHistogram 10.1KB 10.5KB +413.0B
total +440.0B
Unknown metric groups

API count

id before after diff
@kbn/visualization-utils 19 24 +5
lens 692 693 +1
total +6

History

@stratoula stratoula merged commit ccbcab9 into elastic:main Nov 5, 2024
27 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/11693873531

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 5, 2024
…ble (elastic#197453)

## Summary

Closes elastic#184631

It keeps the chart configuration when the user is doing actions
compatible with the current query such as:

- Adding a where filter (by clicking the table, the sidebar, the chart)
- Changes the breakdown field and the field type is compatible with the
current chart
- Changing to a compatible chart type (from example from bar to line or
pie to treemap)
- Changing the query that doesnt affect the generated columns mapped to
a chart. For example adding a limit or creating a runtime field etc.

The logic depends on the suggestions. If the suggestions return the
preferred chart type, then we are going to use this. So it really
depends on the api and the type / number of columns. It is as smarter as
it can in order to not create bugs. I am quite happy with the result. It
is much better than what we have so far.

![meow](https://github.com/user-attachments/assets/c4249e5e-e785-4e57-8651-d1f660f5a61a)

### Next steps
I would love to do the same on the dahsboard too, needs more time
though. But the changes made here will def work in favor

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed

---------

Co-authored-by: Marta Bondyra <[email protected]>
(cherry picked from commit ccbcab9)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Nov 6, 2024
… possible (#197453) (#199069)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ES|QL] [Discover] Keeps the preferred chart configuration when
possible (#197453)](#197453)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Stratoula
Kalafateli","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-05T22:56:17Z","message":"[ES|QL]
[Discover] Keeps the preferred chart configuration when possible
(#197453)\n\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/184631\r\n\r\nIt keeps the
chart configuration when the user is doing actions\r\ncompatible with
the current query such as:\r\n\r\n- Adding a where filter (by clicking
the table, the sidebar, the chart)\r\n- Changes the breakdown field and
the field type is compatible with the\r\ncurrent chart\r\n- Changing to
a compatible chart type (from example from bar to line or\r\npie to
treemap)\r\n- Changing the query that doesnt affect the generated
columns mapped to\r\na chart. For example adding a limit or creating a
runtime field etc.\r\n\r\nThe logic depends on the suggestions. If the
suggestions return the\r\npreferred chart type, then we are going to use
this. So it really\r\ndepends on the api and the type / number of
columns. It is as smarter as\r\nit can in order to not create bugs. I am
quite happy with the result. It\r\nis much better than what we have so
far.\r\n\r\n\r\n![meow](https://github.com/user-attachments/assets/c4249e5e-e785-4e57-8651-d1f660f5a61a)\r\n\r\n###
Next steps\r\nI would love to do the same on the dahsboard too, needs
more time\r\nthough. But the changes made here will def work in
favor\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n\r\n---------\r\n\r\nCo-authored-by:
Marta Bondyra
<[email protected]>","sha":"ccbcab9623af4df0bdccb0e3e194b8484d2161a1","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Discover","enhancement","v9.0.0","release_note:feature","Team:Obs
AI
Assistant","Feature:ES|QL","ci:project-deploy-observability","backport:version","v8.17.0"],"title":"[ES|QL]
[Discover] Keeps the preferred chart configuration when
possible","number":197453,"url":"https://github.com/elastic/kibana/pull/197453","mergeCommit":{"message":"[ES|QL]
[Discover] Keeps the preferred chart configuration when possible
(#197453)\n\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/184631\r\n\r\nIt keeps the
chart configuration when the user is doing actions\r\ncompatible with
the current query such as:\r\n\r\n- Adding a where filter (by clicking
the table, the sidebar, the chart)\r\n- Changes the breakdown field and
the field type is compatible with the\r\ncurrent chart\r\n- Changing to
a compatible chart type (from example from bar to line or\r\npie to
treemap)\r\n- Changing the query that doesnt affect the generated
columns mapped to\r\na chart. For example adding a limit or creating a
runtime field etc.\r\n\r\nThe logic depends on the suggestions. If the
suggestions return the\r\npreferred chart type, then we are going to use
this. So it really\r\ndepends on the api and the type / number of
columns. It is as smarter as\r\nit can in order to not create bugs. I am
quite happy with the result. It\r\nis much better than what we have so
far.\r\n\r\n\r\n![meow](https://github.com/user-attachments/assets/c4249e5e-e785-4e57-8651-d1f660f5a61a)\r\n\r\n###
Next steps\r\nI would love to do the same on the dahsboard too, needs
more time\r\nthough. But the changes made here will def work in
favor\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n\r\n---------\r\n\r\nCo-authored-by:
Marta Bondyra
<[email protected]>","sha":"ccbcab9623af4df0bdccb0e3e194b8484d2161a1"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197453","number":197453,"mergeCommit":{"message":"[ES|QL]
[Discover] Keeps the preferred chart configuration when possible
(#197453)\n\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/184631\r\n\r\nIt keeps the
chart configuration when the user is doing actions\r\ncompatible with
the current query such as:\r\n\r\n- Adding a where filter (by clicking
the table, the sidebar, the chart)\r\n- Changes the breakdown field and
the field type is compatible with the\r\ncurrent chart\r\n- Changing to
a compatible chart type (from example from bar to line or\r\npie to
treemap)\r\n- Changing the query that doesnt affect the generated
columns mapped to\r\na chart. For example adding a limit or creating a
runtime field etc.\r\n\r\nThe logic depends on the suggestions. If the
suggestions return the\r\npreferred chart type, then we are going to use
this. So it really\r\ndepends on the api and the type / number of
columns. It is as smarter as\r\nit can in order to not create bugs. I am
quite happy with the result. It\r\nis much better than what we have so
far.\r\n\r\n\r\n![meow](https://github.com/user-attachments/assets/c4249e5e-e785-4e57-8651-d1f660f5a61a)\r\n\r\n###
Next steps\r\nI would love to do the same on the dahsboard too, needs
more time\r\nthough. But the changes made here will def work in
favor\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n\r\n---------\r\n\r\nCo-authored-by:
Marta Bondyra
<[email protected]>","sha":"ccbcab9623af4df0bdccb0e3e194b8484d2161a1"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Stratoula Kalafateli <[email protected]>
mgadewoll pushed a commit to mgadewoll/kibana that referenced this pull request Nov 7, 2024
…ble (elastic#197453)

## Summary

Closes elastic#184631

It keeps the chart configuration when the user is doing actions
compatible with the current query such as:

- Adding a where filter (by clicking the table, the sidebar, the chart)
- Changes the breakdown field and the field type is compatible with the
current chart
- Changing to a compatible chart type (from example from bar to line or
pie to treemap)
- Changing the query that doesnt affect the generated columns mapped to
a chart. For example adding a limit or creating a runtime field etc.

The logic depends on the suggestions. If the suggestions return the
preferred chart type, then we are going to use this. So it really
depends on the api and the type / number of columns. It is as smarter as
it can in order to not create bugs. I am quite happy with the result. It
is much better than what we have so far.


![meow](https://github.com/user-attachments/assets/c4249e5e-e785-4e57-8651-d1f660f5a61a)

### Next steps
I would love to do the same on the dahsboard too, needs more time
though. But the changes made here will def work in favor

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed

---------

Co-authored-by: Marta Bondyra <[email protected]>
@IanLee1521
Copy link

I came across this in the release notes for 8.17 and I've definitely been bitten by this before. Looking forward to trying this out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:version Backport to applied version labels ci:project-deploy-observability Create an Observability project enhancement New value added to drive a business result Feature:Discover Discover Application Feature:ES|QL ES|QL related features in Kibana release_note:feature Makes this part of the condensed release notes Team:Obs AI Assistant Observability AI Assistant v8.17.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Discover][ES|QL] Filtering by clicking should keep the selected chart type
8 participants