cancel
Showing results for 
Search instead for 
Did you mean: 

Datetime Formatter Problem in Vizchart

former_member184867
Active Contributor
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos
former_member184867
Active Contributor
0 Kudos

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

.

Answers (0)