Notice the two if lines with one of them commented out.
When run like this the DoughnutChart is rendered as expected.
Now comment the "if (x > 0) {" line and uncomment the other if line.
Suddenly the chart no longer renders with an error of "TypeError: chart.segments[segmentIndex] is undefined".
What is really strange though is that the output of the console.log() line is "value = 1" so the if condition evaluates to true and the same code as before is executed. I also added some debug code that outputs the content of "piechart" just before the return statement and in both cases it is the same (a list with one element).
I have no clue what is going on here. Since in both cases the exact same input data is provided for "piedata" the result should be the same but it isn't.
Any ideas what might be going on here?
Something really strange is happening when I try to build data dynamically for a DoughnutChart. Consider the following render function:
Notice the two if lines with one of them commented out. When run like this the DoughnutChart is rendered as expected. Now comment the "if (x > 0) {" line and uncomment the other if line. Suddenly the chart no longer renders with an error of "TypeError: chart.segments[segmentIndex] is undefined".
What is really strange though is that the output of the console.log() line is "value = 1" so the if condition evaluates to true and the same code as before is executed. I also added some debug code that outputs the content of "piechart" just before the return statement and in both cases it is the same (a list with one element). I have no clue what is going on here. Since in both cases the exact same input data is provided for "piedata" the result should be the same but it isn't. Any ideas what might be going on here?