简体   繁体   English

highstock图表仅设置xAxis的最大值

[英]highstock chart only set the max value of xAxis

I want to only set the max value of xAxis. 我只想设置xAxis的最大值。 I get this value from session value. 我从会话值获得此值。 I want to display stockchart. 我想展示股票图表。 The selected range of xAxis is set(from session value) and not changing. xAxis的选定范围已设置(根据会话值)且未更改。 How to link the max xAxis value to the rangeSelectorButton and input range selector or and navigator. 如何将最大xAxis值链接到rangeSelectorButton以及输入范围选择器或和导航器。 Click range button or input range or navigator, the max value of xAxis doesn't change. 单击范围按钮或输入范围或导航器,xAxis的最大值不变。

If i use the following code, I have to sent the value of both min and max value. 如果我使用以下代码,则必须发送最小值和最大值的值。

$('#container').highcharts('StockChart', {

  title: {
    text: 'AAPL Stock Price'
  },
  xAxis: {
    events: {
      SetExtremes: function (e) {
        if (e.trigger == "rangeSelectorButton") {
          setTimeout(function () {
            var end = 1293091200000;
            Highcharts.charts[0].xAxis[0].setExtremes(1198681756385, end)
          }, 1);

        }
      },
    }
  },
  series: [{
    name: 'AAPL',
    data: data,
    tooltip: {
      valueDecimals: 2
    }
  }]
});

How can I only set the max value? 如何只设置最大值? The reason why I want this, because I get a date from session value, then I can choose different button range selector to show past week or past 1 month or past 3 month chart. 之所以要这样做,是因为我从会话值中获取了一个日期,因此可以选择其他按钮范围选择器来显示过去一周或过去1个月或过去3个月的图表。

In case you want to set the max value of the extreme (selected range on navigator) without changing the min extreme, you can first retrieve the current extreme and set the same value back: 如果要设置极值的最大值(在导航器上选择的范围)而又不更改极值的极值,则可以先获取当前极值,然后再设置相同的值:

// Assume the chart instance is stored in variable 'chart'
var extremes = chart.xAxis[0].getExtremes();
chart.xAxis[0].setExtremes(extremes.min, yourMaxValue);

First of all setExtremes , not SetExtremes . 首先是setExtremes ,而不是SetExtremes

Second thing, calling setExtremes in setExtremes callback makes infinite loop. 其次,在setExtremes回调中调用setExtremessetExtremes无限循环。

I advice to disable rangeSelector from Highcharts, generate your own HTML buttons, and add click event where you will call chart.xAxis[0].setExtremes(previous_min, your_max_value); 我建议从Highcharts禁用rangeSelector ,生成自己的HTML按钮,并在单击chart.xAxis[0].setExtremes(previous_min, your_max_value);位置添加click事件chart.xAxis[0].setExtremes(previous_min, your_max_value); .

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

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