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.

StackedAreaChart doesn't properly render all data points

See original GitHub issue

What is the problem?

StackedAreaChart doesn’t properly render all the data points. In particular, it only renders the first keys.length data points.

When does it happen?

The following code should render a StackedAreaChart that looks like the one from the examples, but with one additional data point (making five total).

class StackedAreaExample extends React.PureComponent {

    render() {

        const data = [
            {
                month: new Date(2015, 0, 1),
                apples: 3840,
                bananas: 1920,
                cherries: 960,
                dates: 400,
            },
            {
                month: new Date(2015, 1, 1),
                apples: 1600,
                bananas: 1440,
                cherries: 960,
                dates: 400,
            },
            {
                month: new Date(2015, 2, 1),
                apples: 640,
                bananas: 960,
                cherries: 3640,
                dates: 400,
            },
            {
                month: new Date(2015, 3, 1),
                apples: 3320,
                bananas: 480,
                cherries: 640,
                dates: 400,
            },
            {
                month: new Date(2015, 4, 1),
                apples: 2320,
                bananas: 780,
                cherries: 440,
                dates: 400,
            },
        ]

        const colors = [ '#ED5314', '#FFB92A', '#FEEB51', '#9BCA3E' ]
        const keys   = [ 'apples', 'bananas', 'cherries', 'dates' ]

        return (
            <StackedAreaChart
                style={ { height: 200, paddingVertical: 16 } }
                data={ data }
                keys={ keys }
                colors={ colors }
                curve={ shape.curveNatural }
                showGrid={ false }
            />
        )
    }
}

However, this code only renders the first four data points.

What platform?

Occurs on both iOS and Android platforms.

Additional comments

I think the problem has something to do with this line, which seems to be using keys.length when it should be using data.length. However, changing that line alone does not fix the issue, so there must be another place where the number of data points is being calculated incorrectly.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mrbodoiacommented, Jan 31, 2018

Looks good to me. Thanks!

0reactions
JesperLeklandcommented, Feb 1, 2018

Released in v.2.2.2. Thank you for reporting the issue and helping with the fix 🥇

Read more comments on GitHub >

github_iconTop Results From Across the Web

ggplotly rendering issues due to too many data points
My actual data has 9500 data points across the stacked area chart. When I remove the custom text tooltips, it plots fine.
Read more >
Stacked Area Chart - starting data point not plotted on last ...
We use stacked area charts to display data. I have noticed, since 13.2, that stacked area charts that have more than 3 series...
Read more >
Rendering Artifacts in Stacked Area Chart with Gaps-Highcharts
Could be a bug in highcharts, a workaround is to use step , like this: plotOptions: { series: { stacking: 'percent', gapSize: 1,...
Read more >
Stacked Area Chart is misleading if all groups don't have values
This is causing my stacked area chart to have odd jumps in the data. Here's an example where position "Jrny" had values in...
Read more >
Build and style a chart with the new Swift Charts framework
Screenshot of a stacked area chart showing US baby names over time. NOTE: It's very important to sort the data points by name....
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