Blame view

src/misc/static/js/plotter.js 1.93 KB
81988d81   Patrick Maeght   plot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85


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);
        
    }
 
}