ChartJS - Different color per data point

后端 未结 6 1634
走了就别回头了
走了就别回头了 2020-11-27 18:43

Is there a way to set a different color to a datapoint in a Line Chart if its above a certain value?

I found this example for dxChart - https://stackoverflow.com/a/2

6条回答
  •  失恋的感觉
    2020-11-27 19:47

    Just adding what worked for me in the new 2.0 version.

    Instead of:

    myLineChart.datasets[0].points[4].fillColor =  "lightgreen";
    

    I had to use:

    myChart.config.data.datasets[0].backgroundColor[4] = "lightgreen";
    

    Not sure if that's because of a change in 2.0 or because I'm using a bar chart and not a line chart.

提交回复
热议问题