2012-06-11 50 views
0

有誰知道如何讓flot顯示「時間軸」類型?在Flot中顯示時間軸/線性數據

E.g.

Y: 
Person1| -----  ------- 
Person2| ------- ------- 
Person3| -- ----- ---- 
Person4|  ------- 
     _____________________ 
X:  Jan Feb March April 

我不知道如何在y軸上顯示的標籤,並顯示

解決方案到目前爲止:)

$(文件)。就緒數據線(函數( ){

var d1 = [[(new Date("01/01/2009")).getTime(), 5], [(new Date("10/01/2009")).getTime(), 5]]; 

var placeholder = $("#placeholder"); 

// plot it 
var plot = $.plot(placeholder, [d1], {xaxis:{mode:"time", timeformat:"%b.%y"}}); 

});

在此先感謝!

回答

2

終於找到了答案。使用配置「滴答聲」。

解決方案:

//american dates 
    var d1 = [[(new Date("01/01/2009")).getTime(), 1], [(new Date("01/10/2009")).getTime(), 1]]; 
    var d2 = [[(new Date("05/05/2009")).getTime(), 2], [(new Date("06/23/2009")).getTime(), 2]]; 
    var d3 = [[(new Date("03/10/2009")).getTime(), 3], [(new Date("03/15/2009")).getTime(), 3]]; 
    //var d1 = [[0, 5], [5, 5], null, [5, 10], [15, 10]]; 
    var placeholder = $("#placeholder"); 

    // plot it 
    var plot = $.plot(placeholder, [d1,d2,d3], { 
     xaxis:{mode:"time", timeformat:"%b.%y"}, 
     yaxis:{ticks:[[1, "Apple"], [2, "Microsoft"], [3, "Dell"]]} 
    }); 
1

查看http://people.iola.dk/olau/flot/examples/basic.html的來源 要特別注意評論// a null signifies separate line segments 我認爲應該讓你到你想要的地方。

+0

感謝的是,是啊,我看到了......但我不似乎得到相同的結果,如果x軸是時間!因爲我不確定如何將yaxis設置爲每個數據集的其他類似「人員」的東西。 – Stevanicus