FVANCOP / ChartNew.js

MIT License
420 stars 143 forks source link

Typeerror in stackedbars #450

Closed gavinspearhead closed 7 years ago

gavinspearhead commented 7 years ago

I get this error : TypeError: statData[i][0] is undefined chartnew.js:3562:9 wwith the latest version from github.

FVANCOP commented 7 years ago

Hi,

Don't really understand how it could happen; Can you send your data and options to my email address ?

Thanks, François

markosko commented 7 years ago

Until variable i is out of range of statData variable

gavinspearhead commented 7 years ago

Below are the dataset I use - I ran them through json.stringify to make them printable. They all give the error in the latest version but work fine in a version I have downloaded around 1 november 2015. (there is no version or date in the file itself as far as i can see.

And then call this: my_chart = new Chart(ctx).StackedBar(plot_data, plot_options);

{"labels":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"datasets":[{"data":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0},"title":"Gav","fillColor":"rgba(140,61,0,0.6)","strokeColor":"rgba(140,61,0,1)"},{"data":[3.5,0,0,0,0,3.5,0,0,0,0,0,0],"title":"harm","fillColor":"rgba(180,150,60,0.6)","strokeColor":"rgba(180,150,60,1)"},{"data":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0},"title":"stnh","fillColor":"rgba(200,200,0,0.6)","strokeColor":"rgba(200,200,0,1)"},{"data":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0},"title":"test12","fillColor":"rgba(140,210,220,0.6)","strokeColor":"rgba(140,210,220,1)"},{"data":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0},"title":"tester","fillColor":"rgba(0,200,0,0.6)","strokeColor":"rgba(0,200,0,1)"},{"data":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0},"title":"tnhtnh","fillColor":"rgba(0,200,100,0.6)","strokeColor":"rgba(0,200,100,1)"}]}

{"legend":true,"inGraphDataShow":false,"inGraphDataVAlign":"above","graphTitleFontSize":14,"graphTitle":"Uploads (Size) - 2016","legendPosY":4,"legendPosX":2,"xAxisFontSize":11,"yAxisFontSize":11,"annotateLabel":"<%=v1%> <%=v2%>: <%=v3%> (<%=v6%>%)","annotateDisplay":true,"graphMin":0,"yAxisLabel":"MB","yAxisMinimumInterval":"none","graphTitleFontColor":"rgb(255, 255, 255)","legendFontColor":"rgb(255, 255, 255)","scaleFontColor":"rgb(255, 255, 255)","yAxisFontColor":"rgb(255, 255, 255)","scaleXGridLinesStep":9999,"maxBarWidth":191}

