2017-02-23 48 views
0

我目前正在用sensortag嘗試HCP。Sensortag每60秒發送一次溫度至HCP,圖表運行良好。 唯一的問題是,我只看到圖中的最後30個值,因爲時間戳是軸的值。SAP UI5:在x軸上格式化viz.frame圖

  1. 哪些可能有格式化圖表?我可以總結這些數據值,因此X軸顯示每小時f.e. ?
  2. 是否有可能爲每天添加例如第二行。 這意味着,其色1數據點示出了溫度DAY1,顏色2天2等,並且x軸示出了時間從0-24

編輯: 確定,它得到格式從這個代碼的x軸的小時:

Axis : { scale: { fixedRange : true, minValue : "0:00", maxValue : "24:00" } } – 

所以點2仍然是開放的,我如何格式的措施?

measures: [ 
     { 
      name: "C_SENSORTEMP", 
      value: "{C_SENSORTEMP}" 
     }, 
     { 
      name: "C_SENSORHUMIDITY", 
      value: "{C_SENSORHUMIDITY}" 
     } 

    ], 

感謝所有

var vizFrame = new sap.viz.ui5.controls.VizFrame("graph").addStyleClass("sapUiSmallMarginBegin").addStyleClass("sapUiSmallMarginTop"); 
    vizFrame.setWidth("900px"); 
    var oDataset = new sap.viz.ui5.data.FlattenedDataset({ 
     dimensions: [ 
      { 
       name: "Date", 
       value: { 
        path: "G_CREATED", 
        formatter: function(val){ 
         if (val == null) { 
          return "string null"; 
         }       
         var date = new Date(parseInt(val.substr(6,20))); 
         var dd = date.getDate(); 
         var mm = date.getMonth()+1; //January is 0! 
         var yyyy = date.getFullYear(); 
         var hr = date.getHours(); 
         var min = date.getMinutes(); 
         var sec = date.getSeconds(); 
         var fromdate1 = dd+'/'+mm+'/'+yyyy + " " + hr + ":" + min + ":" + sec; 
         return fromdate1; 
        } 
       } 
      } 
     ], 
     measures: [ 
      { 
       name: "C_SENSORTEMP", 
       value: "{C_SENSORTEMP}" 
      }, 
      { 
       name: "C_SENSORHUMIDITY", 
       value: "{C_SENSORHUMIDITY}" 
      } 

     ], 
     data: { 
      path: "/items" 

     } 
    }); 
    vizFrame.setDataset(oDataset); 
    vizFrame.setVizType('line'); 

    vizFrame.setVizProperties({ 
     plotArea: { 
      colorPalette : ["#5cbae6", "#b6d957", "#fac364"] 
      }, 
     categoryAxis: { 
      title: { 
       text: "Date/Time" 
      } 
     }, 
     valueAxis: { 
      title: { 
       text: "temp/humidity" 
      } 
     }, 
     title: { 
      visible:false 
     } 
    }); 

    var feedValueAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({ 
      'uid': "valueAxis", 
      'type': "Measure", 
      'values': ["C_SENSORTEMP", "C_SENSORHUMIDITY"] 
     }), 
     feedCategoryAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({ 
      'uid': "categoryAxis", 
      'type': "Dimension", 
      'values': ["Date"] 
     }); 

    vizFrame.addFeed(feedValueAxis); 
    vizFrame.addFeed(feedCategoryAxis); 

    var container = new sap.m.VBox({ 
     items: [vizFrame], 
     width: "100%", 
     height: "100%", 
     alignItems: "Center" 
    }); 

回答

0

問題得以解決:

1)得到的30點的數據集的限制在omodel

2)X軸刻度值:

yAxis : {scale: { 
           fixedRange : true, 
           minValue : "15", 
           maxValue : "30" 
        }}, 

categor ies/groups for each date in colours:

var oDataset = new sap.viz.ui5.data.FlattenedDataset({ 
dimensions: [{ 
name: "hour",value: "{hour}"}, 
name: "date", value: "{date}"} 
... 
var feedValueAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({ 
      'uid': "valueAxis", 
      'type': "Measure", 
      'values': ["SENSORTEMP"] 
     }), 
     feedCategoryAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({ 
      'uid': "categoryAxis", 
      'type': "Dimension", 
      'values': ["hour"] 
     }), 
     feedColor = new sap.viz.ui5.controls.common.feeds.FeedItem({ 
      "uid": "color", 
      "type": "Dimension", 
      "values": ["date"] 
});