Skip to Content
0
Mar 20, 2015 at 11:55 AM

Problem in Loading Chart

42 Views

Hi experts,

I am facing problem in loading charts when I use navigation between pages. I do neither get any error.

Below is the code that I have used.

I have included the required lib in index.html

data-sap-ui-libs="sap.m, sap.viz"

in my 1st view

return new sap.m.Page ({
  title: "Title",
  content: [
           new sap.m.Button({
    text : "Button", press : [oController.onButton, oController],
  }) ]
});

in the controller

onButton : function() {
  var app = sap.ui.getCore().byId("idApp");
  var page = sap.ui.view({id:"idpage2", viewName:"testchart.nextPage", type:sap.ui.core.mvc.ViewType.JS});
  app.addPage(page);
  app.to("idpage2");
  },

nextPage view

var oPage = new sap.m.Page({
  title: "Title",
  });

  var oModel = new sap.ui.model.json.JSONModel({
  businessData : [
  {Country :"Canada",revenue:410.87,profit:-141.25, population:34789000},
  {Country :"China",revenue:338.29,profit:133.82, population:1339724852},
  {Country :"France",revenue:487.66,profit:348.76, population:65350000},
  {Country :"Germany",revenue:470.23,profit:217.29, population:81799600},
  {Country :"India",revenue:170.93,profit:117.00, population:1210193422},
  {Country :"United States",revenue:905.08,profit:609.16, population:313490000}
  ]
  });


  var oDataset = new sap.viz.ui5.data.FlattenedDataset({
  dimensions : [ 
  { axis : 1, name : 'Country', value : "{Country}" } 
  ],
  measures : [ 
  { name : 'Profit' ,  value : '{profit}' },
  { name : 'Revenue', value : '{revenue}' } 
  ],
  data : { path : "/businessData" }
  });


  var oBarChart = new sap.viz.ui5.Bar({
  width : "80%", height : "400px",
  title : { visible : true, text : 'Profit and Revenue By Country'},
  dataset : oDataset
  });


  oBarChart.setModel(oModel);
  oPage.addContent(oBarChart);

and there is no event in the controller

the problem is that the page is coming blank.

If I load only the page with other contents like button, panel, it is loading, but not with charts.

Please guide me.

Thank you,