function PlotterClas(hkname, plotdiv, HKRange) { this.hkname = hkname; this.plotdiv = plotdiv; this.HKRange = HKRange this.dataPlot = []; this.HKQueue = { x: [], y: [], type: 'scatter', name: 'HK' }; this.minQueue = { x: [], y: [], type: 'scatter', name: 'Min' }; this.maxQueue = { x: [], y: [], type: 'scatter', name: 'Max' }; this.layout = { title: 'Title of the Graph', xaxis: { title: 'Time' }, yaxis: { title: 'Value', type: 'log' } }; this.layout.title = this.hkname; this.HKQueue.x = []; this.HKQueue.y = []; this.dataPlot = []; this.dataPlot.push(this.HKQueue); if (this.HKRange){ if (this.HKRange[0]) { this.minQueue.x = []; this.minQueue.y = []; this.dataPlot.push(this.minQueue); } if (this.HKRange[1]) { this.maxQueue.x = []; this.maxQueue.y = []; this.dataPlot.push(this.maxQueue); } } } PlotterClas.prototype = { methode: function() { alert("Attributs: " + this.hkname + ", " + this.plotdiv); }, refresh_list: function(data) { var x = this.HKQueue.x.push(data[0]); this.minQueue.x.push(data[0]); this.maxQueue.x.push(data[0]); if (x > 50) { this.HKQueue.x.shift(); this.minQueue.x.shift(); this.maxQueue.x.shift(); } var y = this.HKQueue.y.push(data[1]); this.minQueue.y.push(this.HKRange[0]); this.maxQueue.y.push(this.HKRange[1]); if (y > 50) { this.HKQueue.y.shift(); this.minQueue.y.shift(); this.maxQueue.y.shift(); } Plotly.newPlot(this.plotdiv, this.dataPlot, this.layout); } }