2013-04-23 59 views
0

我試圖使用HighStock顯示一些數據。除了我無法顯示少於6天的事實之外,一切都很好。 正如您在下面看到的,我選擇了3天作爲範圍,但圖表仍顯示6列。 此外,如果我試圖在4月18日之後的任何一天選擇「來自」價值,則價值將被忽略,並且會考慮2013年4月18日。最後,如果我試圖捏住導航器,我會有相同的行爲,我不能顯示少於6天。爲什麼我不能顯示少於6天?

我查看了HighStock API Reference,但是我找不到任何有關6是默認天數/值顯示的事實的參考。

enter image description here

下面我彙報我的JS:

$('#container').highcharts('StockChart', { 
     chart: { 
     backgroundColor: '#E5E7EB' 
    }, 
     rangeSelector: { 
     buttons: [{ 
      type: 'day', 
      count: 3, 
      text: '3d' 
     }, { 
      type: 'week', 
      count: 1, 
      text: '1w' 
     }, { 
      type: 'month', 
      count: 1, 
      text: '1m' 
     }, { 
      type: 'month', 
       count: 3, 
       text: '3m' 
      }, { 
       type: 'month', 
       count: 6, 
       text: '6m' 
      }, { 
       type: 'ytd', 
      count: 1, 
       text: 'Ytd' 
     },{ 
       type: 'year', 
      count: 1, 
       text: '1y' 
     }, { 
      type: 'all', 
      text: 'All' 
     }], 
     selected: 1 
     }, 

     xAxis: { 
    type: 'datetime', 
    minTickInterval: 24 * 3600 * 1000 // daily 
    }, 

    yAxis: { 
     offset: 8, 
     title: { 
      text: yAxisTitle 
     }, 
     labels: { 
     align:'right' 
    } 
    }, 

     plotOptions: { 
      column: { 
     stacking: 'normal', 
     dataLabels: { 
     enabled: false, 
     color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white' 
     } 
    } 
     }, 
     series: seriesOptions 
    }); 

我錯過了什麼?我如何顯示少於6天/值?

謝謝你,祝你有美好的一天。

回答

1

您應該設置minRange http://api.highcharts.com/highstock#xAxis.minRange

在您的例子:3 * 24 * 3600 * 1000(這意味着3天)

+0

感謝您幫助。 minRange解決了這個問題。 你知道我可以如何顯示昨天作爲xAxis(而不是今天)的最新日子嗎?在我的應用程序中,最新的可用數據是在當前數據前一天註冊的數據,現在我擁有最新的一個空列,我不想顯示。謝謝。 – macsig 2013-04-28 10:28:10

+0

您可以使用setExtremes()函數來定義您自己的範圍。那麼只有你需要的是設置第一個/最後一個「範圍egdes」。 http://stackoverflow.com/questions/16260053/highchart-with-scaled-images-in-column-bars – 2013-04-29 13:00:00