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.

ChartOptions and Typescript

See original GitHub issue

Right. Hmm? Screen Shot 2021-10-29 at 9 35 02 AM

What type should I import and use to create my options object to make the Typescript woes go away?

I know this sounds more like a question than bug/feature request, but there is very little help in the docs about how to use options in typescript.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
dangreencommented, Oct 31, 2021

@usahai Hi. Please use as const with align props:

xAlign: 'center' as const,
yAlign: 'bottom' as const,
bodyAlign: 'center' as const,
1reaction
dangreencommented, Oct 29, 2021

@peterbe Hi. You are using options for chart.js@v2, while using chart.js@v3. Options for v3 should look like this:

const options = {
  scales: {
    y: {
      beginAtZero: true,
    },
  },
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to declare plugin options, using typescript and react ...
const pieOptions: chartjs.ChartOptions = { ... } and/or tell TypeScript that that bold weight is a constant, so it can be assigned to...
Read more >
How to use react-chartjs-2 with TypeScript?
import type { ChartData, ChartOptions } from 'chart.js'; Copy ...and then used with options and data props: interface LineProps {
Read more >
TypeScript typings · Issue #7655 · chartjs/Chart.js - GitHub
I.e. core/Chart.options.legend using plugins/ChartLegendOptions , which in turn imports types like ChartColor from core. Use Declaration merging ...
Read more >
Options | Chart.js
Options. # Option resolution. Options are resolved from top to bottom, using a context dependent route. # Chart level options.
Read more >
Highcharts TypeScript Declarations (beta)
TypeScript -compatible editors can give you tooltips and suggestions for Highcharts as you type. The TypeScript compiler watches and points out ...
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