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

[XY axis] Implement new palette service #86876

Merged
merged 24 commits into from
Jan 13, 2021

Conversation

stratoula
Copy link
Contributor

@stratoula stratoula commented Dec 23, 2020

Summary

Closes #82495.
This PR integrates the new palette service to the new XY axis plugin. So in order to test it, the Legacy charts library switch should be off (this is the default state).

We introduce a new dropdown on the Panel Settings tab of the XY plugin.
Screenshot 2021-01-04 at 10 31 16 AM

Here the user can choose which palette she wants to use.

  • For a new visualization the default palette will be chosen.
  • For an existing visualization the kibana_palette will be chosen. (For this reason, I have added the migration script)

What this PR implements

  • I have created the color picker component which is exported from the editor plugin as it is going to be used for the rest vislib charts that are going to be converted to elastic charts (pie chart is the next one).
  • Integration with the new palette service on the xy plugin
  • Color sync on dashboard (see screenshots below)
  • Add the dropdown on telemetry to have analytics on the palettes usage (especially how many users are going to use the legacy palette)
  • Migration script to default the existing visualizations on the kibana palette. (legacy one)

Screenshots

Bar and area charts without color syncing (legacy palette)
Screenshot 2021-01-04 at 10 24 30 AM

Bar and area charts with color syncing (legacy palette)
Screenshot 2021-01-04 at 10 24 37 AM

Color syncing between Lens and XY plugin (default palette)
Screenshot 2021-01-04 at 10 27 27 AM

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@stratoula stratoula changed the title Xy plugin new palette [XY axis] Implement new palette service Dec 23, 2020
@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

merge conflict between base and head

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

const showNoResult = shouldShowNoResultsMessage(visData, visType);
const isSplitChart = Boolean(visConfig.dimensions.splitRow || visConfig.dimensions.splitRow);
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 is irrelevant with this PR but it's an OR on the same value.

@stratoula stratoula marked this pull request as ready for review January 4, 2021 13:00
@stratoula stratoula requested a review from a team January 4, 2021 13:00
@stratoula stratoula requested a review from a team as a code owner January 4, 2021 13:00
@stratoula stratoula added the Team:Visualizations Visualization editors, elastic-charts and infrastructure label Jan 4, 2021
@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

On editing an existing visualization (I picked one from the logs sample dashboard), it seems like changing the palette doesn't have any effect:
Screenshot 2021-01-07 at 10 29 40

@stratoula
Copy link
Contributor Author

@flash1293 thanx for reviewing and testing this PR 🙂 I will check this!

@stratoula
Copy link
Contributor Author

@flash1293 it should be ok now. Make sure also that the migration script has run. It should default on the legacy palette

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@flash1293
Copy link
Contributor

flash1293 commented Jan 11, 2021

@stratoula I can still reproduce this specific thing, these are the steps:

  • Install logs sample data and go to dashboard
  • Edit "[Logs] Unique Visitors vs. Average Bytes"
  • Add a split series of terms of geo.src
  • Change palette
  • Update
  • default palette is still used

Maybe it's something about this visualization in particular?

@stratoula
Copy link
Contributor Author

Thanx for the steps Joe, I didn't test this scenario. Let me check it

@stratoula
Copy link
Contributor Author

@flash1293 great catch! It fails for all the visualizations that have more than one metric. I will proceed with a fix

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

Left one remark, but this works pretty well, thanks!

Low prio UI nit - can we make sure the palette picker is full-width here:
Screenshot 2021-01-11 at 15 40 57

That might be a personal thing but it looks weird to me among the full width select elements

@@ -77,8 +77,9 @@ export class VisTypeXyPlugin
if (!core.uiSettings.get(LEGACY_CHARTS_LIBRARY, false)) {
setUISettings(core.uiSettings);
setThemeService(charts.theme);
setColorsService(charts.legacyColors);

charts.palettes.getPalettes().then((palettes) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function should not be called directly in a plugin lifecycle because it's meant to enable lazy loading (if it's loaded every time the plugin is loaded, that's pretty much defeated).

It should be called if it's certain a chart will be rendered very soon (e.g. in the renderer or behind some existing lazy loading barrier)

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

LGTM, works as expected. Thanks for taking care of lazy loading.

We don't necessarily have to change that because I think the experience is nice, but I want to point out one small difference to Lens - if there is no "split series" dimension, it will always use the default palette and don't allow the user to change it.

@stratoula
Copy link
Contributor Author

Thanx Joe 🙂 Yes, I know that is quite different from Lens and I thought about it too but I like it that way. I don't have a strong opinion on it but we can leave it as it is and see how it goes

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@nickofthyme nickofthyme left a comment

Choose a reason for hiding this comment

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

LGTM, great addition! Tested locally on chrome on multiple sample visualizations.

src/plugins/vis_type_xy/public/vis_renderer.tsx Outdated Show resolved Hide resolved
Copy link
Member

@ppisljar ppisljar left a comment

Choose a reason for hiding this comment

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

code LGTM

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
visDefaultEditor 126 127 +1
visTypeXy 107 108 +1
total +2

Async chunks

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

id before after diff
visTypeXy 152.0KB 157.4KB +5.4KB

Page load bundle

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

id before after diff
expressions 200.6KB 200.7KB +122.0B
visDefaultEditor 44.3KB 46.4KB +2.0KB
visTypeXy 68.0KB 69.5KB +1.5KB
visualizations 171.0KB 171.2KB +228.0B
total +3.8KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@stratoula stratoula merged commit 633495e into elastic:master Jan 13, 2021
stratoula added a commit to stratoula/kibana that referenced this pull request Jan 13, 2021
* [XY Axis] New Palette service

* Calculate all Series to map the colors correctly

* remove commented out code

* syncColors on XY plugin

* Reset to false when no embeddable

* Add unit test for getAllSeries function

* Measure the usage of the selected palette

* Minor adjustments

* Update documentation for isSyncColorsEnabled method

* Fix bug on changing palette on charts with no split series

* Fix coloring for multiple y axis visualizations

* Call getPalettes function from the renderer

* Fullwidth palette picker

* Fetch palette registry on the component and not on the renderer

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
stratoula added a commit that referenced this pull request Jan 13, 2021
* [XY Axis] New Palette service

* Calculate all Series to map the colors correctly

* remove commented out code

* syncColors on XY plugin

* Reset to false when no embeddable

* Add unit test for getAllSeries function

* Measure the usage of the selected palette

* Minor adjustments

* Update documentation for isSyncColorsEnabled method

* Fix bug on changing palette on charts with no split series

* Fix coloring for multiple y axis visualizations

* Call getPalettes function from the renderer

* Fullwidth palette picker

* Fetch palette registry on the component and not on the renderer

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:ExpressionLanguage Interpreter expression language (aka canvas pipeline) Feature:XYAxis XY-Axis charts (bar, area, line) release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.12.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor vis_type_xy plugin to use palette service
6 participants