Quantcast
Channel: SCN : All Content - SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 6178

How to make UI5 Bar Chart treat string like "20140402" as Date type

$
0
0

Hi Experts:

      I want to create a Bar chart with the X axis is Date type. The data from my model is like "20140321" and the Bar will treat this data as INT on X axis as what I show in the picture. How can I make the Bar to display my data as Date? The following is my code:

==================================================

var oData = { "quarter_info": [{"start_ags":"20140321", "end_ags":"20140603", "start_it":"20140402", "end_it":"20140702"}] };
var oModel = sap.ui.model.json.JSONModel();
oModel.setData(oData);
var oDataset = new sap.viz.ui5.data.FlattenedDataset("chartDataset",{     dimensions : [{axis:1, name:'AGS and IT'}],     measures : [          {name : 'AGS',value : "{start_ags}"},          {name : 'IT',value : '{end_ags}'}      ],         data:{          path : "/quarter_info",          type: new sap.ui.model.type.Date({source:{pattern:"yyyyMMdd"}, pattern:"yyyy-MM-dd"}     )}
});
var oBarChart = new sap.viz.ui5.Bar({width : "80%",height : "400px",dataset : oDataset});
oBarChart.setModel(oModel);   
oBarChart.placeAt("content");        

Viewing all articles
Browse latest Browse all 6178

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>