on 02-26-2013 4:35 PM
Hi All,
We have a bar graph in SAPUI5; We have a xsjs service which provides the data in json format.
I am trying to populate the model using code snippet as below:
var oModel = new sap.ui.model.json.JSONModel({
businessData :[// "http://172.22.0.168:8000/osmosis/Sales_json.xsjs?sorg='INSO'&div='02'&dchan='IN'"]
});
Bar graph does not show up. Is there a way to make the Bar Graph consume the data from this xsjs service?
Regards,
Ganga
Hi Ganga,
It's a bit hard to be certain from your question, but try..
var oModel = new sap.ui.model.json.JSONModel("http://172.22.0.168:8000/osmosis/Sales_json.xsjs?sorg='INSO'&div='02'&dchan='IN'");
Cheers
Graham Robbo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thanks for the reply. The code we are trying is:
var oModel = new sap.ui.model.json.JSONModel(
{
businessData : ["http://172.22.0.168:8000/osmosis/Sales_json.xsjs?sorg='INSO'&div='04'&dchan='IN'"]
});
var oDataset = new sap.viz.ui5.data.FlattenedDataset({
dimensions : [
{
axis : 1, // must be one for the x-axis, 2 for y-axis
name : 'material',
value : "{material}"
}
, {
axis : 1,
name : 'year',
value : "{year}"
}, {
axis : 2,
name : 'quantity',
value : "{quantity}"
}
],
measures : [
{
name : 'quantity', // 'name' is used as label in the Legend
value : '{v}' // 'value' defines the binding for the displayed value
}
],
data : {
path : "/businessData"
}
});
var oBarChart = new sap.viz.ui5.Bar({
width : "80%",
height : "400px",
plotArea : {
//'colorPalette' : d3.scale.category20().range()
},
title : {
visible : true,
text : 'Profit and Revenue By Country'
},
dataset : oDataset
});
oBarChart.setModel(oModel);
oBarChart.placeAt("content","first");
That's a bit of surprise as it works for me.
All I did was change your JSON payload to make it valid and changed the definition of the model to be like this...
var oModel = new sap.ui.model.json.JSONModel('mytest.json');
The mytest.json payload looks like this...
{
"businessData" : [
{
"material" : "Material 1",
"year" : 2010,
"quantity" : 12600
}, {
"material" : "Material 2",
"year" : 2010,
"quantity" : 1500
}, {
"material" : "Material 1",
"year" : 2011,
"quantity" : 13600
}, {
"material" : "Material 2",
"year" : 2011,
"quantity" : 18600
}, {
"material" : "Material 1",
"year" : 2012,
"quantity" : 12600
}, {
"material" : "Material 2",
"year" : 2012,
"quantity" : 12600
}
]
}
Cheers
Graham Robbo
Hi Graham,
we are using
var oModel = new sap.ui.model.json.JSONModel("http://<host>:<port>/osmosis/Sales_json.xsjs?sorg='INSO'&div='02'&dchan='IN'");
oModel is not giving the data available in the url. The values shows as below.
oModel as EventProvider sap.ui.model.json.JSONModel
And oModel.getData() as [object Object]
Thanks,
Srinivas
Hi Srinivas,
perhaps the JSON payload is invalid? I use http://json.parser.online.fr/ to validate my JSON.
Cheers
Graham
This message was moderated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ganga,
how the json responce looks like?
Best Regards
Konstantin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
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.