gpt4 book ai didi

javascript - 不在 Durandal 中使用 HighCharts 渲染 VU-meter Gauge 图表

转载 作者:搜寻专家 更新时间:2023-11-01 05:23:56 25 4
gpt4 key购买 nike

我正在尝试在 Durandal 应用程序中添加 Vu-Meter Gauge 图表。我在“viewAttacthed”中保留了 Highcharts Js代码。我的 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 error #17

最佳答案

在 solid gauge demo 的源代码中,他们有以下 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。

关于javascript - 不在 Durandal 中使用 HighCharts 渲染 VU-meter Gauge 图表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17780729/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com