In the following quick example, the memory is not freed by Chrome,
even after one minute of not updating the graph. Which is a problem
for me as I'd need to update it regularly.
<!doctype>
<html>
<head>
<title>Test AJAX graph</title>
<link rel="stylesheet" type="text/css" href="jqplot/
jquery.jqplot.css" />
<script type="text/javascript" src="
http://ajax.googleapis.com/
ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<!--[if lt IE 9]><script language="javascript" type="text/
javascript" src="jqplot/excanvas.js"></script><![endif]-->
<script type="text/javascript" src="jqplot/jquery.jqplot.js"></
script>
<script type="text/javascript" src="jqplot/plugins/
jqplot.cursor.min.js"></script>
<script type="text/javascript" src="jqplot/plugins/
jqplot.highlighter.min.js"></script>
<script type="text/javascript" src="jqplot/plugins/
jqplot.enhancedLegendRenderer.js"></script>
<script type="text/javascript" src="jqplot/plugins/
jqplot.dateAxisRenderer.js"></script>
<script type="text/javascript" src="jqplot/plugins/
jqplot.canvasTextRenderer.js"></script>
<script type="text/javascript" src="jqplot/plugins/
jqplot.canvasAxisTickRenderer.js"></script>
<script type="text/javascript">
var datalist = [1,3,4];
var labellist = ['label'];
var plot;
function rand (min, max) {
var argc = arguments.length;
if (argc === 0) {
min = 0;
max =
2147483647;
} else if (argc === 1) {
throw new Error('Warning: rand() expects exactly 2
parameters, 1 given');
}
return Math.floor(Math.random() * (max - min + 1)) +
min;
}
function createPlot(datalist, labellist) {
plot = $.jqplot('chart', datalist, {
title:'Données de production EDF pour un an',
stackSeries: true,
legend: {
renderer: $.jqplot.EnhancedLegendRenderer,
show: true,
placement: 'outsideGrid',
rendererOptions:{
numberRows: 1
},
location: 's'//,
//labels:labellist
},
seriesDefaults: {fill:true, showMarker:false},
axes: {
xaxis: {/*renderer:$.jqplot.DateAxisRenderer,
rendererOptions:{tickRenderer:
$.jqplot.CanvasAxisTickRenderer},
tickInterval:'2 weeks',
tickOptions:{
formatString:'%d/%m/%Y',
fontSize:'10pt',
fontFamily:'Tahoma',
fontSize:'10pt', fontFamily:'Tahoma',
angle:-40, fontWeight:'normal', fontStretch:1
},*/
pad: 1 //On réduit les marges du graphe
},
yaxis: {
//pad: 1,
min: 0
}
},
cursor:{
show: true,
zoom:true,
showTooltip:false
}
});
}
function updatevals() {
var JSONdata = {"datastreams": [
{"label": "Data1", "type": "normal", "data":
[rand(0,5), rand(0,5), rand(0,5), rand(0,5), rand(0,5), rand(0,5)]},
{"label": "Data2", "type": "normal", "data":
[rand(0,5), rand(0,5), rand(0,5), rand(0,5), rand(0,5), rand(0,5)]},
{"label": "Data3", "type": "normal", "data":
[rand(0,5), rand(0,5), rand(0,5), rand(0,5), rand(0,5), rand(0,5)]}
]
};
var i;
datalist = [];
labellist = [];
for(i=0;i<JSONdata.datastreams.length;i++) {
switch (JSONdata.datastreams[i].type) {
case "normal":
//alert(dump(JSONdata.datastreams[i]));
datalist.push(JSONdata.datastreams[i].data);
labellist.push(JSONdata.datastreams[i].label);
break;
}
}
if (plot) {
$("#chart").html("");
plot = null;
}
createPlot(datalist, labellist);
}
$(document).ready(function(){
$.jqplot.config.enablePlugins = true;
var options = {
title: "Lines",
legend:{show:true, location:'se'},
seriesDefaults:{trendline:{show:true}}
}
updatevals();
});
</script>
</head>
<body>
<div class="jqplot" id="chart" style="height:500px;width:
1000px;"></div>
<button onclick="updatevals();">Change vals</button>
</body>
</html>
On 13 juil, 08:59, Antonin Lenfant <
antonin.lenf...@smart-impulse.com>
wrote: