ClemensKim - kyj909

hightchart [하이차트] 이번에는 hightchat 를 하게 됐음-리얼타임 샘플 본문

IT/Script

hightchart [하이차트] 이번에는 hightchat 를 하게 됐음-리얼타임 샘플

kyj909 2013. 7. 12. 14:57

이번에는 hightchat 를 하게 되었음...ㅠ,.ㅠ 리얼타임 시리즈 3개 샘플

나름 이쁘넹.

스크립트 시작 -------------------

$(function () {
    $(document).ready(function() {
        Highcharts.setOptions({
            global: {
                useUTC: false
            }
        });
   
        var chart;
        $('#container').highcharts({
            chart: {
                type: 'spline',
                animation: Highcharts.svg, // don't animate in old IE
                marginRight: 10,
                events: {
                    load: function() {
   
                        // set up the updating of the chart each second
                        var series = this.series[0];
                        var series2 = this.series[1];
                        var series3 = this.series[2];
                       
                        setInterval(function() {
                            var x = (new Date()).getTime(), // current time
                                y = Math.random();
                                z = Math.random();
                                a = Math.random();
                            series.addPoint([x, y], false, true);
                            series2.addPoint([x,z], false, true);
                            series3.addPoint([x,a], true, true);
                        }, 1000);
                    }
                }
            },
           
            title: {
                text: '샘플그래프'
               
               
            },
           
             subtitle: {
                text: '서브타이틀'
            },
           
            xAxis: {
                title:{
                    text:'X 값'  /*X 축 라벨*/
                    },
               
                type: 'datetime',
                tickPixelInterval: 150
            },
           
            yAxis: {
                title: {
                    text: 'Y 값'  /*y축 라벨*/
                },
                plotLines: [{
                    value: 0,
                    width: 1,
                    color: '#808080'
                }]
            },
           
            tooltip: {
                formatter: function() {
                        return '<b>'+ this.series.name +'</b><br/>'+
                        Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', this.x) +'<br/>'+
                        Highcharts.numberFormat(this.y, 2);
                }
            },
           
            legend: {
                enabled: false
            },
           
            exporting: {
                enabled: false
            },
           
            series: [{
                name: '툴팁라벨1',
                data: (function() {
                    // generate an array of random data
                    var data = [],
                        time = (new Date()).getTime(),
                        i;
   
                    for (i = -19; i <= 0; i++) {
                        data.push({
                            x: time + i * 1000,
                            y: Math.random()
                        });
                    }
                    return data;
                })()
            },
            {
                name: '툴팁라벨2',
                data: (function() {
                    // generate an array of random data
                    var data = [],
                        time = (new Date()).getTime(),
                        a;
   
                    for (a = -19; a <= 0; a++) {
                        data.push({
                            x: time + a * 1000,
                            y: Math.random()
                        });
                    }
                    return data;
                })()
            },
            {
                name: '툴팁라벨3',
                data: (function() {
                    // generate an array of random data
                    var data = [],
                        time = (new Date()).getTime(),
                        a;
   
                    for (a = -19; a <= 0; a++) {
                        data.push({
                            x: time + a * 1000,
                            y: Math.random()
                        });
                    }
                    return data;
                })()
            }
            ]
        });
    });
   
});

스크립트 끝 ---------------------

결과물


+ 디폴트 디자인대신에 gray theme 을 사용


'IT > Script' 카테고리의 다른 글

hightchart 참고 정리  (0) 2013.07.12
hightchart 참고 도서 [Learning Highcharts]  (0) 2013.07.12
NVD3 charts  (0) 2013.05.10
Flot 차트 샘플 관련  (0) 2013.04.11
flot - javascript Chart - API Doc  (0) 2013.04.06
Comments