日期:2014-05-17  浏览次数:20666 次

最近用到了jquery的一个图表功能jqplot,发现页面内存会不断的增加,求各位兄弟姐妹帮忙解决下。
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  "http://www.w3.org/TR/html4/loose.dtd">

<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>Simple Test</title>
  <!--[if IE]><script language="javascript" type="text/javascript" src="../excanvas.js"></script><![endif]-->
  
  <link rel="stylesheet" type="text/css" href="../jquery.jqplot.css" />
  <link rel="stylesheet" type="text/css" href="examples.css" />
  
  <!-- BEGIN: load jquery -->
  <script language="javascript" type="text/javascript" src="../jquery-1.4.2.min.js"></script>
  <!-- END: load jquery -->
  
  <!-- BEGIN: load jqplot -->
  <script language="javascript" type="text/javascript" src="../jquery.jqplot.js"></script>
  <script language="javascript" type="text/javascript" src="../plugins/jqplot.dateAxisRenderer.js"></script>
  <script language="javascript" type="text/javascript" src="../plugins/jqplot.barRenderer.js"></script>
  <script language="javascript" type="text/javascript" src="../plugins/jqplot.categoryAxisRenderer.js"></script>
  <!-- END: load jqplot -->
  <style type="text/css" media="screen">
  .jqplot-axis {
  font-size: 0.85em;
  }
  </style>

  </head>
  <body>
  <div id="chart2" style="margin-top:20px; margin-left:20px; width:400px; height:300px;"></div>
  <script type="text/javascript" language="javascript">
  function show(){
  document.getElementById("chart2").innerHTML=null;
  var number = Math.random()*10;
$.jqplot.config.enablePlugins = true;
s1 = [number, 3, 9, 16, 12, 8];
ticks = [2006, 2007, 2008, 2009, 2010, 2011];
plot2 = $.jqplot('chart2', [s1], {
  seriesDefaults:{},
  legend: {show:true, location: 'nw'},
  axes:{xaxis:{renderer:$.jqplot.CategoryAxisRenderer, ticks:ticks}, yaxis:{min:0, max:20, numberTicks:6}}
  });
  setTimeout("show()",1000);
  }
  show();
  </script>
  </body>
</html>

------解决方案--------------------
你在调用的时候可以清理一次原来的数据吗?