You must be logged in to post your query.
Home › Forums › Chart Support › Why in “Candle Stick Chart With …” the surrounding color is red?
Tagged: candles, colors
I want to have a green bar that is totally green, and a red bar that is totally red. Can I?
@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
You must be logged in to reply to this topic. Login/Register