Home Forums Chart Support Why in “Candle Stick Chart With …” the surrounding color is red? Reply To: Why in “Candle Stick Chart With …” the surrounding color is red?

#44921

@ranc,

You can set the datapoint color based on the datapoint value, whether it’s rising or falling as shown in the code snippet below:

function changeBorderColor(chart){
  var dataSeries;
  for( var i = 0; i < chart.options.data.length; i++){
    dataSeries = chart.options.data[i];
    for(var j = 0; j < dataSeries.dataPoints.length; j++){
      dataSeries.dataPoints[j].color = (dataSeries.dataPoints[j].y[0] <= dataSeries.dataPoints[j].y[3]) ? (dataSeries.risingColor ? dataSeries.risingColor : dataSeries.color) : (dataSeries.fallingColor ? dataSeries.fallingColor : dataSeries.color);
    }
  }
}

Please check this JSFiddle for a working example.


Thangaraj Raman
Team CanvasJS