Closed GoogleCodeExporter closed 8 years ago
<script type="text/javascript"> $(function(){ function update(){ $.ajax({ type: "POST", url: "get-today-infor.php", success: function(msg){ var options = { xaxis: { mode: "time",timeformat: "%H:%M" , tickLength: 5 }, series: { lines: { show: true } }, crosshair: { mode: "x" }, grid: { hoverable: true, autoHighlight: false }, selection: { mode: "x" } }; var updateLegendTimeout = null; var latestPosition = null; var plot_big = $.plot($("#today-p"), [{data:msg , label: "总功率= 0.00"}], options); plot_big.draw(); var plot_small = $.plot($("#for_tip"), [msg], { series: { lines: { show: true, lineWidth: 1 }, shadowSize: 0 }, xaxis: { ticks: [], mode: "time",timeformat: "%H:%M" }, yaxis: { ticks: [], min: 0, autoscaleMargin: 0.1 }, selection: { mode: "x" } }); plot_small.draw(); function updateLegend() { updateLegendTimeout = null; var pos = latestPosition; var axes = plot.getAxes(); alert("nb"+axes.xaxis.max); if (pos.x < axes.xaxis.min || pos.x > axes.xaxis.max || pos.y < axes.yaxis.min || pos.y > axes.yaxis.max) return; var i, j, dataset = plot.getData(); for (i = 0; i < dataset.length; ++i) { var series = dataset[i]; // find the nearest points, x-wise for (j = 0; j < series.data.length; ++j) if (series.data[j][0] > pos.x) break; // now interpolate var y, p1 = series.data[j - 1], p2 = series.data[j]; if (p1 == null) y = p2[1]; else if (p2 == null) y = p1[1]; else y = p1[1] + (p2[1] - p1[1]) * (pos.x - p1[0]) / (p2[0] - p1[0]); legends.eq(i).text(series.label.replace(/=.*/, "= " + y.toFixed(2))); } } $("#today-p").bind("plotselected", function (event, ranges) { // do the zooming plot_big = $.plot($("#today-p"), [{data:msg , label: "总功率= 0.00"}], $.extend(true, {}, options, { xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to } })); // don't fire event on the overview to prevent eternal loop for_tip.setSelection(ranges, true); }); $("#today-p").bind("plothover", function (event, pos, item) { latestPosition = pos; if (!updateLegendTimeout) updateLegendTimeout = setTimeout(updateLegend, 50); }); $("#for_tip").bind("plotselected", function (event, ranges) { plot_big.setSelection(ranges); }); }, error: function(){ new Dialog('wait for a moment thanks...',{time:5000},{id:'dialog'}).show(); window.location.reload(); }, dataType: 'json' }); setTimeout(update, 1000000); } update(); }); </script>
Original issue reported on code.google.com by xmphoe...@gmail.com on 24 Jun 2011 at 5:38
xmphoe...@gmail.com
Original comment by olau%iol...@gtempaccount.com on 24 Jun 2011 at 9:09
olau%iol...@gtempaccount.com
Original comment by dnsch...@gmail.com on 7 May 2012 at 11:29
dnsch...@gmail.com
Original issue reported on code.google.com by
xmphoe...@gmail.com
on 24 Jun 2011 at 5:38