Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

SAPUI5 and VIZ Chart error to load library

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
Tags:
Former Member
Former Member replied

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="application/jso…

2 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question