ChartJS - Different color per data point

后端 未结 6 1637
走了就别回头了
走了就别回头了 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:31

    If you initialize the myChart in this manner,

    var myChart = new Chart(ctx, {
      type: 'line',
      data: {
    

    you have to change line color by this code

      myChart.data.datasets[0].backgroundColor[0] ="#87CEFA";
    

    If you initialize the myChart in this manner,

    myBar = new Chart(ctx).Line(barChartData, {
    

    you have to change line color by this code

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

提交回复
热议问题