Skip to Content
Author's profile photo Former Member

SAP Fiori / UI5 and HANA Data visualization

Hello Everyone,

I recently had to create some demo’s to visualize data form a HANA XS system. The team created some

odata (xsodata) services for me and “the asks” was to have a UI5/Fiori App to display the data via different charts.

There are lot of example and posts out there but I could not find answers to some of the issue I was facing hints this post.

Here the resulting application which we built using UI5.


The app basically displays sales information from one odata service in different ways.

Here are some of the challenge I was facing during prototyping:

1. CORS (

Since I started my development locally using JSbin I kept running into the CORS issue.

One simple work around is to use chrome and start
via the window->run or dos prompt using the parameters like:

chrome.exe –disable-web-security or

chrome.exe   –disable-web-security  –allow-file-access-from-files

to allow local file access.

Note: Make sure you close all chrome.exe task/sessions before starting chrome with the command line parameters.

You should see a message in the chrome header like:


Here an example of an SAPUI5 chart which you can run the code locally with a local json source

(,output) or use the attached zip files or Github url listed at the end of the post.

If the browser security is set properly and the json data file is I the right path you should see the following

picture after executing the jsbin example.


2. Differences between xml and json model from a odata service.

One of the challenges I ran into was that there are different ways to bind the data from odata service using xml or
json format.  The normal odata service call will invoke $metadata and basically requires a working real odata service vs
json you can work with offline json files like in my jsbin examples or attatched zip file/github.

In order to bind odata you just need to used the entity url path.


           path: “/Opportunities“, //  xsodata nativ binding  (xml)

           path: “/d/results”, // Json xsodata binding for the same service

Note: The json model binding for xsodata service always uses the path “/d/results”.

Here an example of a bubble chart using odata (xml) model.


Code in JSBin

JSbin with the local json data is a great place to start “fiddling” with the data and the chart code but eventually you

want to move to odata to take advantage of all the odata functionality especially once the charts and data get more complex.

3. Which chart library to use?

SAP UI5 offers viz and makit and there several other libraries out there. I just focused on makit and viz and ended up using viz.

Here the SAP demo app for the makit library.

Here the SAP demos for the viz library

Here the code for a json makit Pie chart example Example:


There was no particular reason why I ended up with viz over the makit library other than there seems more
information on sap.viz out there. There also other chart libraries available like d3.js, c3.js and pivot.js which

can be used see alternative libraries section below for examples.

4. Layouts

One of the challenges was to layout 6 charts (see 1st picture)  on one page and make sure its visible on an ipad. Some of the charts do
not seem to display when just adding them to a page like with .placeAt and some do show right away. A simple work around seems

to be to add the chart first to a panel and than place it on the page. Sometimes changing the height to pixel vs % worked too.

Example of using panel to place charts on a page.


Starting with a Panel layout to build the prototype worked great. We use matrix layout later to be a more

EXAMPLE of Panel layout

var oPanel1 = new
sap.ui.commons.Panel({width: “100%”,height: “100%”});     


oPanel1.setTitle(new sap.ui.core.Title({text: “Sale at Risk by Region”}));


The key was to add the some of the charts/elements to a cell before adding the layout to the page.

EXAMPLE of a Matrix layout

var oLayout = new sap.ui.commons.layout.MatrixLayout(“layout”, { width : “100%”,       columns : 2 }); 

             var oCell = new sap.ui.commons.layout.MatrixLayoutCell({id : ‘Cell-0-0’,lSpan : 2 });



var oCell10 = new sap.ui.commons.layout.MatrixLayoutCell({id : ‘Cell-1-0’,colSpan : 1 });




Result of adding a Table to matrix layout cell.


Here a jsbin play ground of different charts and layouts:

5. Aggregation of data.

Once I got more comfortable with the charts and the data model. I tried create the page and charts based on

the requirements. It took me a while till I realized that the charts never showed the sum of any of the values

e.g. Sales by region instead it show just the last customers of the region for example.

Example of a chart without aggregated and with aggregated data values form the same service.


It took a while to find the solution since the issue it was in the service it self and just partiality in the code.

The HANA xsodata service had a Vidal parameter missing called “aggregates always;” without that parameter

the service would not a aggregate values.

here the xsodata service In Hana Studio with the right parameter.


Below a Odata selection url to check the aggregation of values: format: <service/Entity url>?$parameter&$otherodataparameter


Result without the aggregate parameter in HANA service

<d:CUSTOMER_DESC m:type=”Edm.String”>ABC Motorsports</d:CUSTOMER_DESC>


With the parameter it returns the sum/total of the value for  ABC Motorsports

<d:CUSTOMER_DESC m:type=”Edm.String”>ABC Motorsports</d:CUSTOMER_DESC>

<d:OPPORTUNITY_VALUE m:type=”Edm.Double”>6837050</d:OPPORTUNITY_VALUE>

The other issue was that like in odata url also in UI5 we have to define/select the fields for the aggregration.


       var oDataset = new{

        dimensions: [{

            axis: 1,

            name: ‘REGION’,

            value: ‘{REGION}’


        measures: [{

            name: ‘VALUE’,

            value: “{OPPORTUNITY_AMOUNT}”

        data: {

         path: “/Opportunities”,




Otherwise the data would not be aggregated even if the service is setup right.

Here the Jsbin code example:


6. Filters and Sorters.

In order to filter and sort the data in the same way you can do this via odata url parameters

( you need to add sorter and filters to the dataset.

Filter code example: (

data: {

         path: “/Opportunities”,

          filters: new sap.ui.model.Filter(‘VERSION’,sap.ui.model.FilterOperator.EQ,’ACTUAL’),

          sorter : new sap.ui.model.Sorter(“REGION”,true)

           parameters: {select: ‘CUSTOMER_ID,REGION,CUSTOMER_DESC,OPPORTUNITY_AMOUNT’}        }  

7. Alternative chart libraries

As mentioned before there are a lot of other chart JavaScript libraries out there which you can use instead of makit or viz.

D3 is a very popular one there are ui5 examples on sdn using d3 to render charts and gauges.

(Gauges in SAPUI5)

Here some other (code) example of charting libraries.

C3 –,js,output

highcharts –,live

google charts –
The picture shows a d3 chart of the odata HANA service which I used in all my examples. You can find the code
for the above chart here.,output

8. Adding you code to a Fiori Launchpad.

Here some quick infos on how to add you ui5 app to a Fiori Launchpad which was very useful.

Note: You can upload your developed code as a BSP page using se80 or the report/UI5/UI5_REPOSITORY_LOAD
… more information here


There is of course a lot more to know about charts and ui5 data visualization but this will give you a good start and focus on the data, and charts
functionality and hopefully you avoid some of the pitfalls.

The code for all the examples is available in the jsbin, github and in the attached zip file.

Please leave a comment and let me know if you have questions or contact me via twitter
@markusvankempen or email me






Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Masayuki Sekihara
      Masayuki Sekihara

      This is a great document. Chart example and sample codes are helpful.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thank you Masayuki much appreciated.


      Author's profile photo Joao Sousa
      Joao Sousa

      Great document. Just one small note, D3.js isn't exactly a charting library, you can build charts using it but you will be building the SVG yourself. Manipulating the height of the bars, the colors, implementing animations,

      All the other libraries use d3.js to create the SVG charts, even sap.viz. 

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hi Joao

      thanks for you comment. I just had a couple of days to build the demos and zeroed in on a couple of tools. Obviously you know a lot more about D3.js - Data-Driven Documents, SVG and charting libraries (The 15 Best JavaScript Charting Libraries)

      Thank you for your insides and clarification always appreciated.


      Author's profile photo Former Member
      Former Member

      This is really a great document I have seen in our scn. Give you my esteem.