question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a property in ChartOptions

See original GitHub issue

Hi!

Is it possible to add:

annotation?: object property in @types/chart.js inside ChartOptions interface?

Thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
itaispectorcommented, Oct 25, 2020

@etimberg Thank you for the lead, a further investigation and I’ve found the magic formula, I’ve added:

"@types/chart.js": "^2.9.15",
"@types/chartjs-plugin-annotation": "^0.5.1",

to devDependencies, instead of dependencies, and that did the trick.

Thanks again

0reactions
etimbergcommented, Oct 25, 2020

Ah, ok, you’re using v2.9.4 + the DefinitelyTyped definitions? My suggestion should work v3.0.0-beta.4 where we’ve shipped the types from our repo.

I’m not sure what the best way to augment those types would be. It looks like you’d want to augment ChartOptions instead of IChartOptions but I’m not sure what other changes might be required. https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/chart.js/index.d.ts#L285

The DefinitelyTyped definitions for the annotation plugin augment ChartOptions using https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/chartjs-plugin-annotation/index.d.ts#L11-L23

Read more comments on GitHub >

github_iconTop Results From Across the Web

Options | Chart.js
Options. # Option resolution. Options are resolved from top to bottom, using a context dependent route. # Chart level options.
Read more >
Chart.options returns "Property 'options' does not exist on type ...
Got it working. I do not know exactly what was causing this error however by treating the properties as array elements I was...
Read more >
Customizing Chart using Chart Options - CanvasJS.com
You can set data and all the attributes/properties of a chart using chart option object. You can pass the chart “options” as a...
Read more >
ChartJS Tutorials #4 - Chart Options - YouTube
In this video, we explore chart options in ChartJS. Subscribe for more free tutorials https://goo.gl/6ljoFc, Buy this series and get access ...
Read more >
Getting Started - vue-chartjs
pnpm add vue-chartjs chart.js # or yarn add vue-chartjs chart.js # or npm i ... <template> <Bar id="my-chart-id" :options="chartOptions" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found