我有一个在Angular中实现的Highstock.js图表。我正在尝试为用户提供多个缩放选项,默认情况下选择其中一个。我定义按钮,指示默认情况下应该选择哪个按钮(通过提供按钮的索引),但是仅当配置JS对象中不存在“ xAxis”字段时,该按钮才起作用。
$scope.chartConfig = {
"useHighStocks":true,
/*
the line below prevents the rangeSelector from selecting
a custom time frame option in spite of correct configuration
*/
"xAxis": {},
"options":{
"rangeSelector": {
"allButtonsEnabled": true,
"enabled": true,
"selected": 1,
"buttons": [{
"type": 'month',
"count": 1,
"text": '1m'
}, {
"type": 'month',
"count": 3,
"text": '3m'
}]
}
...
如何在图表中同时具有xAxis和自定义缩放选择?
这是小提琴,请尝试注释/取消注释xAxis行并运行代码。
小提琴:http : //jsfiddle.net/11zqLnh3/
您是否尝试过将xAxis对象放入选项中?看起来在这种情况下可以正常工作:
"options":{
"xAxis": {}, // try commenting this line
"rangeSelector": {
"allButtonsEnabled": true,
"enabled": true,
"selected": 1,
"buttons": [{
"type": 'month',
"count": 1,
"text": '1m'
}, {
"type": 'month',
"count": 3,
"text": '3m'
}]
},
},
看这个例子:http : //jsfiddle.net/11zqLnh3/1/
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句