Skip to content
Francois Vancoppenolle edited this page Nov 29, 2016 · 4 revisions

Previous Chapter          Previous Page          Next Page          Table of content

Return Value - how to test if the chart is drawn ?

In order to check if the chart is drawn, some variables are added to the context.

The firstPass variable is a first variable that can be used. This is a variable used internally by ChartNew.js. The variable firstPass is initialised with the value 9 when the chart is completely drawn.

A second set of variables have been defined. Those variables are grouped under the object pieces_drawn.

Variables available under pieces_drawn :

  • completed

  • all_drawn

  • total_data

  • total_non_missing_data

  • total_missing_data

  • total_drawn

  • points

  • rectangles

  • slices

Let's explain each of these variables.

completed & all_drawn

"completed" is a boolean variable; The value of "completed" is true when the chart function is completed. So during the animation, "completed" is false.

"all_drawn" is another boolean variable; The value of "all_drawn" is true when the chart function is completed and when a chart has been drawn in the canvas. When the size of the canvas is too small, the chart is not drawn. So when the variable "completed" has the value "true", the variable "all_drawn" can be used to determine if something has been drawn.

"completed" equal to "true" and "all_drawn" equal to "false" means that nothing has been drawn in the canvas because the canvas is too small.

"completed" equal to "true" and "all_drawn" equal to "true" means that the chart has been drawn in the canvas and that the animation is completed.

total_data, total_non_missing_data & total_missing_data

total_data is the number of data that are passed through the data variable; total_non_missing_data is the number of not missing data and total_missing_data is the number of missing data. total_data=total_non_missing_data+total_non_missing_data.

total_drawn, points, rectangles, slices

When the chart is completely drawn, points is equal to the number of points drawn in the chart, rectangles is equal to the number of bars drawn in the chart and slices, the number of slices drawn in the chart. total_drawn is the sum of those three variables.

Those variables are initialised at the end of the animation.

For an example, check Samples/testChartIsDrawn.html

http://fvancop.github.io/ChartNew.js/Samples/testChartIsDrawn.html

In this sample, if you reduce the size of the window browser, when sufficienltly small, the second chart is not drawn. At that time you will see that the variable "all_drawn" is set to false.

Previous Chapter          Previous Page          Next Page          Top of Page

Clone this wiki locally