0
我有一个Highchart图,它以Handlebars表达式的形式从后端接收数据。像这样的东西。使用Handlebars刷新Highcharts和来自AJAX的数据
$('#container').highcharts({
xAxis: {
categories: [{{{histKeys}}}]
},
yAxis: {
title: {
text: 'Failure Percentage',
style: {
color: '#cc0000'
}
},
labels: {
format: '{value}%',
style: {
color: '#cc0000'
}
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
credits: {
enabled: false
},
plotOptions: {
series: {
cursor: 'pointer',
point: {
events: {
click: function() {
var index = this.series.name;
var tfs = epochKeys[Math.ceil(this.x)];
window.location.href = url;
return false;
}
}
}
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
},
series: [
{{#each histData as |index|}}
{
name: '{{@key}}',
type: 'spline',
allowPointSelect: true,
{{#each index as |status|}}
{{#if_eq @key "histSuccess"}}
{{/if_eq}}
{{#if_eq @key "histFailure"}}
data: [{{this}}],
{{/if_eq}}
{{/each}}
},
{{/each}}
]
});
现在我做一个AJAX调用来获取数据刷新图。我如何将Handlebars表达式的新值传递给Highcharts代码中使用的变量。 因此,我在AJAX调用中接收到的数据包含Highcharts函数中使用的所有这些表达式的值。
由于代码是动态的,因此我无法手动更新系列值,因为图形上的行数取决于来自后端的数据。
感谢您的任何意见。
非常感谢您的意见。这真的很有帮助。但是xAxis类别呢?我怎样才能取代?任何方式来访问它? –
通常,几乎所有的东西都可以通过API访问。请访问http://api.highcharts.com/highcharts/Axis以访问和操作轴。 –