on 10-15-2013 4:55 AM
Hello Experts,
I am binding an OData service with a vizchart. I want to show a graph for Temperature vs Time .
The flatten dataset code looks like this
var oDataset = new sap.viz.ui5.data.FlattenedDataset({
dimensions : [ {axis : 1, name : 'Time', value : "{TIMS}" } ],
measures : [ { name : 'Tempareture', value : '{CONTENT }' } ],
data : { path : "/Content" ,
formatter: function(fValue) {
debugger ;
jQuery.sap.require("sap.ui.core.format.DateFormat");
var oDateFormat = sap.ui.core.format.DateFormat.getTimeInstance({pattern: "HH-MM-SS"});
return oDateFormat.format(fValue);
}
}});
The entity 'Content' has a property 'TIMS' of Edm type Edm.Time which contains value like 'PT9H9M22S'.
The formatter is not working correctly which is failing to extract the time value. So in the chart I am getting error 'no value' for the time axis.
Can anyone help me ?
Regards,
Atanu
Hi Atanu,
http://scn.sap.com/community/developer-center/front-end/blog/2013/04/28/working-with-odata-dates
It may help you,
Simon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Simon,
Thanks for the direction.
I solved the problem and the final code will be
var oDataset = new sap.viz.ui5.data.FlattenedDataset({dimensions : [ {axis : 1, | name : 'Time', value :{ path: "TS" , | ||
formatter: function(fValue) { |
var date = new Date(fValue);
var timeinmiliseconds = date.getTime() ;
var timeFormat = sap.ui.core.format.DateFormat.getTimeInstance({pattern: "KK:mm:ss a"});
var TZOffsetMs = new Date(0).getTimezoneOffset()*60*1000;
var timeStr = timeFormat.format(new Date(timeinmiliseconds + TZOffsetMs));
return timeStr ; | ||||
} | ||||
}}], | ||||
measures : [ { name : 'Tempareture', value : '{CONTENT}' } | ], | |||
data : { path : "/Content" } | ||||
}); |
Regards,
atanu
.
User | Count |
---|---|
83 | |
9 | |
9 | |
8 | |
7 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.