custom labels with generateLabels in donutcharts,doesn't work properly
See original GitHub issueI 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.
Environment
- vue.js version: 2.5.13
- vue-chart.js version: 3.3…2
- chart.js version:2.7.2
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 ownlabel
.And the
generateLengend
callback is gathering only thelabel
from thedata
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 thelabel
prop inside yourdata
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 alabels
array.The question is what you are trying to achieve. Maybe there is another way.
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