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 labels pointStyle for pie partially not working? #9351

Closed
lucapollani opened this issue Jul 5, 2021 · 5 comments
Closed

Legend labels pointStyle for pie partially not working? #9351

lucapollani opened this issue Jul 5, 2021 · 5 comments

Comments

@lucapollani
Copy link

Expected Behavior

I should be able to define all the point styles defined here https://www.chartjs.org/docs/latest/configuration/elements.html#point-styles

Current Behavior

cross, crossRot, dash, line, star point styles are not working. Nothing is displayed. Am I doing something wrong?
image

circle, rect, rectRounded, rectRot, triangle point styles are working correctly instead.

Steps to Reproduce

https://codesandbox.io/s/red-lake-16cx6?file=/index.html

Context

Related to #9337 / #9341

Environment

  • Chart.js version: 3.4.1
  • Browser name and version: 91.0.4472.124
@LeeLenaleee
Copy link
Collaborator

It seems the cross is getting it styling from the borderColor and borderWidth propertys in the dataset, so when you set the borderColor the crosses will show and when you set the borderWidth it defines how big they are, downside is that you will get borders in your pie chart.

https://codesandbox.io/s/upbeat-smoke-f1221?file=/index.html

@etimberg
Copy link
Member

etimberg commented Jul 5, 2021

To work around the borders in the chart problem, one could override the generateLabels config option with something like this

const labelOpts = {
  generateLabels: (chart) => {
    const items = Chart.overrides.pie.plugins.legend.labels.generateLabels(chart);
    
    for (const item of items) {
      item.strokeStyle = item.fillStyle;
      item.lineWidth = 1;
    }
    
    return items;
  }
}

@lucapollani
Copy link
Author

lucapollani commented Jul 5, 2021

Thanks for the tips 👍🏻 , so as far as I've understood those point styles are actually being drawn but they have a size / color which doesn't make them show, correct?

@etimberg
Copy link
Member

etimberg commented Jul 5, 2021

That's correct

@lucapollani
Copy link
Author

Perfect, thank you, closing the issue then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants