4

我正在尝试在 Durandal 应用程序中添加 Vu-Meter Gauge 图表。我将高图表 Js 代码保留在“viewAttacted”中。我的 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;
});

但我看不到仪表图。请让我知道我到底在哪里遗漏了什么或做错了什么。

脚本抛出:

未捕获的 Highcharts 错误 #17

4

2 回答 2

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。

于 2014-05-30T18:14:33.157 回答
0

错误 17 表示“请求的系列类型不存在”,可能您没有附加 highcharts-more.js 文件。

http://www.highcharts.com/errors/17

于 2013-07-22T10:55:07.147 回答