$(function() {
$(document).ready(function() {
// set an array to be used as initial x axis values
var xAxisValues = (function () {
var data = [], i=0;
var interval = setInterval(function () {
if ( i < 5 )
{
data.push(new Date());
}
else
{
clearInterval(interval);
}
},1000);
console.log(data);
return data;
})();
var dataSeries = (function () {
// generate an array of random data
var data = [],
time = (new Date()).getTime(),
i;
for (i = -19; i <= 0; i += 5) {
data.push({
x: time + i * 1000,
y: (i != 0 ? null : Math.random())
});
}
return data;
}());
$('#container02').highcharts({
chart: {
type: 'spline',
animation: Highcharts.svg, // don't animate in old IE
marginRight: 10,
events: {
load: function () {
// set up the updating of the chart each second
var series = this.series,
xAxis = this.xAxis,
count = 1;
function addPoint(){
series.forEach(function (s,i) {
var x = (new Date()).getTime(), // current time
y = Math.random()*i+1;
s.addPoint([x,(y*count)+s.data[s.data.length-1].y],true,true);
});
};
addPoint()
console.log(xAxis);
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.