react-c3js icon indicating copy to clipboard operation
react-c3js copied to clipboard

Uncaught TypeError: Cannot read property 'data_types' of null

Open bvenkatr opened this issue 7 years ago • 18 comments

Hi, I am getting this error whenever the pie chart is re-rendered by react. This happens only sometimes, not every time react re-renders. screen shot 2017-04-10 at 10 36 20 pm

bvenkatr avatar Apr 10 '17 17:04 bvenkatr

Me too. If I navigate away within the app, and then come back I get the error. If I reload the page using the browser's button it works. It is only the pie, and the donut that doesn't work.

handoff avatar May 15 '17 17:05 handoff

We're seeing the same issue, although only occasionally. Any updates / ideas what is causing this error?

forum-is avatar Oct 02 '17 11:10 forum-is

Same issue

AlbertoCalvo avatar Oct 17 '17 21:10 AlbertoCalvo

This can be seen when using c3js in an Angular 2+ application as well for donut/pie charts. I'm pretty certain it's an error in c3js similar to [1].

When you destroy a chart it sets a number of fields to null. However there are timer actions in the background trying to use these fields to render things. In certain conditions, the destroy will set the fields to null before the timer accesses theses fields and things will break spectacularly.

The related fixes in [1] are basically adding null checks to various places. It looks like some more are needed for the donut/pie charts.

[1] https://github.com/c3js/c3/issues/1205

jiekang avatar Jan 05 '18 20:01 jiekang

EDIT: I thought I was on the C3 issues page and realize this is a side project built on C3. I'm using straight C3 and having these same issues, not sure if they are related but I'll leave this here and remove it if asked.

Im getting similar after calling destroy on a "timeseries" chart:

TypeError: $$.data is null[Learn More] c3.js:7890:5 c3_chart_internal_fn.getShapeIndices http://localhost:3000/c3.js:7890:5 c3_chart_internal_fn.redraw http://localhost:3000/c3.js:1490:23 c3_chart_fn.unload/< http://localhost:3000/c3.js:4006:9 c3_chart_internal_fn.endall/< http://localhost:3000/c3.js:2031:13 event http://localhost:3000/d3.js:504:40 tick http://localhost:3000/d3.js:8959:29 start/< http://localhost:3000/d3.js:8936:24 d3_timer_mark http://localhost:3000/d3.js:2166:29 d3_timer_step http://localhost:3000/d3.js:2147:15

By the time I get this error I have destroyed 3 charts and flushed all their data, removed their html containers and destroyed the objects that created them. I have a charts class that handles all the chart creation and manipulation for another class.

In addition, if you have any other charts active after invoking a .destroy() on a chart and attempt to update other charts (using .flow() at least) if will create a massive memory leak that will trap all available memory in a very short period of time.

theonlyfox avatar Jan 21 '18 08:01 theonlyfox

Still throws same error, and crush chart. Adding in my package.json "c3": "^0.6.7" helps to keep chart working but still output error in console

artjoms-faltins avatar Sep 13 '18 06:09 artjoms-faltins

I am facing the same issue with pie charts

ayadavkrt avatar Nov 26 '18 11:11 ayadavkrt

Same issue

damianb86 avatar Dec 03 '18 14:12 damianb86

Hey, same issue here ! Is anyone found a workaround ?

Thebarda avatar Dec 04 '18 09:12 Thebarda

Same issue

idandagan1 avatar Dec 16 '18 11:12 idandagan1

me too, any workarounds?

leslie-alldridge avatar Jan 14 '19 06:01 leslie-alldridge

Same issue , any workarounds?

akhilesh-94 avatar Jan 24 '19 06:01 akhilesh-94

I had a similar problem and I think I finally figured it out. The <C3Chart> component takes an unloadBeforeLoad prop, however ALL charts on the page need unloadBeforeLoad={true}. If even one chart is missing the unloadBeforeLoad prop, I get weird chart breakages.

bkanber avatar Feb 22 '19 19:02 bkanber

@bkanber I'm glad it's working for you. I've added the prop to all my charts but unfortunately they still display blank and output

Uncaught TypeError: Cannot read property 'data_types' of null
    at k.E.isPieType (c3.js:9223)
    at k.E.isArcType (c3.js:9234)
    at k.E.getArc (c3.js:4473)
    at c3.js:4816
    at SVGPathElement.<anonymous> (d3.js:8775)
    at Object.h [as c] (d3.js:8956)
    at Mt (d3.js:2166)
    at At (d3.js:2147)

If I refresh the page it's all good. I'm using React + Redux.

leslie-alldridge avatar Feb 22 '19 21:02 leslie-alldridge

I also have unload: true on all of my data objects. Maybe that's a factor as well. ie, const data = {unload: true, json: { ...}, groups: ....};

On Fri, Feb 22, 2019, 4:02 PM Leslie Alldridge [email protected] wrote:

@bkanber https://github.com/bkanber I'm glad it's working for you. I've added the prop to all my charts but unfortunately they still display blank and output

Uncaught TypeError: Cannot read property 'data_types' of null at k.E.isPieType (c3.js:9223) at k.E.isArcType (c3.js:9234) at k.E.getArc (c3.js:4473) at c3.js:4816 at SVGPathElement. (d3.js:8775) at Object.h [as c] (d3.js:8956) at Mt (d3.js:2166) at At (d3.js:2147)

If I refresh the page it's all good. I'm using React + Redux.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/bcbcarl/react-c3js/issues/22#issuecomment-466546761, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEdNn4MATnDdqQBnul9vodg0s0PqVz5ks5vQFr1gaJpZM4M5ESQ .

bkanber avatar Feb 25 '19 12:02 bkanber

Thanks for the update @bkanber I've added that to my data object for every chart but continue to get the same error. Files attached a c

leslie-alldridge avatar Feb 25 '19 20:02 leslie-alldridge

I can confirm that I am still seeing this error with a gauge chart even with adding unloadBeforeLoad and unload on the data objects

mike-stumpf avatar Mar 15 '19 20:03 mike-stumpf

+1 for this issue. If chart.destroy() is called inside ngOnDestroy(), the error appears for doughnut and bar charts.

Jiish avatar Apr 11 '19 13:04 Jiish