Home forums Using CanvasJS Pie chart color not changing Reply To: Pie chart color not changing


Bivek Singh


You’re setting the color of entire dataSeries. That’s why whole pie chart is shown in single color.

color: scopes.chart_color_value[i],

Remove above line from scopes.dataset.push() and add it inside scopes.inner_chart_data.push();

for (var j = 0; j < data[0].data.length; j++) {
	scopes.inner_chart_data.push({ label: data[0].data[j]._attr.label._value, color: scopes.chart_color_value[j],y:  data[0].data[j]._attr.value._value });
  type: "pie",
  markerType: "circle",
  markerSize: scopes.markersize,
  showInLegend: false,
  name: scopes.legend_text,
  dataPoints: scopes.inner_chart_data

For you second query, doughnut chart is not multi series chart like line chart. That’s why you don’t get 2 charts.