2012-09-20 104 views

回答

14

當您在目前不可見的東西上致電$.plot時,Flot不起作用。你最好的選擇將是移動你的第2頁和第3個圖形到pageshow事件:

$('#device2').bind('pageshow',function(){  
    $.plot($("#total-inches-graph"), 
    [{ color: "rgb(14, 91, 173)", label: 'Total Measurements', data: totalInchesArray }] , 
    { xaxis: { mode: "time", timeformat: "%a" ,minTickSize: [1, "day"] } }); 
}); 

$('#device3').bind('pageshow',function(){  
    $.plot($("#weight-graph"), 
    [{ color: "rgb(32, 140, 47)", label: 'Weight', data: weightArray }] , 
    { xaxis: { mode: "time", timeformat: "%a" ,minTickSize: [1, "day"] } }); 
}); 

我在這裏做一個工作示例:http://jsfiddle.net/ryleyb/yZuZb/

0

似乎有什麼不對的滑動,隨着情節的正確呈現時,頁面被直接訪問,例如打開以下網址: http://lasmit.co.uk/tmm-graphs/graph2.php#device2,但隨後的其他頁面都呈現不正確。

您設置了DIV元素的大小,您是否也可以設置圖的確切大小?