Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compile errors when using multiple plugins #877

Merged
merged 1 commit into from
May 9, 2023

Conversation

ghost
Copy link

@ghost ghost commented Apr 20, 2023

Closes #854

@stockiNail stockiNail added the bug label Apr 20, 2023
@stockiNail stockiNail added this to the 3.0.0 milestone Apr 20, 2023
@stockiNail
Copy link
Collaborator

@kurkle go to version 3 or 2.2.2?

@rfrancois
Copy link

rfrancois commented May 11, 2023

Hi @stockiNail ,

I tried version 3.0.0 and I have a new error :
Object literal may only specify known properties, and 'annotation' does not exist in type '_DeepPartialObject<PluginOptionsByType<keyof ChartTypeRegistry, keyof ChartTypeRegistry>>'.

With this code :

import { Chart } from "chart.js/auto";
import * as moment from 'moment';
import zoomPlugin from 'chartjs-plugin-zoom';
import annotationPlugin from 'chartjs-plugin-annotation';
import 'chartjs-adapter-moment';

Chart.register(annotationPlugin)

...

new Chart(chartRef.nativeElement, {
  type: 'bar',
  plugins: [zoomPlugin],
  data: {
	datasets: datasets
  },
  options: {
	responsive: true,
	maintainAspectRatio: false,
	plugins: {
	  zoom: {
		zoom: {
		  drag: {
			enabled: true
		  },
		  mode: 'x',
		},
	  },
	  annotation: { } // If I comment this line, error disappears. If I put content inside this object to draw my annotations, still have the error
	}
  },
})

My versions :
"chart.js": "^4.3.0",
"chartjs-adapter-moment": "^1.0.1",
"chartjs-plugin-annotation": "^3.0.0",
"chartjs-plugin-zoom": "^2.0.1",

If I remove zoom plugin, it works though. But I would like both plugins.
Any suggestion ?

@stockiNail
Copy link
Collaborator

@rfrancois created an issue: #886
I had a quick look and I was able to reproduce it. Also here, it doesn't depend on annotation plugin but unfortunately there is, in my opinion, something not well defined (at types level) in Chart.js.
I say that because in my test case, I have the issue on zoom instead of annotation (depends on import order).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error TS2567 when using this plugin in version 2.1.2
2 participants