我正嘗試使用highstocks顯示燭臺圖表中股票的股票價格。圖表的數據來自外部來源http://www.highcharts.com/samples/data/jsonp.php?filename=new-intraday.json未啓用Highstock上的自定義按鈕
我創建了一些按鈕,但其中一些按鈕並未啓用,即使數據存在或似乎存在。準確地說,我看不到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毫秒)的時間
星期四2011年10月6日8時00分零零秒
星期四2011年10月6日08:01: 00
週四2011年10月6日8點02分00秒
週五2011年10月14日15時57分00秒
週五2011年10月14日15:58:00
週五2011年10月14日15點59分00秒
As我們可以看到每分鐘都有數據,因此我不確定爲什麼我無法啓用2分鐘,3分鐘按鈕。
您可以設置minrange並通過選項啓用allbuttons。例如:http://jsfiddle.net/e8ee8e02/5/ –
謝謝@Sebastian Bochan。這非常有幫助。如果你能把這個作爲答案,我可以接受它作爲答案。謝謝。 – Amitabh