Javascript Highchart事件加载不工作 函数绘图图($scope){ //控制台日志(“绘制图形”); //console.log(graphName); //log($scope.chartCategories); //log($scope.chartSeries); $scope.chartConfig={ 图表:{ 类型:“样条线”, 动画:Highcharts.svg,//不要在旧IE中设置动画 marginRight:10, 活动:{ 加载:函数(){ //设置图表的每秒更新 var系列=本系列[0]; setInterval(函数(){ var x=(新日期()).getTime(),//当前时间 y=数学随机(); 系列。添加点([x,y],真,真); 控制台日志(x+y); }, 1000); } } }, 标题:{ 文本:“实时随机数据” }, xAxis:{ 键入:“日期时间”, 像素间隔:150 }, 亚克斯:{ 标题:{ 文本:“值” }, 绘图线:[{ 值:0, 宽度:1, 颜色:'#808080' }] }, 工具提示:{ 格式化程序:函数(){ 返回“+this.series.name+”+ Highcharts.dateFormat(“%Y-%m-%d%H:%m:%S',this.x)+''+ 数字格式(this.y,2); } }, 图例:{ 已启用:false }, 出口:{ 已启用:false }, 系列:[{ 名称:'随机数据', 数据:(函数(){ //生成一个随机数据数组 var数据=[], 时间=(新日期()).getTime(), 我 对于(i=-19;i
在更新数据后尝试重新绘制图表Javascript Highchart事件加载不工作 函数绘图图($scope){ //控制台日志(“绘制图形”); //console.log(graphName); //log($scope.chartCategories); //log($scope.chartSeries); $scope.chartConfig={ 图表:{ 类型:“样条线”, 动画:Highcharts.svg,//不要在旧IE中设置动画 marginRight:10, 活动:{ 加载:函数(){ //设置图表的每秒更新 var系列=本系列[0]; setInterval(函数(){ var x=(新日期()).getTime(),//当前时间 y=数学随机(); 系列。添加点([x,y],真,真); 控制台日志(x+y); }, 1000); } } }, 标题:{ 文本:“实时随机数据” }, xAxis:{ 键入:“日期时间”, 像素间隔:150 }, 亚克斯:{ 标题:{ 文本:“值” }, 绘图线:[{ 值:0, 宽度:1, 颜色:'#808080' }] }, 工具提示:{ 格式化程序:函数(){ 返回“+this.series.name+”+ Highcharts.dateFormat(“%Y-%m-%d%H:%m:%S',this.x)+''+ 数字格式(this.y,2); } }, 图例:{ 已启用:false }, 出口:{ 已启用:false }, 系列:[{ 名称:'随机数据', 数据:(函数(){ //生成一个随机数据数组 var数据=[], 时间=(新日期()).getTime(), 我 对于(i=-19;i,javascript,angularjs,asp.net-mvc,highcharts,Javascript,Angularjs,Asp.net Mvc,Highcharts,在更新数据后尝试重新绘制图表 function drawGraph($scope) { //console.log("in draw graph"); //console.log(graphName); //console.log($scope.chartCategories); //console.log($scope.chartSeries); $scope.chartConfig = { chart: { ty
function drawGraph($scope) {
//console.log("in draw graph");
//console.log(graphName);
//console.log($scope.chartCategories);
//console.log($scope.chartSeries);
$scope.chartConfig = {
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];
setInterval(function () {
var x = (new Date()).getTime(), // current time
y = Math.random();
series.addPoint([x, y], true, true);
console.log(x + y);
}, 1000);
}
}
},
title: {
text: 'Live random data'
},
xAxis: {
type: 'datetime',
tickPixelInterval: 150
},
yAxis: {
title: {
text: 'Value'
},
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: 'Random data',
data: (function () {
// generate an array of random data
var data = [],
time = (new Date()).getTime(),
i;
for (i = -19; i <= 0; i += 1) {
data.push({
x: time + i * 1000,
y: Math.random()
});
}
return data;
}())
}]
}
}
它看起来像highcharts ng中的一个bug。请参阅相关主题:Same!加载函数甚至没有调用:S
load: function() {
// set up the updating of the chart each second
var series = this.series[0];
var chart = this;
setInterval(function() {
var x = (new Date()).getTime(), // current time
y = Math.random();
series.addPoint([x, y], true, true);
chart.redraw();
console.log(x + y);
}, 1000);
}