A Line chart with a scrolling effect
This goes in the documents header:
<script src="RGraph.common.core.js"></script>
<script src="RGraph.line.js"></script>
Put this where you want the chart to show up:
<canvas id="cvs" width="600" height="250">
[No canvas support]
</canvas>
This is the code that generates the chart:
<script>
data = RGraph.arrayPad([], 500);
last = 30;
(function drawGraph ()
{
RGraph.clear(document.getElementById("cvs"));
RGraph.ObjectRegistry.clear();
var line = new RGraph.Line({
id: 'cvs',
data: data,
options: {
colors: ['rgb(200,0,0)'],
linewidth: 1,
filled: true,
filledColors: 'rgba(255,0,0,0.5)',
yaxisScaleMax: 60,
tickmarksStyle: null,
shadow: false,
xaxisTickmarksCount: 5,
xaxisLabels: ['Now','25s','50s','75s','100s','125s'],
backgroundGridVlinesCount: 5
}
}).draw();
n = RGraph.random(last - 5, last + 5);
last = n;
if (last < 0) last = 1;
// Bounds constraints
Math.max(0, n);
Math.min(500, n);
data = [n].concat(data);
data.pop();
setTimeout(drawGraph, 250);
})();
</script>