This commit is contained in:
Yann Esposito (Yogsototh) 2014-12-21 23:21:41 +01:00
parent f6cf852deb
commit b40a327621

View file

@ -24,11 +24,6 @@
var runningElmModule1 = Elm.embed(Elm.Main,div1); var runningElmModule1 = Elm.embed(Elm.Main,div1);
var runningElmModule2 = Elm.embed(Elm.Main,div2); var runningElmModule2 = Elm.embed(Elm.Main,div2);
var position = 0;
var setpos = function(x) { console.log(x); position = x; }
runningElmModule1.ports.xpos.subscribe(setpos);
var genPoint = function(v){ return { x: (new Date()).getTime(), y: v}; var genPoint = function(v){ return { x: (new Date()).getTime(), y: v};
} }
var genPoints = function(n) { var serie = []; var genPoints = function(n) { var serie = [];
@ -41,6 +36,12 @@
} }
var initDatas = genPoints(20); var initDatas = genPoints(20);
var updateSerie = function(){
var series=this.series[0];
runningElmModule1.ports.xpos.subscribe(function(x){
series.addPoint(genPoint(x),true,true); });
};
var conf = { var conf = {
title: {text: 'Reactive data'}, title: {text: 'Reactive data'},
xAxis: {type: 'datetime'}, xAxis: {type: 'datetime'},
@ -49,12 +50,7 @@
exporting: {enabled: false}, exporting: {enabled: false},
chart: { chart: {
type: 'spline', type: 'spline',
events: {load: function(){ events: {load: updateSerie},
var series = this.series[0];
setInterval(function(){
series.addPoint(genPoint(position),true,true);
},1000);}
},
}, },
series: [{ series: [{
name: 'Reactive Data', name: 'Reactive Data',