The this.canvas variable is null in the file RGraph.pie.js which results in a runtime error

« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by Rich Ward on 12th December 2013
Hi -

I'm an RGraph newbie and am trying to figure out a bug in code written by someone else.

If RGraph.Pie is called:
var pie = new RGraph.Pie(pContainerName, pDataPoints);

- with no data points, the following exception is raised when this statement is executed:
this.context = this.canvas.getContext("2d");

"Microsoft JScript runtime error: Unable to get value of the property 'getContext': object is null or undefined"

I can resolve this bit - but then if RGraph.Pie is called subsequently with valid data points the same exception is raised on the same statement.

Is there a way to reset?

Many thanks,

- Rich

Posted by RGraph support on 12th December 2013
Hi there,

With a Pie chart you need at least one non-null, non-zero value - like this:

var data = [1];

So if you have no data - don't try and show the chart - not that there's any point with a pie chart. Also, ensure you're using the ExCanvas from the latest stable RGraph archive.

Oh and there is an RGraph.Reset() function - but this is unlikely to have an effect if you're using ExCanvas.


Add a reply

« Back to message list