Hi,
I'm trying to read the JSON data returned from HTTP GET of a url and using this data to populate my Line chart. But its throwing error 'Uncaught TypeError: Cannot read property 'ui5' of undefined' in the line containing 'new sap.viz.ui5.data.FlattenedDataset'. I dont know whats the mistake.
My code:
var oModel = new sap.ui.model.json.JSONModel();
oModel.loadData(url);
sap.ui.getCore().setModel(oModel);
var dataset = new sap.viz.ui5.data.FlattenedDataset({
dimensions : [
{
axis : 1,
name : 'Timestamp',
value : "{timestamp}"
}
],
measures : [
{
group : 1,
name : 'Power (in KW.h)',
value : '{power}'
},
{
group: 2,
name : 'No of Plugs',
value : '{numberOfPlugs}'
}
],
data : {
path : "/_embedded/overallPowers"
}
});
var line = new sap.viz.ui5.DualLine({
id : "dualline",
width : "100%",
height : "400px",
title : {
visible : true,
text : 'Power Utilisation'
},
xAxis : {
title : {
visible : true
}
},
yAxis : {
title : {
visible : true
}
},
dataset : dataset
});
line.setModel(oModel);
line.placeAt("content");
</script>
</head>
<body id="content" class="sapUiBody">
</body>
</html>
input JSON data which is returned from url:
{
"_embedded" : {
"overallPowers" : [ {
"timestamp" : 456,
"power" : 5.0,
"numberOfPlugs" : 555,
"_links" : {
"self" : {
"href" : "http://localhost:8096/overallPowers/456"
},
"overallPower" : {
"href" : "http://localhost:8096/overallPowers/456"
}
}
}, {
"timestamp" : 678,
"power" : 8.0,
"numberOfPlugs" : 98,
"_links" : {
"self" : {
"href" : "http://localhost:8096/overallPowers/678"
},
"overallPower" : {
"href" : "http://localhost:8096/overallPowers/678"
}
}
}, {
"timestamp" : 123,
"power" : 5.768,
"numberOfPlugs" : 6,
"_links" : {
"self" : {
"href" : "http://localhost:8096/overallPowers/123"
},
"overallPower" : {
"href" : "http://localhost:8096/overallPowers/123"
}
}
} ]
},
"_links" : {
"self" : {
"href" : "http://localhost:8096/overallPowers"
},
"profile" : {
"href" : "http://localhost:8096/profile/overallPowers"
},
"search" : {
"href" : "http://localhost:8096/overallPowers/search"
}
}
}