如何将次轴添加到高股价图中
How do I add secondary axis to highstock charts?
当谈到javascript时,我仍然非常兴奋。我需要一些帮助,将一个类似收入的辅助轴添加到一个高库存图表中,该图表也使用$.getJSON(JSONP)来获取一个json文件来填充数据。
请查看此处的JSFiddle示例。这是要玩的示例数据集。最后,以Highcharts中的次轴为例。
$(function () {
var seriesOptions = [],
seriesCounter = 0,
names = ['MSFT', 'AAPL', 'GOOG'],
// 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'
}]
},
yAxis: {
floor: 0
},
plotOptions: {
series: {
compare: 'value'
}
},
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: data
};
// 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();
}
});
});
});
非常感谢任何帮助和解释(以便我学习)。我仍在努力学习如何将jsonp和图表联系在一起,尤其是多个系列的数据和json文件。
这样写:
yAxis: [{
labels: { ... },
title: { ... },
...
},
{
labels: { ... },
title: { ... },
...
}]
http://jsfiddle.net/5eem7a2a/1/
相关文章:
- 在可触摸的高光上添加compnant
- 将图表动态添加到组合高图表中
- 在图例项目之间添加额外空间的高图表
- 如何从高股价图中提取数据
- 显示额外月份的高股价图
- 高图表 - 是否可以为每个系列添加工具提示格式化程序
- 日期未在高股价图的 x 轴上正确显示
- 高图表添加新系列不起作用
- 将高图表添加到传单弹出窗口
- 在单击按钮时向高图表添加选项
- 高图表 - 添加其他导出选项而不会丢失默认选项
- 同时移动两个相关高股价图表的手柄
- 从CSV将高图表添加到地图框弹出窗口
- 如何将次轴添加到高股价图中
- 高图表添加数据使用文本框
- 根据图表上的每个系列的缩放级别动态地向高图添加平均值
- 为气泡图/高图添加自定义工具提示
- 谷歌电子表格JSON的高股价图表
- 高图:添加点而不连接系列
- 向饼状高图添加数据表