Highcharts-ng动态刷新数据方法

前端之家收集整理的这篇文章主要介绍了Highcharts-ng动态刷新数据方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

HTML:

<div style="border: 1px solid #ccc; width: 620px; float: right">
     <highchart id="chart1" config="chartConfig"></highchart>
</div>

highcharts-ng配置:

var prices = [60.5,55.7]; // Static data works

$scope.chartConfig = {
    options : {
        chart : {
            type : 'line'
        }
    },series : [ {
        data : prices 
    } ],title : {
        text : 'Monthly Book Prices'
    },loading : false
}

动态更新series数据:

$scope.chartConfig.series[0].data = $scope.book.prices 

或者用下面这个方法:

var prices = {data: [60.5,55.7]}; // Static data works

$scope.chartConfig = {
    options : {
        chart : {
            type : 'line'
        }
    },series : [ prices ],loading : false
}

prices.data = [60.5,55.7]

Highcharts官网:https://www.highcharts.com/stock/demo/dynamic-update

原文链接:https://www.f2er.com/angularjs/146598.html

猜你在找的Angularjs相关文章