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

[TSVB] Integrates the color service #93749

Merged
merged 22 commits into from
Mar 23, 2021

Conversation

stratoula
Copy link
Contributor

@stratoula stratoula commented Mar 5, 2021

Summary

Closes #93407

This PR integrates the new palette service to TSVB. TSVB uses three palettes to color the series when a user split the series by Terms. If the user changes the palette dropdown without having split the series by terms this setting is not applied. I kept the same logic in order to not introduce breaking changes.

The integration with the new service provides us the following advantages:

  • We use the same system with Lens and XY axis plugin
  • Now the color sync works on a dashboard for the TSVB visualizations too
  • Now the user has more palettes choices (I kept the existing three and added the rest EUI palettes).

Note: I tried to be backwards compatible and avoid writing a migration script so the old key split_color_mode is kept and used to distinguish between the new and the old visualizations.

TSVB with an EUI Palette:
image

Palette Picker with the existing gradient and rainbow palettes
image

Color sync on dashboard (TSVB and Lens charts):
image

Checklist

Delete any items that are not applicable to this PR.

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream


const handlePaletteChange = (val) => {
props.onChange({
split_color_mode: null,
Copy link
Contributor Author

@stratoula stratoula Mar 16, 2021

Choose a reason for hiding this comment

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

In order to be backwards compatible I haven't removed the split_color_mode. Otherwise, I had to write a migration script to get its value and use it as the palette name. I preferred to skip the migration script.

@stratoula stratoula added Feature:TSVB TSVB (Time Series Visual Builder) enhancement New value added to drive a business result Team:Visualizations Visualization editors, elastic-charts and infrastructure release_note:enhancement v7.13.0 v8.0.0 and removed enhancement New value added to drive a business result labels Mar 16, 2021
@stratoula stratoula marked this pull request as ready for review March 16, 2021 13:01
@stratoula stratoula requested a review from a team March 16, 2021 13:01
@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.

Just a note: The gradient color seems to look very slightly different (should be fine):
Screenshot 2021-03-18 at 16 55 49
Screenshot 2021-03-18 at 16 55 55

An extisting saved TSVB vis renders like this though:
Screenshot 2021-03-18 at 16 57 50

Also I can't find a configuration of the "Default palette" in the old version - can a chart still look like this?

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@stratoula
Copy link
Contributor Author

@flash1293 thanx a lot for the review, I will look into your comments soonish. About the Default palette it seems that is actually the vislib palette.

Old implementation Default Palette
image

New implementation kibana_palette
image

I just saw that the mapping is not exactly the same - I will look into this - but I think that the current one is correct as I have created the same chart on the xy axis plugin and the color mapping is the same.

@flash1293
Copy link
Contributor

I just saw that the mapping is not exactly the same - I will look into this - but I think that the current one is correct as I have created the same chart on the xy axis plugin and the color mapping is the same.

Yeah, that's what I meant. I'm realizing this just now, but it looks like it's shifted by one and otherwise the same.

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@stratoula
Copy link
Contributor Author

@flash1293 I am fetching the palettes on the renderer as you proposed. About the other issues:

  • Gradient palette. Tbh I can't see the difference. Can you help me here? For example. here is a chart on master and on my branch. They seem the same to me. Unless I am missing something here.

Screenshot 2021-03-22 at 9 17 04 AM

Screenshot 2021-03-22 at 9 14 58 AM

  • About the default palette. It seems that the legacy color service excludes the first color of the series (it applies this to the count aggregation and then uses the rest colors for the terms). But this doesn't make sense to TSVB. The count agg color is given by the user so I think that the current implementation is the correct one (also matches Lens and XY axis plugin). wdyt?

@flash1293
Copy link
Contributor

flash1293 commented Mar 22, 2021

I recorded this gif, switching between the two versions. It super close, I wouldn't worry
shadesofgreen

About the default palette. It seems that the legacy color service excludes the first color of the series (it applies this to the count aggregation and then uses the rest colors for the terms). But this doesn't make sense to TSVB. The count agg color is given by the user so I think that the current implementation is the correct one (also matches Lens and XY axis plugin). wdyt?

Oh, that's actually an important point - if you are using the palette service, visualization:colorMapping won't be respected anymore (we did that on purpose because we didn't want to pull in this behavior in Lens). This means vis_type_xy (and TSVB after this PR) would drop support for visualization:colorMapping which can be regarded as a breaking change. Not sure what we should do here tbh...

Legacy TSVB visualizations work fine now btw.

@stratoula
Copy link
Contributor Author

After syncing offline with Joe, we decided that we want the advanced setting visualization:colorMapping to be respected for the compatibility palette. I have created an issue here

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.

Tested and works as expected, LGMT

The only weird thing I noticed is that empty string is not treated the same way but we can also fix this on the Lens side (it's a pending tech debt item)
Screenshot 2021-03-22 at 17 59 21

@stratoula
Copy link
Contributor Author

stratoula commented Mar 22, 2021

Hmmm good point, and on xy axis works like that
image

I suggest to fix TSVB to work as XY axis. It uses the color from the editor and not the palette mapping. I will fix it tmr

@flash1293
Copy link
Contributor

I suggest to fix TSVB to work as XY axis, wdyt

I'm fine with that as well. If you do, could you leave a note here #68060 so this doesn't break once we clean up the handling in Lens?

@stratoula
Copy link
Contributor Author

of course :)

@stratoula
Copy link
Contributor Author

Fixed, now (empty) has the same color for Lens, XY and TSVB viz
image

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
visTypeTimeseries 472 477 +5

Async chunks

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

id before after diff
visTypeTimeseries 1.6MB 1.6MB +13.3KB

Page load bundle

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

id before after diff
visTypeTimeseries 123.9KB 124.4KB +421.0B

History

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

@stratoula stratoula merged commit 7d303eb into elastic:master Mar 23, 2021
stratoula added a commit to stratoula/kibana that referenced this pull request Mar 23, 2021
* [TSVB] Integrates the color service

* Fix i18n failure

* Sync colors :)

* Fix unit tests

* Apply the multiple colors also for gauge

* Fix

* More unit tests

* Cleanup

* Be backwards compatible

* Fetch palettesService on vis renderer

* Fix eslint

* Fix jest test

* Fix color mapping for empty labels

Co-authored-by: Kibana Machine <[email protected]>
stratoula added a commit that referenced this pull request Mar 23, 2021
* [TSVB] Integrates the color service

* Fix i18n failure

* Sync colors :)

* Fix unit tests

* Apply the multiple colors also for gauge

* Fix

* More unit tests

* Cleanup

* Be backwards compatible

* Fetch palettesService on vis renderer

* Fix eslint

* Fix jest test

* Fix color mapping for empty labels

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:TSVB TSVB (Time Series Visual Builder) release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.13.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[TSVB] Use color service instead of the custom implementation
4 participants