Errors on hideSeries

Hello All,

I initialized the chart with no value, added series one by one, and hide all of them except the first one. I could see the combined result, but error occurred while hiding the series as follows.

Uncaught TypeError: Cannot call method 'hideCanvas' of undefined dhtmlx.js:2076 dhtmlXChart.hideSeries dhtmlx.js:2076 SalesStatsHandler.updateChart SalesStats.js:465 $.ajax.success SalesStats.js:336 c jquery-1.9.1.min.js:3 p.fireWith jquery-1.9.1.min.js:3 k jquery-1.9.1.min.js:5 r

and the code for adding and hiding is as follows:

var seriesIndexAt = {}; var seriesIndex = 0; for (var i in SalesStatsHandler.columnInfo) { var series = SalesStatsHandler.columnInfo[i]; if (series.seriesColor) { seriesIndexAt[series.id] = seriesIndex; SalesStatsHandler.chart.addSeries({ value : "#" + series.id + "#", color : series.color, }); seriesIndex--; } } _log(seriesIndexAt); _log(seriesIndex); SalesStatsHandler.chart.parse(SalesStatsHandler.datasetForChart, "json"); for (i = -1 ; i > seriesIndex ; i--) { _log(i); SalesStatsHandler.chart.hideSeries(i); }

And the color doesn’t seem to work either. dhtmlXChart shows all the colors as orange(FF9900).

Anyone has same issue? Any input will be appreciated.

it seems like hideSeries() needs to be called after the parse() ? I changed my code and got another error.

[code]SalesStatsHandler.chart.seriesIndexAt = {};
var seriesIndex = 0;
for (var i in SalesStatsHandler.columnInfo) {
var series = SalesStatsHandler.columnInfo[i];

if (series.seriesColor) 
{
	SalesStatsHandler.chart.seriesIndexAt[series.id] = seriesIndex;
	SalesStatsHandler.chart.addSeries({
		view : 'line',
		value : "#" + series.id + "#",
		tooltip : "#time# <br/> " +
				g_string['column_sales_stats_' + series.id] + "#" + series.id + "#",
		item : {
			borderColor : series.seriesColor,
			borderWidth: 1,
			color : series.seriesColor,
			radius : 1,
		},
		line : {
			color : series.seriesColor,
			width : 3
		},
	});
	seriesIndex--;
}

}

_log(SalesStatsHandler.chart.seriesIndexAt);

for (var i in SalesStatsHandler.chart.seriesIndexAt) {
var seriesIndex = SalesStatsHandler.chart.seriesIndexAt[i];
_log(seriesIndex);
SalesStatsHandler.chart.hideSeries(seriesIndex);
}

SalesStatsHandler.chart.parse(SalesStatsHandler.datasetForChart, “json”);[/code]

Error : Uncaught TypeError: Cannot read property ‘0’ of undefined

If I put hideSeries() after parse(), it says "TypeError: Cannot read property ‘values’ of undefined "

Hello,

The problem is somewhere in your code. You may add the following snippet in the dhtmlxChart/samples/06_bar_chart/06_series.html sample:


barChart1.parse(multiple_dataset,“json”);

for(var i = 0; i< 3; i++){
barChart1.hideSeries(i);
}

All series are hidden.

Thanks!

You probably should change the API document then. The document says the series indexes are negative numbers starting with 0.

http://docs.dhtmlx.com/doku.php?id=dhtmlxchart:api_method_dhtmlxchart_hideseries

Apologize for the mistake. We’ll necessary correct the method description.