问题描述
<%//我的是java想做一个动态刷新效果请看这里http://people.iola.dk/olau/flot/examples/ajax.htmlStringdata1="data:[[0,0],[5,5],[6,10],[7,8],[10,20],[11,21],[12,22],[13,23],[14,24],[15,25],[16,16],[17,27],[18,28],[19,5],[20,20],[21,18],[23,15],[25,16],[26,5],[28,15]]";//[[1999,3.0],[2000,3.9],[2001,2.0],[2002,1.2],[2003,1.3],[2004,2.5],[2005,2.0],[2006,3.1],[2007,2.9],[2008,0.9]]Stringpv1="[{"+la+","+data1+"}]";%><script>$(function(){vardata=<%=pv1%>;varoptions={series:{lines:{show:true},points:{show:true}},grid:{labelMargin:1},legend:{noColumns:2},xaxis:{tickDecimals:0,min:0,max:30,tickDecimals:0,ticks:50,tickSize:3,minTickSize:0.01,tickFormatter:100},yaxis:{min:0,max:30},selection:{mode:"x"}};$("#placeholder").bind("plotselected",function(event,ranges){$.plot($("#placeholder"),data,$.extend(true,{},options,{xaxis:{min:ranges.xaxis.from,max:ranges.xaxis.to}}));});$.plot($("#placeholder"),data,options);//更新数据$("input.dataUpdate").click(function(){mydata=[];$.plot($("#placeholder"),mydata,options);variteration=0;//重复次数//取得数据functionfetchData(){++iteration;//数据被取得functiononDataReceived(data){mydata=data;$.plot($("#placeholder"),mydata,options);}//刷新$.ajax({success:onDataReceived});if(iteration<5)//周期性执行函数fetchData()setTimeout(fetchData,1000);else{mydata=[];}}//周期性执行函数fetchData()setTimeout(fetchData,1000);});});<script>