Skip to Content
avatar image
Former Member

Line chart binding issue with sample oData flight service

Hi all,

I am trying to create a line chart using the sample flight service. The chart is giving error

[50017] - Invalid data binding. The same chart works fine if used with local data that i create. So its a issue with binding with the odata response from the gw service.

Please find my code below

var model = new sap.ui.model.odata.v2.ODataModel("/sap/opu/odata/iwfnd/RMTSAMPLEFLIGHT");
model.read("/FlightCollection",{
success:function(odata){
 jmodel = new sap.ui.model.json.JSONModel(odata);
     a = new sap.viz.ui5.data.FlattenedDataset({
	 dimensions:[
	    new sap.viz.ui5.data.DimensionDefinition({
		name:"currency",
		value:"{CURRENCY}"
	})
	],
	measures:[
		new	sap.viz.ui5.data.MeasureDefinition({
		name: "price",
		value:"{PRICE}"
	}),
// new	sap.viz.ui5.data.MeasureDefinition({
//name: "seatsf",
// value:"{SEATSMAX_F}"
// 	}),
// 		new	sap.viz.ui5.data.MeasureDefinition({
// 		name: "seatsb",
// value:"{SEATSMAX_B}"
// 	})
		],
	data:{
		"path":"/results"
 		}
		});
		line.setModel(jmodel);
		line.setDataset(a);
		},
failed:function(fail){
	alert("failed- " +fail)
		}
	});

********* here is the line chart **********
	var line = new sap.viz.ui5.controls.VizFrame("lineid",{
			vizType:"line",
			height: "80%",
			width: "80%",
			
				feeds:[
										new sap.viz.ui5.controls.common.feeds.FeedItem({
										uid: "categoryAxis",
	//	uid:"axisLabels",
	type:"Dimension",
	values:["currency"]
	}),
	new sap.viz.ui5.controls.common.feeds.FeedItem({
	 uid:"valueAxis",
	//	uid:"primaryValues",
	type:"Measure",
	values:["price"]
	})
		]
		});

 
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Mar 21, 2017 at 08:24 AM

    Got the answer. I was making a mistake of instantiating feeds within the line controller itself.

    The feeds along with the dataset aggregation should be instantiated in the odata.read methods success callback and then added to the line control by using addfeed & setDataset methods.

    Add comment
    10|10000 characters needed characters exceeded