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.

plugins.legend.align are incompatible types

See original GitHub issue

Expected Behavior

I shouldn’t be seeing any errors

Current Behavior

TypeScript is complaining that the type of align should be ‘start’, ‘center’ or ‘end’ and not a string. In the documentation, the type of align is string

Possible Solution

export interface LegendOptions<TType extends ChartType> {
  ....
  /**
   * Alignment of the legend.
   * @default 'center'
   */
  align: 'start' | 'center' | 'end';

}

If I change align to a type of string. The TypeScript error goes away but I shouldn’t be doing this from my end.

Steps to Reproduce

Make sure you are using TypeScript in your project, use any of the chart, and try to align the label.

Environment

  • Chart.js version: 3.6.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
LeeLenaleeecommented, Nov 2, 2021

It seems to be a react-chartjs-2 issue since if you just use barebone chart.js in typescript it doesnt throw an error unless you put a wrong value in there.

React TS: https://codesandbox.io/s/goofy-curie-eyxrr?file=/src/App.tsx Angular TS: https://codesandbox.io/s/strange-almeida-f5hbz?file=/src/app/app.component.ts

1reaction
phoenixbeats01commented, Oct 9, 2022

I’m still running into this same problem on version 4.3.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

plugins.legend.align are incompatible types typescript chartjs
The alignment works fine, I am getting the desired result but typescript is complaining that the type of align should be 'start', 'center'...
Read more >
plugins.legend.align are incompatible types typescript chartjs ...
Issue seems to be within the react-chartjs-2 lib. If you switch to the barebone version of chart.js you wont have this ...
Read more >
chartist-plugin-legend examples
Sets the position of the legend element. top , bottom or any DOM2 Element are currently accepted. If a DOM Element is given,...
Read more >
3.x Migration Guide - Chart.js
horizontalBar chart type was removed. ... renamed to tooltip to match the plugin name; legend , title and tooltip namespaces were moved from ......
Read more >
Legend Toggling - Ultimate WordPress Plugins by Supsystic
Toggling option is compatible with all types of diagrams except Bubble: Area Chart; Line Chart; Pie Chart ... Legend Position – choose a...
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