Search code examples
javascripthtmldojojavascript-frameworkdojox.charting

Dojo 1.8 chart programmatic tutorial error


I have been going through some of the Dojo 1.8 tutorials, which are great, but have encountered a bug in the basic charting tutorial. The declarative example works fine, but the programmatic example has an error when it tries to render the chart.

Charting tutorial: http://dojotoolkit.org/documentation/tutorials/1.8/charting/

Working declarative example: http://dojotoolkit.org/documentation/tutorials/1.8/charting/demo/basic-declarative.php

Errored programmatic example: http://dojotoolkit.org/documentation/tutorials/1.8/charting/demo/basic-programmatic.php

From my investigations it looks like the problem is with the code trying to use the 'IN' operand on a string, at which point it falls over.

The error in firebug looks like this: "TypeError: invalid 'in' operand t"

You'll need to download the non minified version of dojox/gfx/path.js and look at line 191 where you'll see this snippet of code:

if(t instanceof Array){
    this._collectArgs(_12,t);
  }else{
    if("x" in t&&"y" in t){
      _12.push(t.x,t.y);
    }
  }

I believe that the error is where the logic falls through into the "if("x" in t&&"y" in t)" line.

Any ideas?


Solution

  • it seems its an error in the tutorial, the 'labelOffset' is supposed to take a Number, but they are giving it a string, thus it fails, take the quotes away and it works, see this forum post. Charting tutorial in 1.7 and 1.8