2
http://code.google.com/p/flot/jQuery的海军报插件,图和标签订购
通过默认的图解和标签按顺序显示,这是我所定义他们
$.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}
}
);
凡plotdata是一个阵列,具有结构:
var plotData = [
{data: statData1, color: plotColor1, label: label1},
{data: statData2, color: plotColor2, label: label2},
{data: statData3, color: plotColor3, label: label3}
];
我想在一个订单中显示重复,其他标签:
plot S:
plot1 plot2 plot3
图例表:
plot3 plot1 plot2
我只有一个想法:通过脚本图例表更改顺序,我没有看到这里的选项此
if ($('#chart div.legend table tr').length > 1) {
var $tableRow = $('#chart div.legend table tr:last');
$tableRow.insertBefore($('#chart div.legend table tr:first'));
}
存在一个更好的方法来做到这一点?
这个伟大的,谢谢你,但排序的选项是排序方法的功能。 我压缩了我的例子,并且您如何看到现在的标签顺序不是降序或升序,而是任意顺序。我只是想把数组的最后一个元素放在第一位 – 2012-07-23 13:17:17
你仍然可以做到这一点;这只是一点点工作。您的排序功能接受系列a和b。迭代原始plotData数组,并通过标签进行比较以在plotData中查找两个系列的索引。然后,如果aIndex == plotData.length - 1,则返回-1将其排序后面的所有内容,否则返回aIndex - bIndex以保持其余按索引定期排序。 – DNS 2012-07-23 13:26:06
谢谢,但将来排序功能不是最好的方法=) LabelOrder选项在系列数据中会更方便=) – 2012-07-23 17:02:44