2017-03-07 48 views
0

我有一個服務隨時間改變每分鐘的歐元數據,我使用highstocks繪製分鐘燭臺,但它只顯示最後一個蠟燭和以前的蠟燭正在消失。它的工作原理,如果我使用當前時間(毫秒)爲OHLC屬性,但我想用分鐘時間從服務器Highchart/Highstock OHLC沒有顯示以前的燭臺和實時數據

this.options = { 
     chart: { 
      width: 1200 , 
      height:800, 
      type: 'candlestick' 
     }, 

     title: { text : 'dynamic data example'}, 
     xAxis: { 
      type: 'datetime', 
      dateTimeLabelFormats : { 
       hour: '%I %p', 
       minute: '%I:%M %p' 
      } 
     }, 
     yAxis: { 
      title: { 
       text: 'Value' 
      }, 
      plotLines: [{ 
       value: 0, 
       width: 1, 
       color: '#808080' 
      }] 
     }, 
     plotOptions: { 
      line: { 
       dataLabels: { 
        enabled: true 
       }, 
       enableMouseTracking: false 
      } 
     }, 
     rangeSelector: { 
      selected: 1 
     }, 
     dataGrouping: { 
      units: [ 
       ['minute', [1]], [ 
       'hour', [1, 2, 3, 4, 6]] 
      ] 
     }, 
     series: [{ 
      name: 'Random data', 
      type: 'candlestick', 
      data: (function() { 
       // generate an array of random data 
       var data:any = [], 
        time = (new Date()).getTime(), 
        i:any; 

       for (i = -5; i <= 0; i++) { 
        data.push([ 
         time + i * 60000, 
         Math.random()*100, 
         Math.random()*100, 
         Math.random()*100, 
         Math.random()*100 
        ]); 
       } 
       return data; 
      })()} 

      ] 
    }; 
    this.connection = this.socketService.getMessages().subscribe(data => { 
     this.data = data; 

     this.chart.series[0].addPoint([ 
      this.data.time, 
      this.data.open, 
      this.data.high, 
      this.data.low, 
      this.data.close, 
     ], true, true); 

    }) 
+0

唯一有效的時間戳是以毫秒爲單位的時間戳 - 如果要使用分鐘數,那麼在將其用於圖表之前,需要將它們轉換爲毫秒。 – morganfree

回答

0

取出真選項解決了問題來了。

this.chart.series [0] .addPoint([this.data.time,this.data.open,this.data.high,this.data.low,this.data.close,],真實,真正);