Piechart: color based on a function

Hi there,

I simply want to re-run an example of chart coloring shown in
[url]Chart Coloring DHTMLX Docs.
But I always get an error where codre reads “index++”, telling me that an object is expected.
Is there any qualifier or declaration needed?

<script> window.onload = function(){ var barChart = new dhtmlXChart({ view: "pie", container: "chartDiv", value: "#sales#", color: function(obj){ index++; if (index % 2) { return "#ff9900"; } else { return "#66cc00"; } } }); barChart.parse(dataset, "json"); } </script> <div id="chartDiv" style="width:600px;height:450px;margin:20px;border:1px solid #A4BED4;"> </div>

thanks a lot!

Hi
Sorry, it was missed a line in doc. We have already fix it.
In your sample you need to add the next line:
window.onload = function(){
var index = 0;
var barChart = new dhtmlXChart({

Thanks Darya!
works perfectly well now!

You are welcome!