Adding coloured box as legends to morris graph

Viewed 7987

I am trying to add colored box as legends to the morris graph. The below picture shows the C3 graph legend. But I am unable to find a way to add in the Morris the same way.

Can anyone help ?

Colored Box Legend example - C3

Currently , The Morris legends appears as below with the code:

Morris Graph Legend

The code for Morris - jQuery

var chart=  Morris.Line({
    element: 'status-req',
    data: <?=json_encode($jsonDataArray)?>,     
    xkey: 'y',
    ykeys: <?=json_encode($deliveryAspect['statusKeys'])?>,
    labels:  <?=json_encode($deliveryAspect['statusLabels'])?>,
    hideHover: 'auto',
    resize: true,      
    smooth:true       
});

chart.options.labels.forEach(function(label, i) {
    var legendItem = $('<span align="center"></span> ').text(label).css('color', chart.options.lineColors[i])
    $('#legend').append(legendItem);
});
1 Answers
Related