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

Unclear usage of GenerateLabels #53

Closed
Puharesource opened this issue Dec 11, 2019 · 2 comments
Closed

Unclear usage of GenerateLabels #53

Puharesource opened this issue Dec 11, 2019 · 2 comments
Assignees

Comments

@Puharesource
Copy link

Puharesource commented Dec 11, 2019

I'm attempting to change the labels in the legend, so that they show the value next to them. Using regular ChartJS, I'd have to pass a function to generateLabels in

options = {
    legend: {
        labels: {
            generateLabels: chart => {
                // Do stuff
            }
        }
    }
}

In ChartJSCore I can only parse a string to GenerateLabels within the LegendLabel class. It seems quite unclear how I'd achieve my goal. Clarification would be much appreciated, thank you.

@mattosaurus
Copy link
Owner

Hi, labels are part of the legend object not the options object aren't they?

options > legend > labels

https://www.chartjs.org/docs/latest/configuration/legend.html

For the generateLabels property just set the string value to whatever you function is, this is then rendered without the standard string double quotes by the decoration [JsonConverter(typeof(PlainJsonStringConverter))].

This maybe isn't obvious in the documentation so I'll update it to make it more explicit.

@Puharesource
Copy link
Author

Puharesource commented Dec 11, 2019

Oh yeah, I just forgot to put in the legend object, I've edited my original issue.
Thank you, I'll try it out

EDIT: Worked perfectly

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

2 participants