STAnoise.js 3.66 KB
Newer Older
Patrick's avatar
Patrick committed
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
var histNoiseSTA
function getSTAHistNoise(){
    try {


        $.ajax({
            async: true,
            type: "POST",
            url: getSTANoiseHistUrl,
            data: "",
        }).done(function (histwinddata) {
            convertdata(histwinddata);
            console.log(histwinddata)
        });

        function convertdata(histwinddt) {
            histNoiseSTA = histwinddt;
            console.log(histNoiseSTA[0]);
            showgraphNoiseSTA();
        }

       
    }
    catch (err) {
        console.log('->  function gethistWind() failed!\n' + err);
    }
}

function showgraphNoiseSTA(){

    var i;
  
    var datas = []
    var datamin = []
    var datamax = []

    var dataseq = []
    console.log(histNoise.length)
    var sDay = new Date('1995-12-17T03:24:00');
    
    for (i = 0; i < histNoiseSTA.length; i++) {
        console.log(i)
        // console.log(noise_LA_maxnumb)
        var datestuff = Date.parse(histNoiseSTA[i].phenomenonTime)
        var valuestuff = histNoiseSTA[i].result
        // console.log(datestuff.toUTCString())
        // if (histNoiseSTA[i].noise == "LAeq"){
            
            datas.push({x: datestuff, y: parseFloat(valuestuff.toFixed(2))})
        // } else if  (histNoiseSTA[i].noise == "LAmin") {
        //     datamin.push({x: datestuff, y: parseFloat(valuestuff.toFixed(2))})
        // } else if (histNoiseSTA[i].noise == "LAmax") {
        //     datamax.push({x: datestuff, y: parseFloat(valuestuff.toFixed(2))})
        // }
        


  
    }
    // console.log(datas)
    // console.log(dataseq)
    console.log("--------")
    // console.log([{
    //   x: new Date('2018-02-12').getTime(),
    //   y: 76
    // }, {
    //   x: new Date('2018-02-12').getTime(),
    //   y: 76
    // }])
    var options = {
      chart: {
        type: "area",
        height: 300,
        foreColor: "#999",
        stacked: false,
        dropShadow: {
          enabled: true,
          enabledSeries: [0],
          top: -2,
          left: 2,
          blur: 5,
          opacity: 0.06
        }
      },
      colors: ['#7F0000','#00E396', '#0090FF'],
      stroke: {
        curve: "smooth",
        width: 3
      },
      dataLabels: {
        enabled: false
      },
      series: [{
        name: 'Noise_LAeq',
        data: datas
      }],
      markers: {
        size: 0,
        strokeColor: "#fff",
        strokeWidth: 3,
        strokeOpacity: 1,
        fillOpacity: 1,
        hover: {
          size: 6
        }
      },
      xaxis: {
        type: "datetime",
        labels: {
          datetimeUTC: false
        },
        axisBorder: {
          show: false
        },
        axisTicks: {
          show: false
        }
      },
      yaxis: {
        labels: {
          offsetX: 14,
          offsetY: -5
        },
        tooltip: {
          enabled: true
        }
      },
      grid: {
        padding: {
          left: -5,
          right: 5
        }
      },
      tooltip: {
        x: {
            format: "dd.MM.yyyy HH:mm"
          },
      },
      legend: {
        position: 'top',
        horizontalAlign: 'left'
      },
      fill: {
        type: 'gradient',
            gradient: {
              shadeIntensity: 1,
              inverseColors: false,
              opacityFrom: 0.5,
              opacityTo: 0,
              stops: [0, 90, 100]
            },
      }
    };
  
  document.getElementById("chartNoiseSTA").innerHTML = "";
  var chart = new ApexCharts(document.querySelector("#chartNoiseSTA"), options);
  // document.getElementById("infobtnNoise").classList.add('infobtn');
  // document.getElementById("infobtnNoise").classList.remove('loaderN');
  console.log("end")
  chart.render();
  
  }