Skip to content
This repository was archived by the owner on Jul 19, 2019. It is now read-only.
This repository was archived by the owner on Jul 19, 2019. It is now read-only.

Update() does not work with Radar Chart #80

Closed

Description

@phil-lauffenburger

I am passing in data in the render() portion of my react component to a radarchart

<div className = "container-fluid">
     <RadarChart data={results} options={chartOptions}  width="600" height="250"/>
        </div>

When the component re-renders, I get the following error:
Uncaught TypeError: Cannot read property 'length' of undefined

originating from this codeline:

 while (chart.scale.xLabels.length > nextProps.data.labels.length) {

If I change my radar chart to a bar chart it works just fine. Is there something I'm missing here?

Thanks!

Activity

  1. blizzo521 commented on Feb 26, 2016

    @blizzo521

    +1 on this, I am having the same problem. Radar chart is the whole reason i'm using this library so if I can't get it to work I will have to replace it :(

  2. pardhaponugoti commented on Mar 15, 2016

    @pardhaponugoti

    I passed in redraw as a prop and it fixed the issue for me. It scraps the old chart and makes a whole new one every time though. For example, your code would look like this:

    `


    `

    I saw it at the bottom of this page:

    https://github.com/jhudson8/react-chartjs

  3. phil-lauffenburger commented on Mar 15, 2016

    @phil-lauffenburger
    ContributorAuthor

    Yeah, that works for me as well. I just don't like how redrawing the chart looks.

  4. rossPatton commented on Mar 22, 2016

    @rossPatton

    adding to this. redraw fixes the issue for me as well, but it shouldn't really be needed

  5. cryptic-mystic commented on Mar 23, 2016

    @cryptic-mystic
    Contributor

    Hey guys, I was having an issue with my doughnut charts updating (which shares code with radar and circle charts). Old data points would not be removed when the new dataset was of a smaller length than the previous. I've made a PR under #88, if you think it might help your problems we can make an effort to get it merged.

  6. austinpray commented on Mar 27, 2016

    @austinpray
    Contributor

    Can you guys check if #88 fixed your issue?

  7. added this to the 1.0.0 milestone on Mar 27, 2016
  8. phil-lauffenburger commented on Mar 29, 2016

    @phil-lauffenburger
    ContributorAuthor

    Ok, so #88 does not fix the issue. #88 just applies to Polar/Pie/Doughnut Charts. However, chart.removeData() seemed promising. I mucked around with it a bit and removed the while loop just below the change in #88.

    } else { chart.removeData(); nextProps.data.datasets.forEach(function(set, setIndex) {

    This of course causes some other errors but I just added a few extra if statements to classData.componentWillReceiveProps:

    if (chart.scale) { chart.scale.xLabels = nextProps.data.labels; if (chart.scale.calculateXLabelRotation){ chart.scale.calculateXLabelRotation(); } }

    Now, my radar chart is updating without redrawing. This feels like a bit of a hack, so I want to poke at it a bit more before submitting a pull request.

    Any thoughts?

  9. cryptic-mystic commented on Mar 29, 2016

    @cryptic-mystic
    Contributor

    @lauffenp Yeah my commit only related to those charts you mentioned. I noticed that some of my charts have been updating slowly with my fix, so if you're able to remove the data without a loop that'll probably give us a speed boost.

  10. phil-lauffenburger commented on Mar 31, 2016

    @phil-lauffenburger
    ContributorAuthor

    #92 should fix this.

  11. phil-lauffenburger commented on Apr 1, 2016

    @phil-lauffenburger
    ContributorAuthor

    fixed by #92

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions