조민지

data push

...@@ -31,30 +31,37 @@ ...@@ -31,30 +31,37 @@
31 31
32 32
33 <script src="/socket.io/socket.io.js"></script> 33 <script src="/socket.io/socket.io.js"></script>
34 - <script type="text/javascript"> 34 + <script>
35 var socket = io.connect('/', { transports: ['websocket'], upgrade: false }); 35 var socket = io.connect('/', { transports: ['websocket'], upgrade: false });
36 socket.emit("connection", "client in"); 36 socket.emit("connection", "client in");
37 socket.on("weatherInfo_minutely_send_to_client", (info) => { //서버에서 client에게 메세지 전송 37 socket.on("weatherInfo_minutely_send_to_client", (info) => { //서버에서 client에게 메세지 전송
38 console.log(info); 38 console.log(info);
39 39
40 - }); 40 + var date = new Date().getTime();
41 41
42 + chart1.series.data.push({
43 + x: date,
44 + y: info.death
45 + })
46 + });
47 + </script>
48 + <script type="text/javascript">
42 var chart1 = Highcharts.chart("container1", { 49 var chart1 = Highcharts.chart("container1", {
43 chart: { 50 chart: {
44 type: "areaspline", 51 type: "areaspline",
45 animation: Highcharts.svg, // don't animate in old IE 52 animation: Highcharts.svg, // don't animate in old IE
46 marginRight: 10, 53 marginRight: 10,
47 - events: { 54 + // events: {
48 - load: function () { 55 + // load: function () {
49 - // set up the updating of the chart each second 56 + // // set up the updating of the chart each second
50 - var series = this.series[0]; 57 + // var series = this.series[0];
51 - setInterval(function () { 58 + // setInterval(function () {
52 - var x = new Date().getTime(), // 현재 시간 59 + // var x = new Date().getTime(), // 현재 시간
53 - y = 0; //여기에 새로 넣을 값 60 + // y = 0; //여기에 새로 넣을 값
54 - series.addPoint([x, y], true, true); 61 + // series.addPoint([x, y], true, true);
55 - }, 60000); //1000=1초 -> 1분=60000 62 + // }, 60000); //1000=1초 -> 1분=60000
56 - } 63 + // }
57 - } 64 + // }
58 }, 65 },
59 66
60 time: { 67 time: {
......