将盘中选项添加到高点
Adding intraday option to highcharts
希望在下图中添加日内(1天)缩放选项。我想看看如何结合现有的缩放选项来实现这一点的示例-http://jsfiddle.net/cvezpup7/1/
$(function () {
$.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-ohlcv.json&callback=?', function (data) {
// split the data set into ohlc and volume
var ohlc = [],
volume = [],
dataLength = data.length,
// set the allowed units for data grouping
groupingUnits = [[
'week', // unit name
[1] // allowed multiples
], [
'month',
[1, 2, 3, 4, 6]
]],
i = 0;
for (i; i < dataLength; i += 1) {
ohlc.push([
data[i][0], // the date
data[i][1], // open
data[i][2], // high
data[i][3], // low
data[i][4] // close
]);
volume.push([
data[i][0], // the date
data[i][5] // the volume
]);
}
var minOHLC = Math.min.apply(Math, ohlc.map(function(v) { return v[3] > 0 ? v[3] : 99999999 }))
var maxOHLC = Math.max.apply(Math, ohlc.map(function(v) { return v[2]}))
var maxVolume = Math.max.apply(Math, volume.map(function(v) { return v[1]}))
var maxVolumeHeight = maxVolume / (minOHLC / maxOHLC)
// create the chart
$('#container').highcharts('StockChart', {
navigator: {
enabled: false
},
rangeSelector: {
selected: 1,
inputEnabled: false
},
credits: {
enabled: false
},
yAxis: [{
lineWidth: 0
}, {
max: maxVolumeHeight,
offset: 0,
lineWidth: 0,
// gridLineWidth: 0,
labels:
{
enabled: false
}
}],
series: [{
type: 'candlestick',
name: 'AAPL',
data: ohlc,
dataGrouping: {
units: groupingUnits
}
}, {
type: 'column',
name: 'Volume',
data: volume,
yAxis: 1,
dataGrouping: {
units: groupingUnits
}
}]
});
});
});
您需要定义自己的按钮数组:
buttons: [{
type: 'day',
count: 1,
text: '1d'
},{
type: 'month',
count: 1,
text: '1m'
}, {
type: 'month',
count: 3,
text: '3m'
}, {
type: 'month',
count: 6,
text: '6m'
}, {
type: 'ytd',
text: 'YTD'
}, {
type: 'year',
count: 1,
text: '1y'
}, {
type: 'all',
text: 'All'
}]
注意,有了这个数据集,Highstock让你走的最精细的时间是5天。请在此处查看详细信息。
更新的小提琴。
相关文章:
- 正在添加'X'按钮,在文本字段旁边使用javascript
- 如何在映射数组中添加换行符
- 正在将数据主题添加到所有项目
- ZeroClipboard-在复制之前添加到值
- 我可以在json对象中添加一个函数吗
- 将输入字段中的文本提交到我的数据库,同时将其添加到我的列表中
- 正在SharePoint 2013母版页中添加JQuery移动文件
- 如何添加浮动和非浮动,其他
- 添加文字和评论功能更新Div
- 如果使用 lodash 将属性存在于另一个对象中,则向对象添加属性
- 动态地改变“”的URL;添加新项目”;链接使用javascript/jquery
- 在函数中添加数组元素的数值
- 如何将歌曲添加到jPlayer
- 在html Select中添加搜索
- Java脚本时间添加
- FabricJs-限制主对象内添加对象的移动区域
- JQuery添加元素需要在我的js之前再次添加JQuery脚本
- 如何在Google柱状图中动态添加行/列
- 将盘中选项添加到高点
- 将新系列添加到类别高点