highcharts stockchart 1m和3m未启用

时间:2014-12-29 11:19:50

标签: highcharts

请参阅http://jsfiddle.net/a6h6cLnt/。 '3m'和'1m'按钮不起作用。较早的数据集较小,没有一个缩放按钮正常工作。较小数据集的网址为http://jsfiddle.net/a6h6cLnt/1/

$(function () {
    var seriesOptions = [],
        seriesCounter = 0,
        names = ['MSFT'],
        // create the chart when all data is loaded
        createChart = function () {

            $('#container').highcharts('StockChart', {

                rangeSelector: {
                    selected: 4
                },

                yAxis: {
                    labels: {
                        formatter: function () {
                            return (this.value > 0 ? ' + ' : '') + this.value + '%';
                        }
                    },
                    plotLines: [{
                        value: 0,
                        width: 2,
                        color: 'silver'
                    }]
                },

                plotOptions: {
                    series: {
                        compare: 'percent'
                    }
                },

                tooltip: {
                    pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> ({point.change}%)<br/>',
                    valueDecimals: 2
                },

                series: seriesOptions
            });
        };

    $.each(names, function (i, name) {

        $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=' + name.toLowerCase() + '-c.json&callback=?',    function (data) {

            seriesOptions[i] = {
                name: name,
                data: [[1346371200000,12],[1348963200000,13],[1354233600000,4],[1377907200000,12],[1380499200000,13],[1385769600000,4],[1406764800000,1],[1409443200000,15],[1412035200000,20],[1414713600000,2],[1417305600000,4]]
            };

            // As we're loading the data asynchronously, we don't know what order it will arrive. So
            // we keep a counter and create the chart when all the data is loaded.
            seriesCounter += 1;

            if (seriesCounter === names.length) {
                createChart();
            }
        });
    });
});
<script src="http://code.highcharts.com/stock/highstock.js"></script>
<script src="http://code.highcharts.com/stock/modules/exporting.js"></script>


<div id="container" style="height: 400px; min-width: 310px"></div>

'1m'和'3m'缩放按钮/链接不起作用。 请让我知道如何启用它们或让它们工作

此致 约瑟夫

1 个答案:

答案 0 :(得分:0)

您需要设置minRange参数以定义最小缩放。

示例:http://jsfiddle.net/a6h6cLnt/2/