question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stacked bars performance

See original GitHub issue

I’m using stacked bars, but the set of stacks is different per bar. I think this is not the use case the current design is for.

I have about 20 bars, and 20 stacks per bar. There are about 400 unique stack values, since this is a categorical hierarchy (e.g. bars are countries, stacks are cities).

So for every bar+stack combination (400x) I’m rendering a <Bar>. After rendering, each of those further contains an <Animate><g> for every bar (20x), despite only one per bar+stack combination actually containing anything graphical inside that <g> (<Rectangle><Animate><Animate><path>).

So that’s unnecessarily complex for React to manage, and is unsuitable for this kind of data breakdown.

The data model per object is:

  • name (the unique key on the X axis) e.g. “France”
  • stack_Paris (the height of stack for Paris)
  • stack_Marseille
  • stack_LeMans
  • etc.

I’ve considered remapping the data values such that I assign a number (from zero) for each per-bar stack, and giving Recharts just the indexes, and custom renderers for labelling and colouring rectangles. It’s a bit messy but should reduce the complexity significantly (down to 400x rather than 400x20x)

Before I press on with this somewhat dirty workaround, I’d be interested to hear if there are any other ways I can structure this.

I’d like to raise the issue that Recharts is creating unnecessary <Animate><g> elements for missing (either null or absent) object atttributes for dataKey. It would be better if it we could skip them altogether, removing the 20x part of the complexity here.

Also, why two Animate in <Rectangle><Animate><Animate><path>?

(Also, the <Animate> elements are adding overhead to React (I’ve not measured how much), and would like to be able to drop them when animation isn’t in use.)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
mchong-tealcommented, Jul 25, 2019

Also running into performance issues for stacked bar graphs with unique stack categories across bars. Haven’t profiled it too deeply yet, but looks like a similar issue to above.

0reactions
dan-kezcommented, Jun 19, 2018

Hey - sorry for commenting on such an old issue. I’ve recently noticed some very bad performance for stacked bar graph animation for similar reasons as above.

Line graphs do not appear to have this problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding Stacked Bar Charts: The Worst Or The Best?
Stacked bar charts are designed to help you simultaneously compare totals and notice sharp changes at the item level that are likely to...
Read more >
use cases for stacked bars - storytelling with data
It was noted that stacked bars may work better in an interactive environment, where you can more easily focus on one piece in...
Read more >
When Are 100% Stacked Bar Graphs Useful?
Unlike normal stacked bars, the lengths of 100% stacked bars never vary, for they always add up to 100%. Consequently, when multiple 100%...
Read more >
Stacked Bars | Visual Explorer Guides - Mode Analytics
This example will walk you through how to created a simple stacked bar chart with one continuous field that's broken down by some...
Read more >
How to create a stacked bar chart? - ServiceNow Community
In Performance Analytics, I can display only one part of the chart (blue or orange) using a column visualization for a breakdown widget....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found