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

Reduce charts bundle size #104697

Closed
Tracked by #88678
timroes opened this issue Jul 7, 2021 · 1 comment · Fixed by #130132
Closed
Tracked by #88678

Reduce charts bundle size #104697

timroes opened this issue Jul 7, 2021 · 1 comment · Fixed by #130132
Labels
Feature:Visualizations Generic visualization features (in case no more specific feature label is available) performance Team:Visualizations Visualization editors, elastic-charts and infrastructure

Comments

@timroes
Copy link
Contributor

timroes commented Jul 7, 2021

Did some investigation. The easiest way to save some bytes is to not require the color package in the main bundle.

This is where it's used:

MappedColors
-> palettes (charts)
-> LegacyColorsService
   -> ChartsPlugin (setup/start)
      -> initVisConfig (Vis) vislib
         -> render (Vis) vislib  async!
         -> render (VisController) vislib async!
lightenColor
-> palettes (charts)
-> ColorPicker (charts)
   -> getColorPicker (vis_type_xy)
      -> VisComponent (vis_type_xy) react component
         -> xyVisRenderer.render (vis_type_xy) async!
   -> getColorPicker (vis_type_pie)
      -> PieComponent (vis_type_pie) react component
         -> getPieVisRenderer (vis_type_pie) async!
-> getLayers (vis_type_pie)
      -> PieComponent (vis_type_pie) react component
         -> getPieVisRenderer (vis_type_pie) async!
createColorPalette doesn't actually need the color package

Plan:

  • Lazy load legacy color service (getLegacyColorService: Promise on contract instead of instance)
  • Resolve in render method of VisController in vislib and pass down to initVisConfig
  • Pass this service getter into PaletteService - resolve there in getPalettes and pass to buildPalettes (use sync in there)

  • Remove static export lightenColor
  • Turn into getLightenColorService: Promise on contract)
  • Pass this service getter into PaletteService - resolve there in getPalettes and pass to buildPalettes (use sync in there)
  • Resolve getLightenColorService in getPieVisRenderer and in xyVisRenderer - pass down from there through component to getColorPicker and getLayers in sync way

  • Make ColorPicker a lazy component which is exported statically (handles async-ness in react)

  • Inline small helper to turn hsl into hex (it's just a couple of lines instead of the whole color package)

Will probably save between 30 and 40%

Extracted from #103749

@timroes timroes added Feature:Visualizations Generic visualization features (in case no more specific feature label is available) performance Team:Visualizations Visualization editors, elastic-charts and infrastructure labels Jul 7, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@lizozom lizozom changed the title Reduce page load bundle size of charts plugin Reduce charts bundle size Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Visualizations Generic visualization features (in case no more specific feature label is available) performance Team:Visualizations Visualization editors, elastic-charts and infrastructure
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants