I am trying to get a multi-line chart using StockChart. At first I tried without any special settings for color properties, but the lines that I had were orange. So I tried to make the graphics have different colors using the "colors" array in the StockPanel class. This works to set legendColor, but with an error when setting line colors.
Did I do something stupid? How can I initiate automatic color assignment?
Here is my code:
var stockPanel1 = new AmCharts.StockPanel();
stockPanel1.showCategoryAxis = true;
var graph1;
$.each($("#building-select").val(), function(index, value) {
graph1 = new AmCharts.StockGraph();
graph1.valueField = buildingNames[value];
graph1.legendColor = stockPanel1.colors[index];
graph1.lineColor = stockPanel1.colors[index];
graph1.title = buildingNames[value];
graph1.bulletBorderColor = "#FFFFFF";
graph1.bulletBorderAlpha = 1;
graph1.balloonText = buildingNames[value] + ":<b>$[[value]]</b>";
stockPanel1.addStockGraph(graph1);
});
This is what I get from the code. Note that the colors of the legends are set accordingly, but the colors of the lines are still orange.

Update:
I replaced the creation code with the JSON format by adding the configuration "useDataSetColors: false". It works for the start line.
stockGraphs: [{
id: "g1",
valueField: $("#type-select").val(),
comparable: true,
useDataSetColors: false,
lineColor: Colors[0],
compareField: $("#type-select").val(),
balloonText: "[[title]]:<b>$[[value]]</b>",
compareGraphBalloonText: "[[title]]:<b>$[[value]]</b>"
}]
:
$.each($(this).val(), function(index, value) {
chartDataSets[value].color = Colors[index];
if (index == 0) {
chart.mainDataSet = chartDataSets[value];
} else {
chartDataSets[value].compared = true;
}
});
, - , , , , .
, ? , amCharts, , StockCharts.