Chart conditional template

Hello,

I want to use a conditional template to show a variable number of labels (I will present for instance only 12 labels, so if there are 12 items I will show a label for each item, is there are 120 only on label for each 10 items) in the template using a function like:

container: “chartContainer”,
tooltip: {template: “#Date#”},
yAxis: {title: “Cost”},
xAxis: {title: “Date”,
template:function(obj, common, data){
if (obj.id%12 == 0 || obj.id == 1) return obj.Date;
return “”;
}},
In order to do so I need to know the number of items in the data collection.
Is there any property of data that tells me how many items I have?

Thanks in advance.

Javier

Hi,

you may use dataCount() method to get number of items in a chart:

var chart = new dhtmlXChart({

template:function(obj, common, data){
var count = chart.dataCount();
if (obj.id%12 == 0 || obj.id == 1) return obj.Date;
return “”;
}
})

Thank you very much one more time again, something like this will do it then:

       yAxis: {title: "Count"},
        xAxis: {title: "Date", 
        template:function(obj, common, data){
    		var count = (barChart.dataCount()/10).toFixed();
        	if (obj.id%count == 0 || obj.id == 1) return obj.Date;
        	return "";
        	}},

Best regards.

Javier