Search code examples
javascriptsharepointmorris.jsdonut-chart

Morris Donut Chart label is showing undefined error


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.

Morris Donut Chart Showing Undefined Error as Label

    var dtData = _.groupBy(jsonData, "status");
    var keys = [];
    keys = Object.keys(dtData);
    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

Thank You


Solution

  • You should use the key label instead of name

    label: '' + keys[n] + '', value: '' + dtData[keys[n]].length + '',