Skip to Content

how to bind chart dynamically?

Oct 23, 2017 at 07:19 AM


avatar image

I am representing a table data via a vizframe chart. When I am calling the chart for the first time its working fine but if after that I am entering data into table and then again displaying the chart its showing a "invalid data binding" error. chrt.png. Even if I dont enter data second time and just pressing the button show chart then also its showing the same error!!! Can anybody please help? Thanks!

here is my code in controler


 var model = new sap.ui.model.json.JSONModel();
 var oData = sap.ui.getCore().getModel("jModel").getData();

var oVizFrame = this.getView().byId("idcolumn");

var oDataset = new{
dimensions : [{
name : 'type',
value : "{type}"}],

measures : [{
name : 'hours',
value : '{hours}'} ],

data : {
path : "/"
//set viz properties
plotArea: {
colorPalette : d3.scale.category20().range()

var feedValueAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({
'uid': "valueAxis",
'type': "Measure",
'values': ["hours"]
feedCategoryAxis = new sap.viz.ui5.controls.common.feeds.FeedItem({
'uid': "categoryAxis",
'type': "Dimension",
'values': ["type"]


chrt.png (108.4 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Arjun Biswas Oct 23, 2017 at 08:55 AM

Maybe I get your error. The thing is that the data is getting bound to the chart more than once, which is causing redundancies and hence you are getting that error. I would suggest you to bind the data to the chart from the model and on submit change the model data and instead of binding the data to the chart again, just refresh the model. So in this way, only once the data binding happens.


Show 1 Share
10 |10000 characters needed characters left characters exceeded

thanks for the response! it has been solved when i changed the code like this:

	var model=newsap.ui.model.json.JSONModel();//sap.ui.getCore().getModel("jModel").getData();
	var aData=sap.ui.getCore().getModel("jModel").getData();
var oChart = this.getView().byId("idcolumn");
	oChart.getModel().setProperty("/", aData);