4👍
You can add a plugin to your chart which can draw anything you’d like on the chart, for example a green line. You can read about plugins in the documentation for ChartJS. Since you want the green line to appear above the vertical bars, you should use the afterDraw
method.
Once you’ve set the plugin up, the steps to accomplish this would be:
- Calculate the mean of all the bars in your chart (sum them up and divide by the number of bars)
- From the previous calculation: Decide the Y position of the line and based on that, draw the green line on the canvas.
Check out CanvasRenderingContext2D if you are new to how the browser canvas works.
Source:stackexchange.com