【发布时间】:2016-04-15 09:43:19
【问题描述】:
我有一个高图表,其中包含柱形图和样条图。数据集使用车把变量传递。代码是这样的
$(function () {
$('#container').highcharts({
title: {
text: '',
style: {
color: '#cc0000',
fontWeight: 'bold'
}
},
xAxis: {
categories: [{{{xaxisLabel}}}]
},
yAxis: [{ /* Primary yAxis */
labels: {
format: '{value}%',
style: {
color: '#cc0000'
}
},
title: {
text: 'Failure Percentage',
style: {
color: '#cc0000'
}
}
}, { /* Secondary yAxis */
title: {
text: 'Success Percentage',
style: {
color: '#009900'
}
},
max: 100,
labels: {
format: '{value} %',
style: {
color: '#009900'
}
},
opposite: true
}],
labels: {
items: [{
html: '',
style: {
left: '2px',
top: '18px',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'black'
}
}]
},
credits: {
enabled: false
},
series: [{
type: 'column',
name: 'Success',
color: Highcharts.getOptions().colors[2],
yAxis: 1,
tooltip: {
valueSuffix: ' %'
},
data: [{{barSuccess}}]
}, {
type: 'spline',
name: 'Failure',
tooltip: {
valueSuffix: ' %'
},
data: [{{barFailure}}],
marker: {
lineWidth: 3,
lineColor: Highcharts.getOptions().colors[8],
fillColor: 'red'
}
}]
});
});
现在我有另外两个数据集,分别称为 {{toolTipSuccess}} 和 {{toolTipFailure}}。
{{toolTipSuccess}} 进入柱形图,{{toolTipFailure}} 进入样条图。
我希望这两个数据集中的数据作为工具提示出现在各自的图表中。我知道如果我在图中以 (x,y,z) 格式传递数据,可以做到这一点,但我必须做很多代码更改以适应我正在避免的内容。
有没有人知道这个问题的任何回旋处?
变量中的数据属于这种类型:-
{{barSuccess}} = [100, 99, 99, 99 .........]
{{barFailure}} = [ 0, 0, 1, 0.3........]
{{toolTipSuccess}} = [363, 763, 762, 987, ........]
{toolTipFailure}} = [12, 3, 13, 8, .........]
提前致谢
【问题讨论】:
标签: javascript graph highcharts handlebars.js tooltip