Reputation: 886
http://code.google.com/p/flot/
By default plots and labels display in order, which i defined them
$.plot($("#chart"),
plotData
,
{
series:{
lines:{ show:true },
points:{ show:true }
},
grid:{ hoverable:true, clickable:true },
yaxis:{ min:0, max:data.maxYaxisValue, tickDecimals:0},
xaxis:{ tickFormatter:tickFormatter}
}
);
Where plotdata is a array, with structure:
var plotData = [
{data: statData1, color: plotColor1, label: label1},
{data: statData2, color: plotColor2, label: label2},
{data: statData3, color: plotColor3, label: label3}
];
I want show plots in one order, labels in other:
plots:
plot1 plot2 plot3
legend table:
plot3 plot1 plot2
I have only one idea: change order in legend table by script, i don't see option here for this
if ($('#chart div.legend table tr').length > 1) {
var $tableRow = $('#chart div.legend table tr:last');
$tableRow.insertBefore($('#chart div.legend table tr:first'));
}
Exist a better way for do this?
Upvotes: 2
Views: 1358
Reputation: 38189
The Flot master branch on Github supports sorting legend labels independently of their series.
It was just added about a week ago, so if you're already using the master branch, you may just need to update. If you're using 0.7, you can either switch to the master branch, if you're okay with it being much less stable, or find those specific commits in the history and apply them to your copy manually.
Upvotes: 3