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.

custom labels with generateLabels in donutcharts,doesn't work properly

See original GitHub issue

I find how to use generateLabels at chart.js but it doesn’t work properly for me when i use vue-chartjs. i don’t know whether it is the problem of vue-chartjs.

Expected Behavior

labels = Chart.defaults.global.legend.labels.generateLabels(chart); labels should renturn the labels be generated before modified.

Actual Behavior

the labels is an array,but the length is not correct ,it only get the first legend item ,but i have three items in data.and ,it only get the data value ,the other property all get null.

test case

Environment

  • vue.js version: 2.5.13
  • vue-chart.js version: 3.3…2
  • chart.js version:2.7.2

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
aperturelesscommented, Jul 16, 2018

Hi @xcchcaptain ,

Well the issue you provides from the Chart.js repo is quite different from what you are doing.

You have one dataset and provided labels for each datapoint.

However the example had multiple datasets and each data: [] array has its own label.

And the generateLengend callback is gathering only the label from the data array.

As you can see here: https://codepen.io/apertureless/pen/zLqOpy?editors=1010

So you mixed up the labels array outside the dataset and the label prop inside your data array.

So this is not an issue with vue-chartjs as it seems this will not work with chart.js either in your case with only a labels array.


The question is what you are trying to achieve. Maybe there is another way.

0reactions
xcchcaptaincommented, Jul 19, 2018

sorry ,it’s my fault, i will try to make it more clear. please look this case one group data. when we only provide one group of data .the labels property in chartData (out of datasets )defined the legend for every item of the data. no matter what ,thanks for your help . reconsiderd the business scene,what i really want is have the label reactived with the data .so ,i will try the reactiveProp.

replenish :as what you said , you already got the problem. i will provide this isuue to chartjs

Read more comments on GitHub >

github_iconTop Results From Across the Web

Doughnut chart from Chart.js, custom legend and call of ...
I've already tried that but for some reasons that not worked, ... onClick.call(this, e, legendItem) }, labels: { generateLabels: chart ...
Read more >
How to Customize Legend With GenerateLabels in Chart JS
It requires a lot of different moving parts to work along. The canvas tag, javascript, arrays and Chart JS all need to be...
Read more >
How to Create Custom Legend for Doughnut Chart ... - YouTube
It requires a lot of different moving parts to work along. The canvas tag, javascript, arrays and Chart JS all need to be...
Read more >
Looker Studio - Customized labels for pie & donut charts
The simple trick below will help you to customize labels for your pie & donuts charts, and display data you need, with the...
Read more >
Contour Plot: Setting Appearance Options
Automatically generate labels for contour levels. Select the check box to automatically label the contour lines. The label for each contour line is...
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