Skip to content

Commit

Permalink
Update Chart.js and simplify types
Browse files Browse the repository at this point in the history
Now that chartjs/Chart.js#12012 has been fixed, these `as any` casts are no longer needed.
  • Loading branch information
joshkel committed Feb 19, 2025
1 parent 137d924 commit 57e1da0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@typescript-eslint/parser": "^5.62.0",
"babel-loader": "^8.3.0",
"c8": "^10.1.2",
"chart.js": "^4.3.2",
"chart.js": "^4.4.8",
"chartjs-adapter-date-fns": "^3.0.0",
"chartjs-test-utils": "^0.5.0",
"concurrently": "^9.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/hammer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function handlePinch(chart: Chart, state: State, e: HammerInput) {

function startPinch(chart: Chart, state: State, e: HammerInput) {
if (state.options.zoom?.pinch?.enabled) {
const point = getRelativePosition(e.srcEvent, chart as any) // TODO: would expect Chart type to be valid for getRelativePosition
const point = getRelativePosition(e.srcEvent, chart)
if (state.options.zoom?.onZoomStart?.({ chart, event: e.srcEvent, point }) === false) {
state.scale = null
state.options.zoom?.onZoomRejected?.({ chart, event: e.srcEvent })
Expand Down
4 changes: 2 additions & 2 deletions src/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function getPointPosition(event: MouseEvent, chart: Chart) {
y: event.clientY - canvasArea.top,
}
}
return getRelativePosition(event, chart as any) // TODO: would expect Chart type to be valid for getRelativePosition
return getRelativePosition(event, chart)
}

function zoomStart(chart: Chart, event: MouseEvent, zoomOptions: ZoomOptions): boolean | void {
Expand All @@ -85,7 +85,7 @@ function zoomStart(chart: Chart, event: MouseEvent, zoomOptions: ZoomOptions): b

export function mouseDown(chart: Chart, event: MouseEvent): void {
if (chart.legend) {
const point = getRelativePosition(event, chart as any) // TODO: would expect Chart type to be valid for getRelativePosition
const point = getRelativePosition(event, chart)
if (_isPointInArea(point, chart.legend)) {
return
}
Expand Down

0 comments on commit 57e1da0

Please sign in to comment.