Hi all,
I wrote some code and it is working fine. But i think and i believe that i should change my code because of the security issues.
In this program, I'm calling odata with js but the problem is everybody can see my odata link when i call it from javascript and they can easily do what they want. Because of that I'm thinking to do it with another way but how?
Here is my javascript file:
____________vertical_sample.js_____________________________________________
var uri = "service.xsodata"; // local proxy for cross-domain access
// create OData model from URL
var o = new sap.ui.model.odata.ODataModel(uri, true);
o.read("/myView?$select=DAY,QUANTITY&$format=json", null, null, true, fSuccess, null);
//var oModel = new sap.ui.model.json.JSONModel(o.results);
function fSuccess(oEvent){
var oModel = new sap.ui.model.json.JSONModel(oEvent);
// A Dataset defines how the model data is mapped to the chart
var oDataset = new sap.viz.ui5.data.FlattenedDataset({
// a Bar Chart requires exactly one dimension (x-axis)
dimensions : [ {
axis : 1, // must be one for the x-axis, 2 for y-axis
name : 'DAY',
value : "{DAY}"
}
],
// it can show multiple measures, each results in a new set of bars in a new color
measures : [
// measure 1
{
name : 'QUANTITY', // 'name' is used as label in the Legend
value : '{QUANTITY}'// 'value' defines the binding for the displayed value
} ],
// 'data' is used to bind the whole data collection that is to be displayed in the chart
data : {
path : "/results"
}
});
// create a VizContainer
var oVizContainer = new sap.viz.ui5.VizContainer({
'uiConfig' : {
'layout' : 'vertical',
'enableMorphing' : false
},
'width': '100%',
//'height': '100%'
});
// attach the model to the chart and display it
oVizContainer.setVizData(oDataset)
oVizContainer.setModel(oModel);
// set feeds
var aobjHour = new sap.viz.ui5.vizcontainer.common.feeds.AnalysisObject({
uid : dimension,
name : 'DAY',
type : "Dimension"
}), aobjQuantity = new sap.viz.ui5.vizcontainer.common.feeds.AnalysisObject({
uid : "QUANTITY",
name : "QUANTITY",
type : "Measure"
});
var feedPrimaryValues = new sap.viz.ui5.vizcontainer.common.feeds.FeedItem({
uid : "primaryValues",
type : "Measure",
values : [ aobjQuantity ]
}), feedAxisLabels = new sap.viz.ui5.vizcontainer.common.feeds.FeedItem({
uid : "axisLabels",
type : "Dimension",
values : [ aobjHour ]
});
oVizContainer.addFeed(feedPrimaryValues);
oVizContainer.addFeed(feedAxisLabels);
// oVizContainer.addAnalysisObjectsForPicker(aobjHour);
// oVizContainer.addAnalysisObjectsForPicker(aobjQuantity);
// attach event listener for feedschange
oVizContainer.attachEvent('feedsChanged', function(e) {
// You could add your own logic to handle feedsChanged to set new dataset to vizContainer.
// Reset current data for demo purpose.
oVizContainer.setVizData(new sap.viz.ui5.data.FlattenedDataset({
dimensions : [ {
axis : 1,
name : 'DAY',
value : "{DAY}"
}], measures : [ {
name : 'QUANTITY',
value : '{QUANTITY}'
} ], data : {
path : "/results"
}
}));
oVizContainer.setModel(oModel);
});
oVizContainer.placeAt("vertical_sample");
};
})();