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

Performance: Formatter is called for each data point in bar chart even if not used #1587

Open
Tracked by #2320
flash1293 opened this issue Feb 10, 2022 · 1 comment
Labels
:performance Performance related issues :xy Bar/Line/Area chart related

Comments

@flash1293
Copy link

flash1293 commented Feb 10, 2022

Describe the issue
In https://github.com/elastic/elastic-charts/blob/master/packages/charts/src/chart_types/xy_chart/rendering/bars.ts#L92 the provided formatter is called for each data point in the series, but it's only used in special circumstances:

https://github.com/elastic/elastic-charts/blob/master/packages/charts/src/chart_types/xy_chart/rendering/bars.ts#L96

In case of charts with lots of series and slow formatting functions provided this can have a noticable performance impact.

E.g. in the following chart it's spending 44ms in getConvertedValue (out of ~360ms total blocking rendering time):
Screenshot 2022-02-10 at 12 36 32

Screenshot 2022-02-10 at 12 43 04

To Reproduce
Configure a bar chart without labels on the bars and observe the provided formatter being called.

Expected behaviour
Formatter should only be called if necessary to render the chart correctly

@flash1293 flash1293 added bug Something isn't working :xy Bar/Line/Area chart related labels Feb 10, 2022
@markov00 markov00 added :performance Performance related issues and removed bug Something isn't working labels Feb 10, 2022
@markov00
Copy link
Member

markov00 commented Feb 10, 2022

Thanks Joe, yep, this can definitely be improved a lot
We can probably also call the value formatting only when showing the tooltip, without having a precomputed value saved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:performance Performance related issues :xy Bar/Line/Area chart related
Projects
None yet
Development

No branches or pull requests

2 participants