chartjs-plugin-zoom
chartjs-plugin-zoom copied to clipboard
issue setting defaults with set()
I am using the defaults object like so:
import { ChartOptions, defaults } from "chart.js"
import { ZoomPluginOptions } from "chartjs-plugin-zoom/types/options.js"
const zoom: ZoomPluginOptions = {
limits: {
x: { min: "original", max: "original" },
y: { min: "original", max: "original" },
},
pan: {
enabled: true,
mode: "xy",
},
zoom: {
wheel: {
enabled: true,
},
pinch: {
enabled: true,
},
mode: "xy",
},
}
export const defaultOptions: ChartOptions = {
plugins: {
zoom,
legend: { rtl: true },
tooltip: { rtl: true },
},
maintainAspectRatio: false,
}
defaults.set(defaultOptions)
Interestingly some properties work and some don't.
After some testing I have concluded that the limits property works and the rest don't unless I explicitly set the in the chart itself.
logging defaults shows the properties being set correctly.
I am using chart js in react:
"chart.js": "^4.2.1"
"chartjs-plugin-zoom": "^2.0.0"
"react": "^18.2.0"
"react-chartjs-2": "^5.2.0"