Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import { palette } from "@palette";
const MouseLinePlugin = {
id: "mouseline",
afterDatasetDraw: (chart: any) => {
if (chart.tooltip?._active?.length) {
const x = chart.tooltip._active[0].element.x;
const yAxis = chart.scales.y;
const ctx = chart.ctx;
const gradient = ctx.createLinearGradient(0, 0, 1, chart.chartArea.height);
gradient.addColorStop(0, palette.neutral.white);
gradient.addColorStop(0.4, palette.gray[300]);
gradient.addColorStop(1, palette.neutral.white);
ctx.save();
ctx.beginPath();
ctx.moveTo(x, yAxis.top);
ctx.lineTo(x, yAxis.bottom);
ctx.lineWidth = 1;
ctx.strokeStyle = gradient;
ctx.stroke();
ctx.restore();
}
}
};
export default MouseLinePlugin;
|