我正在尝试在Durandal应用程序中添加Vu-Meter Gauge图表。我将高图表Js代码保存在“viewAttacthed”中。我的Js代码如下所示:
define(['services/logger'], function (logger, highcharts) {
//#region Internal Methods
function activate() {
logger.log('Reports View Activated', null, 'Resources', true);
return true;
}
//#endregion
function viewAttached(view) {
$('#ufcGaugeChart', view).highcharts({
chart: { type: 'gauge' },
title: null,
pane: [{
startAngle: -90,
endAngle: 90,
center: ['50%', '67%'],
size: 175
}],
yAxis: [{
min: 0,
max: 100000,
minorTickPosition: 'inside',
tickPosition: 'inside',
labels: {
rotation: 'auto',
distance: 20
},
plotBands: [{
from: 0,
to: 40000,
color: '#679b4f',
innerRadius: '100%',
outerRadius: '105%'
}, {
from: 40000,
to: 70000,
color: '#d5995c',
innerRadius: '100%',
outerRadius: '105%'
}, {
from: 70000,
to: 100000,
color: '#ab4641',
innerRadius: '100%',
outerRadius: '105%'
}],
pane: 0,
title: {
// need to change the style.
text: 'Gauge',
y: 0
}
}],
plotOptions: {
gauge: {
dataLabels: { enabled: true },
dial: { radius: '100%' }
}
},
series: [{
data: [54036],
yAxis: 0
}]
},
// Let the music play
function (chart) {
setInterval(function () {
alert("hi");
var left = chart.series[0].points[0],
right = chart.series[1].points[0],
leftVal,
inc = (Math.random() - 0.5) * 3;
leftVal = left.y + inc;
rightVal = leftVal + inc / 3;
if (leftVal < -20 || leftVal > 6) {
leftVal = left.y - inc;
}
if (rightVal < -20 || rightVal > 6) {
rightVal = leftVal;
}
left.update(leftVal, false);
right.update(rightVal, false);
chart.redraw();
}, 500);
});
};
var vm = {
activate: activate,
title: 'Reports View',
paymentDate: '06/09/2013',
paymentAmount: '$120,098.66',
paymentCheck: '235',
viewAttached: viewAttached
};
return vm;
});
但是我无法看到仪表图表。请让我知道我错过了哪里或做错了。
脚本抛出:
Uncaught Highcharts错误#17
答案 0 :(得分:7)
在实体仪表演示的源代码中,它们具有以下js文件:
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/highcharts-more.js"></script>
<script src="http://code.highcharts.com/modules/solid-gauge.src.js"></script>
捆绑和缩小那些为我清除了错误17。
答案 1 :(得分:0)
错误17表示“请求的系列类型不存在”,可能您没有附加highcharts-more.js文件。