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

Legend Label Options missing type def for pointStyleWidth - Typescript #11366

Closed
MasterCash opened this issue Jun 22, 2023 · 3 comments · Fixed by #11383
Closed

Legend Label Options missing type def for pointStyleWidth - Typescript #11366

MasterCash opened this issue Jun 22, 2023 · 3 comments · Fixed by #11383
Labels
type: bug type: types Typescript type changes
Milestone

Comments

@MasterCash
Copy link

MasterCash commented Jun 22, 2023

Expected behavior

property pointStyleWidth exists on options.plugin.legend.labels object and doesn't cause compiler error

Current behavior

compiler complains that pointStyleWidth doesn't exist but it should be according to documentation: https://www.chartjs.org/docs/latest/configuration/legend.html#legend-label-configuration

Reproducible sample

https://www.typescriptlang.org/play?module=1#code/JYWwDg9gTgLgBAbzgYQBYENZwL5wGZQQhwDkAxhrAHQBWAziQNwCwAUGwG6ZxkwAecALxwAJhDIBXEAFMAdjCoBzaTACiAG2kz5AIQCeASREAKAEQg9aTDFMBKOOjpwAEgBUAsgBlk6WVzoaWnIwLKxcUHAWVljCstIA7iiUMMa8fAA0iGxwOXAwemDSAFyk6sBxJOnZuSLoMOglCNW5ueroAEbS6nQlANqmAErSIqaZpjrqEtKjcKYAml3qEPEzpgDiUNJyqwAKElBgmqsA8lC+yqYAulWsLS219XQqPXC9Tbd3n22d6iUkAMRwCB4OAANQgMGkDBun0+DwarwAjAAmTKIgCcmQAzJkAKyZVFwLHXZp3bCXUnYGG5CBgGDACCyF7vT6HCSKcrM0ktTTKWQiRrcu7fLpcj6w3KQcowADK+U0AHVgCIYKgSoiAAzUiXYIU5XXi3JUoV0MjoTRiiV8QWGz56nDau56G0SnL2g2fD1GtjYWyMIA

Optional extra steps/info to reproduce

No response

Possible solution

if property is not intended for use, remove from documentation link, or add property to the types code

Context

I am using the usePointStyle property for the legend and I am trying to control the size of the circle

chart.js version

v4.3.0

Browser name and version

No response

Link to your project

No response

@etimberg etimberg added the type: types Typescript type changes label Jun 22, 2023
@xxgunnery
Copy link

Hey any updates on solving this? I am having the same problem with 3.9.1. I wonder if there is an alternative to changing the pointStyle?

@MasterCash
Copy link
Author

@xxgunnery:

you can get around the TS compile errors by casting to any but you lose intellisense and type checking:

new Chart(ctx, {
  ...,
  options: {
    plugins: {
      legend: {
        labels: {
          pointStyleWidth: 10,
        } as any
      }
    }
  }
});

you could also go to your node_modules folder (or where ever your package lives) and manually update the package to have the type def, you could add it to the chart.js/dist/types/index.d.ts file with the interface LegendOptions there is the labels property where I believe it should be added to allow it to work without the any. This also causes it to be overwritten if you ever update 🤷‍♂️ but that would be a workaround. (I also haven't tested the implications of the second workaround and have only done a little bit of digging into the source code)

@etimberg
Copy link
Member

Sent a PR to fix this for the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug type: types Typescript type changes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants