I'm struggling with setting chartjs-plugin-crosshair to work with my chart (chartjs).
Project dependencies are:
- vue-chartjs: 4.1.0
- chartjs-plugin-crosshair: 1.2.0
- chart.js: 3.7.1
i'm getting errors:
first: Uncaught TypeError: Cannot read properties of undefined (reading 'dragStarted')
then (on mouse move over chart): Uncaught TypeError: Cannot read properties of undefined (reading 'length')
My component:
<template>
<Line :chart-data="chartData" :plugins="[CrosshairPlugin]" :chart-options="chartOptions" ref="myChart" />
</template
<script setup>
import { Line } from 'vue-chartjs'
import { Chart as ChartJS, Title, Tooltip, Legend, PointElement, LineElement, CategoryScale, LinearScale, TimeSeriesScale } from 'chart.js'
import {CrosshairPlugin,Interpolate} from 'chartjs-plugin-crosshair';
ChartJS.register(Title, Tooltip, Legend, PointElement, LineElement, CategoryScale, LinearScale, TimeSeriesScale)
const myChart = ref();
const chartData ={
labels: [1,2,3,4],
datasets: [{label:'test', data:[51,52,53,54],borderWidth:1, borderColor:'#f0f'}]
}
const chartOptions = {
interaction: {
mode: 'nearest'
},
scales: {
xAxes: {
stacked:true,
grid: {
color:"rgba(80,201,209,.3)",
borderColor:"rgba(80,201,209,1)"
},
title: {
display:true,
text: 'value'
},
ticks: {
color:"rgba(80,201,209,1)"
source: 'labels',
},
},
yAxes: {
grid: {
color:"rgba(80,201,209,.3)",
borderColor:"rgba(80,201,209,1)"
},
title: {
display: false,
},
ticks: {
color:rgba(80,201,209,1),
},
},
},
plugins: {
crosshair:
{
sync: {
enabled: false
},
zoom: {
enabled: false
},
snap: {
enabled: true
}
}
}
}
can anyone help?