{"labels":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"datasets":[{"data":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0},"title":"Gav","fillColor":"rgba(140,61,0,0.6)","strokeColor":"rgba(140,61,0,1)"},{"data":[1,0,0,0,0,1,0,0,0,0,0,0],"title":"harm","fillColor":"rgba(180,150,60,0.6)","strokeColor":"rgba(180,150,60,1)"},{"data":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0},"title":"stnh","fillColor":"rgba(200,200,0,0.6)","strokeColor":"rgba(200,200,0,1)"},{"data":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0},"title":"test12","fillColor":"rgba(140,210,220,0.6)","strokeColor":"rgba(140,210,220,1)"},{"data":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0},"title":"tester","fillColor":"rgba(0,200,0,0.6)","strokeColor":"rgba(0,200,0,1)"},{"data":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0},"title":"tnhtnh","fillColor":"rgba(0,200,100,0.6)","strokeColor":"rgba(0,200,100,1)"}]} {

{"legend":true,"inGraphDataShow":false,"inGraphDataVAlign":"above","graphTitleFontSize":14,"graphTitle":"Uploads (Number) - 2016","legendPosY":4,"legendPosX":2,"xAxisFontSize":11,"yAxisFontSize":11,"annotateLabel":"<%=v1%> <%=v2%>: <%=v3%> (<%=v6%>%)","annotateDisplay":true,"graphMin":0,"yAxisLabel":"","yAxisMinimumInterval":1,"graphTitleFontColor":"rgb(255, 255, 255)","legendFontColor":"rgb(255, 255, 255)","scaleFontColor":"rgb(255, 255, 255)","yAxisFontColor":"rgb(255, 255, 255)","scaleXGridLinesStep":9999,"maxBarWidth":191}

{"labels":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"datasets":[{"data":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0},"title":"Gav","fillColor":"rgba(140,61,0,0.6)","strokeColor":"rgba(140,61,0,1)"},{"data":[1,0,0,0,0,1,0,0,0,0,0,0],"title":"harm","fillColor":"rgba(180,150,60,0.6)","strokeColor":"rgba(180,150,60,1)"},{"data":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0},"title":"stnh","fillColor":"rgba(200,200,0,0.6)","strokeColor":"rgba(200,200,0,1)"},{"data":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0},"title":"test12","fillColor":"rgba(140,210,220,0.6)","strokeColor":"rgba(140,210,220,1)"},{"data":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0},"title":"tester","fillColor":"rgba(0,200,0,0.6)","strokeColor":"rgba(0,200,0,1)"},{"data":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0},"title":"tnhtnh","fillColor":"rgba(0,200,100,0.6)","strokeColor":"rgba(0,200,100,1)"}]} {

{"legend":true,"inGraphDataShow":false,"inGraphDataVAlign":"above","graphTitleFontSize":14,"graphTitle":"Downloaded NZB files (Number) - 2016","legendPosY":4,"legendPosX":2,"xAxisFontSize":11,"yAxisFontSize":11,"annotateLabel":"<%=v1%> <%=v2%>: <%=v3%> (<%=v6%>%)","annotateDisplay":true,"graphMin":0,"yAxisLabel":"","yAxisMinimumInterval":1,"graphTitleFontColor":"rgb(255, 255, 255)","legendFontColor":"rgb(255, 255, 255)","scaleFontColor":"rgb(255, 255, 255)","yAxisFontColor":"rgb(255, 255, 255)","scaleXGridLinesStep":9999,"maxBarWidth":191}

{"labels":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"datasets":[{"data":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0},"title":"Gav","fillColor":"rgba(140,61,0,0.6)","strokeColor":"rgba(140,61,0,1)"},{"data":[4,1,0,0,0,11,7,0,0,0,0,0],"title":"harm","fillColor":"rgba(180,150,60,0.6)","strokeColor":"rgba(180,150,60,1)"},{"data":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0},"title":"stnh","fillColor":"rgba(200,200,0,0.6)","strokeColor":"rgba(200,200,0,1)"},{"data":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0},"title":"test12","fillColor":"rgba(140,210,220,0.6)","strokeColor":"rgba(140,210,220,1)"},{"data":[1,0,0,0,0,0,0,0,0,0,0,0],"title":"tester","fillColor":"rgba(0,200,0,0.6)","strokeColor":"rgba(0,200,0,1)"},{"data":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0},"title":"tnhtnh","fillColor":"rgba(0,200,100,0.6)","strokeColor":"rgba(0,200,100,1)"}]}

{"legend":true,"inGraphDataShow":false,"inGraphDataVAlign":"above","graphTitleFontSize":14,"graphTitle":"Imported NZB files (Number) - 2016","legendPosY":4,"legendPosX":2,"xAxisFontSize":11,"yAxisFontSize":11,"annotateLabel":"<%=v1%> <%=v2%>: <%=v3%> (<%=v6%>%)","annotateDisplay":true,"graphMin":0,"yAxisLabel":"","yAxisMinimumInterval":1,"graphTitleFontColor":"rgb(255, 255, 255)","legendFontColor":"rgb(255, 255, 255)","scaleFontColor":"rgb(255, 255, 255)","yAxisFontColor":"rgb(255, 255, 255)","scaleXGridLinesStep":9999,"maxBarWidth":191}

FVANCOP commented 7 years ago

Hi,

Problem has been found : "data" has to be a table of values and not a table of objects.

This is not correct : data :{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0} Must be : data : [0,0,0,0,0,0,0,0,0,0,0,0].

This error did not let to a problem upto the version pubilished the 2 September 2015. But since then, this error is no more allowed.

Even in version published upto the 2 September, such data were associated to missing values. In your case, it was always a null value which is similar to a missing value for stacked charts. But if you try to associate non null values (for instance : : data :{"1":1,"2":2,"3":3,"4":4,"5":5,"6":6,"7":7,"8":8,"9":9,"10":10,"11":11,"12":12}), you will see that those values are not displayed in the chart.

Regards François

gavinspearhead commented 7 years ago

Thanx again! A bit of a puzzle but that seems to fix it indeed.