Chartjs-How to change points/line based on value?

0👍

I would highly recommend this fork of the Bands plugin (because the Bands plugin only allows one band per chart, the fork allows two).

Easy to handle and much easier than writing something yourself because there’s no chartjs-build-in-function for that. The plugin is exactly for your use case.

https://jsbin.com/yikayukewu/edit?html,js,output

In the JSBin you can see both solutions for the plugin and its fork. Because I’m unable or it’s impossible to import the fork you can see the code but without the import it’s not working. The plugin code is working if you adjust the comments.

Here is the code for the fork:

options: {
  bands: {
    yValueMin: 35,
    yValueMax: 55,
    belowMinThresholdColour: [
      'rgb(255, 100, 100)'
    ],
    aboveMaxThresholdColour: [
      'rgb(255, 100, 100)'
    ]
  }
}

Leave a comment