I am using a plugin at the moment.
const VerticalLinePlugin = {
afterDraw (chart, args, options) {
const ctx = chart.ctx
ctx.save()
const yAxis = chart.scales['y-axis-0']
const xAxis = chart.scales['x-axis-0']
const x = xAxis.getPixelForValue('2022-10-26')
ctx.beginPath()
ctx.moveTo(yAxis.top, x)
ctx.lineTo(yAxis.bottom, x)
ctx.lineWidth = 2
ctx.strokeStyle = "green"
ctx.stroke()
ctx.restore()
}
}
In my x-axis I have dates, what I would like to do is have a vertical line from bottom to top across the graph where the date "2022-10-26" is displayed.
Above code does draw a line, but it is a horizontal line and not a vertical line. It also is not exactly on point on the date.
Op donderdag 3 november 2022 om 18:44:28 UTC+1 schreef Nick: