嘗試連接圖表的數據,但我沒有顯示except for the empty charts。如何獲得對javaScript視圖的正確綁定或此代碼中的錯誤?下面列出的代碼片段,我也跟着上link的instructionson:如何綁定OData for SAPUI5圖表(sap.viz.ui5.VizContainer)
sap.ui.jsview("zui5_flight.BookingGraph", {
getControllerName : function() {
return null;
},
createContent : function(oController) {
var oModel = new sap.ui.model.json.JSONModel();
oModel.loadData("/salesOrderService.xsjs");
// 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 : 'CONNID',
value : "{CONNID}"
} ],
// it can show multiple measures, each results in a new set of bars in a new color
measures : [
// measure 1
{
name : 'PRICE_ECO', // 'name' is used as label in the Legend
value : '{PRICE_ECO}' // '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 : "/"
}
});
// create a VizContainer
var oVizContainer = new sap.viz.ui5.VizContainer({
'uiConfig' : {
'layout' : 'vertical',
'enableMorphing' : true
},
'width': '100%',
'height': '100%'
});
// attach the model to the chart and display it
oVizContainer.setVizData(oDataset)
oVizContainer.setModel(oModel);
// set feeds
var aobjCustomer = new sap.viz.ui5.controls.common.feeds.AnalysisObject({
uid : "customer_id",
name : "CONNID",
type : "Dimension"
});
var aobjNetSales = new sap.viz.ui5.controls.common.feeds.AnalysisObject({
uid : "netsales_id",
name : "PRICE_ECO",
type : "Measure"
});
var feedPrimaryValues = new sap.viz.ui5.controls.common.feeds.FeedItem({
uid : "primaryValues",
type : "Measure",
values : [ aobjNetSales ]
});
var feedAxisLabels = new sap.viz.ui5.controls.common.feeds.FeedItem({
uid : "axisLabels",
type : "Dimension",
values : [ aobjCustomer ]
});
oVizContainer.addFeed(feedPrimaryValues);
oVizContainer.addFeed(feedAxisLabels);
// 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 : 'CONNID',
value : "{CONNID}"
} ], measures : [ {
name : 'PRICE_ECO',
value : '{PRICE_ECO}'
} ], data : {
path : "/"
}
}));
oVizContainer.setModel(oModel);
});
return oVizContainer;
}
});