diff --git a/src/pages/workouts/components/LineWithLineChart.ts b/src/pages/workouts/components/LineWithLineChart.ts new file mode 100644 index 0000000..6b3fa3f --- /dev/null +++ b/src/pages/workouts/components/LineWithLineChart.ts @@ -0,0 +1,35 @@ +import { createTypedChart } from 'vue-chartjs' +import { LineController } from 'chart.js' + +class LineWithLineController extends LineController { + static override id = 'line-with-line' + + public override draw() { + super.draw() + + if (this.chart?.tooltip && this.chart.tooltip.opacity > 0) { + const ctx = this.chart.ctx + const x = this.chart.tooltip.x + console.log(this.chart.scales); + const topY = this.chart.scales.y.top + const bottomY = this.chart.scales.y.bottom + + // draw line + ctx.save() + ctx.beginPath() + ctx.moveTo(x, topY) + ctx.lineTo(x, bottomY) + ctx.lineWidth = 2 + ctx.strokeStyle = '#07C' + ctx.stroke() + ctx.restore() + } + } +} + +const LineWithLineChart = createTypedChart( + 'line-with-line' as 'line', + LineWithLineController +) + +export default LineWithLineChart