简体   繁体   English

将Highstock缩放按钮定位在<div>

[英]Positioning Highstock Zoom Buttons outside the chart area within a <div>

I have read the configuration options on Highstock charts but couldn't find anything concerning the position of the Zoom Buttons outside the chart area or using own buttons for this purpose. 我已经阅读了Highstock图表上的配置选项,但是找不到关于图表区域之外的“缩放”按钮的位置或为此目的使用自己的按钮的任何信息。

I guess I have to use the .rangeSelector.buttons in the chart object, but I can't figure it out. 我想我必须在chart对象中使用.rangeSelector.buttons ,但我无法弄清楚。 If somebody has tried something similar I would be very glad if you could share your approach with me. 如果有人尝试过类似的方法,那么如果您能与我分享您的方法,我将非常高兴。

The best would be if I could use the zoom functions with these own Bootstrap buttons: 最好的办法是,我可以将缩放功能与以下自带的Bootstrap按钮配合使用:

<div style="width: 100%; display: inline-block;"> 
   <button href="#" type="button" class="btn btn-xs btn-outline btn-primary active">12h</button>
   <button href="#" type="button" class="btn btn-xs btn-outline btn-primary">2d</button>
   <button href="#" type="button" class="btn btn-xs btn-outline btn-primary">1w</button>
   <button href="#" type="button" class="btn btn-xs btn-outline btn-primary">1m</button>
   <button href="#" type="button" class="btn btn-xs btn-outline btn-primary">All</button>
</div>

Add events to buttons which will set extremes (see Axis.setExtremes ) in the navigator x axis (optionally, you can set data grouping Axis.setDataGrouping() . 将事件添加到将在导航器x轴中设置极限值的按钮(请参阅Axis.setExtremes )(可选,您可以设置数据分组Axis.setDataGrouping())

$('#all').on('click', function() {
  var chart = Highcharts.charts[0];
  chart.xAxis[0].setExtremes(chart.xAxis[1].min, chart.xAxis[1].max);
});

$('#20d').on('click', function() {
  var chart = Highcharts.charts[0],
    max = chart.xAxis[0].max,
    interval = 3600 * 1000 * 24 * 20;

  chart.xAxis[0].setExtremes(max - interval, max);
});

example: http://jsfiddle.net/gyrv1qxp/1/ 示例: http//jsfiddle.net/gyrv1qxp/1/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM