From 585a1e6d01e1e1563a7a87ac9a67e69f691a0ee1 Mon Sep 17 00:00:00 2001 From: artem Date: Mon, 30 Sep 2024 17:50:23 +0300 Subject: [PATCH] fix get status --- .../workouts/components/LineWithLineChart.ts | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/pages/workouts/components/LineWithLineChart.ts 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