I have got a question:
Is it possible to sort labels of my legend at Jqplot?
legend: {
show: true,
placement: 'outsideGrid'
},
I have got a question:
Is it possible to sort labels of my legend at Jqplot?
legend: {
show: true,
placement: 'outsideGrid'
},
You could use something like this to sort the rows in the legend (inspired by How may I sort a list alphabetically using jQuery?):
var rows = $('#chart .jqplot-table-legend tr').get();
rows.sort(function(a, b) {
return $(a).children().last().text().localeCompare($(b).children().last().text());
});
$.each(rows, function(index, item) {
$('#chart .jqplot-table-legend tbody').append(item);
});
This works best for the standard legend renderer - it will also work for the EnhancedLegendRenderer
, but toggling a series visible/invisible will actually show or hide the series that corresponded to the label that was there prior to being sorted.