Highstock上的自定义按钮未启用

Custom buttons on Highstock not enabled

本文关键字:启用 按钮 自定义 Highstock      更新时间:2023-09-26

我正在尝试使用高股票在烛台图表中显示股票价格。图表的数据来自外部源http://www.highcharts.com/samples/data/jsonp.php?filename=new-intraday.json

我创建了许多按钮,但其中一些没有被启用,即使数据在那里或似乎在那里。准确地说,我不能得到3分钟,4分钟按钮启用时,似乎数据是每分钟(我理解按钮秒和月不会工作,因为数据是9天)

我把它放在这里https://jsfiddle.net/amitabhr/e8ee8e02/4/

$(function () {
$.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=new-intraday.json&callback=?', function (data) {
    // create the chart
    $('#container').highcharts('StockChart', {

        title: {
            text: 'AAPL stock price by minute'
        },
        rangeSelector : {
            buttons : [
            {
                type : 'second',
                count : 10,
                text : '10s'
            }, {
                type : 'second',
                count : 30,
                text : '30s'
            },
            {
                type : 'minute',
                count : 1,
                text : '1m'
            },
            {
                type : 'minute',
                count : 3,
                text : '3m'
            },
            {
                type : 'minute',
                count : 4,
                text : '4m'
            },
            {
                type : 'minute',
                count : 5,
                text : '5m'
            },
            {
                type : 'minute',
                count : 10,
                text : '10m'
            },
            {
                type : 'minute',
                count : 15,
                text : '15m'
            },
            {
                type : 'minute',
                count : 30,
                text : '30m'
            },
            {
                type : 'hour',
                count : 1,
                text : '1h'
            },
            {
                type : 'hour',
                count : 6,
                text : '6h'
            },{
                type : 'hour',
                count : 12,
                text : '12h'
            },
             {
                type : 'day',
                count : 1,
                text : '1D'
            },{
                type : 'day',
                count : 2,
                text : '2D'
            },{
                type: 'month',
                count: 1,
                text: '1m'
            }, 
            {
                type: 'month',
                count: 3,
                text: '3m'
            }, {
                type: 'ytd',
                text: 'YTD'
            }, {
                type: 'year',
                count: 1,
                text: '1y'
            }, {
                type : 'all',
                count : 1,
                text : 'All'
            }],
            selected : 1,
            inputEnabled : false
        },
        series : [{
            name : 'AAPL',
            type: 'candlestick',
            data : data,
            tooltip: {
                valueDecimals: 2
            }
        }]
    });
});

});

我检查了数据源,下面是时间的第一个和最后三个读数(毫秒转换为UTC)

thoct 06 2011 08:00:00
2011年10月6日星期四08:01:00
2011年10月6日星期四08:02:00

Fri Oct 14 2011 15:57:00
星期五Oct 14 2011 15:58:00
2011年10月14日星期五15:59:00

我们可以看到数据是每分钟可用的,所以我不知道为什么我不能得到2分钟,3分钟按钮启用。

可以通过选项设置最小范围和启用所有按钮。例如:http://jsfiddle.net/e8ee8e02/5/

xAxis:{
            minRange: 10 * 60 * 1000
},
rangeSelector : {
            allButtonsEnabled:true
}