高程图添加了一个新的数据点

Highcharts add a new data point

本文关键字:一个 数据 添加 高程图      更新时间:2023-09-26

我正试图每分钟更新一次高程线图。如这个链接所示现在,我对绘制图形的函数使用周期性的javascript调用。问题是它从头开始画。是否有可能将新的数据点添加到现有的行?

$(function () {
    $.getJSON('https://www.highcharts.com/samples/data/jsonp.php?    filename=usdeur.json&callback=?', function (data) {
    $('#container').highcharts({
        chart: {
            zoomType: 'x'
        },
        title: {
            text: 'USD to EUR exchange rate over time'
        },
        subtitle: {
            text: document.ontouchstart === undefined ?
                    'Click and drag in the plot area to zoom in' : 'Pinch the chart to zoom in'
        },
        xAxis: {
            type: 'datetime'
        },
        yAxis: {
            title: {
                text: 'Exchange rate'
            }
        },
        legend: {
            enabled: false
        },
        plotOptions: {
            area: {
                fillColor: {
                    linearGradient: {
                        x1: 0,
                        y1: 0,
                        x2: 0,
                        y2: 1
                    },
                    stops: [
                        [0, Highcharts.getOptions().colors[0]],
                        [1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
                    ]
                },
                marker: {
                    radius: 2
                },
                lineWidth: 1,
                states: {
                    hover: {
                        lineWidth: 1
                    }
                },
                threshold: null
            }
        },
        series: [{
            type: 'area',
            name: 'USD to EUR',
            data: data
        }]
    });
});

});

您应该在数据系列中使用addPoint函数…

这是一个图表的例子,每秒钟更新一次

http://jsfiddle.net/gh/get/jquery/1.9.1/hililide-software/highcharts.com/tree/master/samples/highcharts/demo/dynamic-update/

相关文章: