Morris Donut Chart label is showing undefined error
ShajahanKP opened this issue · comments
Dear Friends,
I am using Morris Donut chart to display the progress. I am getting the count of status correctly. But instead of Label it is showing undefined in the donut chart.
`var dtData = _.groupBy(jsonData, "status");
var keys = [];
keys = Object.keys(dtData);
alert(keys);
dtArr = [];
for (var n = 0; n < keys.length; n++) {
dtArr.push({
name: '' + keys[n] + '', value: '' + dtData[keys[n]].length + '',
});
} `
Morris.Donut({ element: 'dashboard-donut-8', data: dtArr, label: 'name', value: 'value', colors: ['#33414E', '#E04B4A', '#1caf9a', '#95b75d'], resize: true });
I am getting the value correctly. But getting as undefined for label.
Please help me on this
You should use the key label instead of name
label: '' + keys[n] + '', value: '' + dtData[keys[n]].length + '',
You should use the key label instead of name
label: '' + keys[n] + '', value: '' + dtData[keys[n]].length + '',
I changed as shown below:
for (var n = 0; n < keys.length; n++) {
`dtArr.push({
label: '' + keys[n] + '', value: '' + dtData[keys[n]].length + '',
});`
}
Morris.Donut({
element: 'dashboard-donut-8',
data: dtArr,
label: 'label',
value:
'value',
colors: ['#33414E', '#E04B4A', '#1caf9a', '#95b75d'],
resize: true
});`
Is the right way ??
Kindly suggest
You should use the key label instead of name
label: '' + keys[n] + '', value: '' + dtData[keys[n]].length + '',
Thanks 👍
Works properly 💯