cancel
Showing results for 
Search instead for 
Did you mean: 

microchart data binding NaN

Former Member
0 Kudos

Sorry if I can't share the code in JBin , but the problem is with the data coming from oData with JSON works as expected.

I am binding the data from an oData model, everything works except for the value. If I hover the mouse cursor on the bar is see is displaying NaN.

var oCmprsDataTmpl = new sap.suite.ui.commons.ComparisonData({

     title : "{Title}",

     color : "{Color}",

     value : "{Value}",

});

The entity field is declared as float and in the DB there are valid numbers, it is only not working in the binding.

I have tried many combinations but probably I am missing something that I can't find in the documentation...

Any ideas?

Many thanks!

SO

amy_king
Active Contributor
0 Kudos

I realize this post is old, but I'm facing the same issue with a ComparisonMicrochart getting its data from an OData service. The title (String) and color (String) properties bind without error, but the value (Float) property shows as NaN. Did you discover the solution to this issue?

Cheers.

Accepted Solutions (0)

Answers (1)

Answers (1)

SergioG_TX
Active Contributor
0 Kudos

can you share how you are creating the model and setting the model to the view prior to binding

Former Member
0 Kudos

Hi Sergio,

var sUrl = "https://localhost:8080/test/test.svc";

var oModelZ = new sap.ui.model.odata.ODataModel(sUrl);

this.setModel(oModelZ);

(I am using the conventions in the personslist scenario, adapted to my needs)

Thanks!

Best,

SergioG_TX
Active Contributor
0 Kudos

looks like the model path is needed..

var oModelZ = new sap.ui.model.odata.ODataModel(sUrl,true); // true - json

this.setModel(oModelZ, "path1");

what is the structure of your json response.. you need to have the path... seems like from your binding you have properties of an end point such as:

{

path1:[  { Title: 'T1', Color: 'C1', Value: 'v1' },          

               { Title: 'T2', Color: 'C2', Value: 'v2' } ],

path2: {} // diff object

}

you need to have your path: path1 specified somewhere then your properties Title, Color, Value would display correctly

Former Member
0 Kudos

It is not JSON , it is connecting to oData from the service url.

And all fields come well , it is only the value that is not recognized as a number..

Please note that in all other parts of the application everything works as expected, it is only this microchart....

thanks!

SergioG_TX
Active Contributor
0 Kudos

yes I understand, odata responds with ATOM or JSON. my JSON example was just to showcase the format/structure of the response to bind to the object

Former Member
0 Kudos

Thanks, I didn't understand well but I will try to make this work.