Skip to content

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

Closed

Description

@MasterCash

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

Activity

  1. xxgunnery commented on Jun 30, 2023

    @xxgunnery

    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?

  2. MasterCash commented on Jun 30, 2023

    @MasterCash
    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)

  3. added this to the Version 4.3.1 milestone on Jun 30, 2023
  4. etimberg commented on Jun 30, 2023

    @etimberg
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions