cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 and VIZ Chart error to load library

Former Member
0 Kudos
Good Day All
I have been struggling to get my chart to appear within a view.
In PieVisual.view.js

var oModel = new sap.ui.model.json.JSONModel({

  riskData : [

  {category: "Category 01", severity: 9, cVulnerable: 15, cPotVulnerable: 32, cSafe: 5, cTotal: 52},           

  {category: "Category 02", severity: 8, cVulnerable: 12, cPotVulnerable: 15, cSafe: 2, cTotal: 29},

  {category: "Category 03", severity: 5, cVulnerable: 32, cPotVulnerable: 32, cSafe: 1, cTotal: 65},

  {category: "Category 04", severity: 6, cVulnerable: 26, cPotVulnerable: 31, cSafe: 5, cTotal: 62},

  {category: "Category 05", severity: 3, cVulnerable: 13, cPotVulnerable: 15, cSafe: 6, cTotal: 34},

  {category: "Category 06", severity: 2, cVulnerable: 9, cPotVulnerable: 15, cSafe: 1, cTotal: 25},

  {category: "Category 07", severity: 7, cVulnerable: 5, cPotVulnerable: 18, cSafe: 0, cTotal:23}

  ]

  });

  //set up dataset

  var PieChartData = new sap.viz.ui5.data.FlattenedDataset("dataForPie",{

  dimensions : [{

  axis : 1,

  name : 'Category',

  value : "{category}"

  }],

  measures: [{

             group: 1,

             name : 'cTotal',

             value : '{cTotal}'

      },

    {

             group: 2,

             name : 'cSafe',

             value : '{cSafe}'

  }],

  data :{

  path : "/riskData"

  }

  });

  //set up chart

  var PieChart = new sap.viz.ui5.Pie({

  id : "pie",

  width : "80%",

  height : "400px"

  });

  PieChartData.setModel(oModel);

  PieChart.setDataset(PieChartData);

  return new sap.m.Page({

  title: "Pie Chart View",

  content: [PieChart]

  });

This is placed in the createContent function.

In the index.html file I have tried to add libraries such as sap.viz, sap.viz.ui5, sap.ui.table, sap.ui.core which I was hoping would help.

In my app.js file I included jQuery.sap.require("sap.viz.ui5.data"); becuase I was getting the error: Uncaught TypeError: Cannot read property 'ui5' of undefined

On running the application on my Tomcat v7.0 Server at localhost I get the following errors:

2014-11-18 09:43:11 Device API logging initialized - DEVICE sap-ui-core.js:44

2014-11-18 09:43:11 registerResourcePath ('', 'https://openui5.hana.ondemand.com/resources/') -  sap.ui.ModuleSystem sap-ui-core.js:80

2014-11-18 09:43:11 URL prefixes set to: -  sap.ui.ModuleSystem sap-ui-core.js:80

2014-11-18 09:43:11   (default) : https://openui5.hana.ondemand.com/resources/ -  sap.ui.ModuleSystem sap-ui-core.js:80

Failed to load resource: the server responded with a status of 404 (Not Found) https://openui5.hana.ondemand.com/resources/sap/viz/library-preload.json

XMLHttpRequest cannot load https://openui5.hana.ondemand.com/resources/sap/viz/library-preload.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. The response had HTTP status code 404. index.html:1

2014-11-18 09:43:12 failed to preload 'sap.viz.library-preload': NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'https://openui5.hana.ondemand.com/resources/sap/viz/library-preload.json'. -  sap.ui.ModuleSystem sap-ui-core.js:80

Failed to load resource: the server responded with a status of 404 (Not Found) https://openui5.hana.ondemand.com/resources/sap/viz/ui5/library-preload.json

XMLHttpRequest cannot load https://openui5.hana.ondemand.com/resources/sap/viz/ui5/library-preload.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. The response had HTTP status code 404. index.html:1

2014-11-18 09:43:12 failed to preload 'sap.viz.ui5.library-preload': NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'https://openui5.hana.ondemand.com/resources/sap/viz/ui5/library-preload.json'. -  sap.ui.ModuleSystem sap-ui-core.js:80

Failed to load resource: the server responded with a status of 404 (Not Found) https://openui5.hana.ondemand.com/resources/sap/viz/library.js

XMLHttpRequest cannot load https://openui5.hana.ondemand.com/resources/sap/viz/library.js. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. The response had HTTP status code 404. index.html:1

Uncaught Error: failed to load 'sap/viz/library.js' from https://openui5.hana.ondemand.com/resources/sap/viz/library.js: 0 - NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'https://openui5.hana.ondemand.com/resources/sap/viz/library.js'. sap-ui-core.js:149

2014-11-18 09:43:12 registerResourcePath ('views', './views/') -  sap.ui.ModuleSystem sap-ui-core.js:80

Uncaught TypeError: Cannot read property 'ui5' of undefined sap-ui-core.js:147

Failed to load resource: net::ERR_CACHE_MISS http://localhost/DSPresentation/index.html

Any help in this regard will be much appreciated.
I have spent 3 days on this and I cant find any useful suggestions in the forums.

Thanks in advacne

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I have spent 3 days on this and I cant find any useful suggestions in the forums.

fyi, it's never gonna work for you ! You're using openui5 & you know what, the chart libraries aren't part of openui5. They are only available with sapui5. Try bootstrapping with sapui5,

JS Bin - Collaborative JavaScript Debugging</title> <link rel="alternate" type=&q...

Former Member
0 Kudos

Thank you so much.

Tip to everyone else. Make sure not to confuse the two different libraries.
Especially when looking at examples.

Answers (2)

Answers (2)

HariCS23
Contributor
0 Kudos

Hi Sakthivel, I ran into same issue which is trying to refer sap.viz from downloaded run time openui5 framework .

Now i realised those two are different and to refer sapui5 ,we need to use src as


src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js">

   in the boot strap .

(Luckily i stumbled across this thread )

My question is just like i am refering opeui5 libraries from local server. Can i also download sapui5 framework and refer that in the bootstrap for my program ?

like


src="../openui5-sdk/resources/sap-ui-core.js"

The reason i am asking , i am wondering there would some difference on performance on referring resources which are local to server vs remote location (https://sapui5.hana.ondemand.com)

Please advise .

Thanks

Hari

kai2015
Contributor
0 Kudos

I got it to work:

import sap.viz at your index.html:    

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

Then you don't need this: jQuery.sap.require("sap.viz.ui5.data");

But if you want to use the sap. require, do it like that:

jQuery.sap.require("sap.viz.ui5.data.FlattenedDataset");

I hope it helps!