First try in SDK, building a bar chart with benchmark option in D3

Gaining experience with the SDK. I thought about addressing something that is being asked by customers quite often. A benchmark chart. Usually Dashboards of larger organizations show a lot of benchmark results. Often with the restriction that the other results are anonymous.

The idea is to have a bar chart where ‘your’ results are shown in a different color than the rest. Additionally the results are being sorted to have the highest result on the left. Until now I had to go back to BW or HANA to set up a way that I could separate them. But it is much easier to do this in Design Studio without the need to go back to a source system.

Using this kind of graph shows how your results are doing in comparison to others. Not only do you get a ranking, but you also have an indication how far ahead/behind you are in relation to the others.

the resulting graph looks like this :

As you can see the results of our entity are ranked third and is at some distance from second place, but also far ahead of third place.

To be able to use the graph to set benchmarks at runtime i’ve introduced two methods to set and get the current benchmark.

You can set these properties at design time in the properties view of the component, but also in script so you can change them at runtime based on user interaction.

You can now set the benchmark using for example a global variable that holds the value of the department that is tied to the user looking at the dashboard

In the actual code to build the graph there is an evaulation of value in the x-axis to the benchmark property. If they are equal the css class .benchmarkbar_benchmark is used. Otherwise the class .benchmarkbar_other is added.

D3 is a very powerful JavaScript library that has been added to the SDK. if you look at sites such as D3js.org you see many examples of what you can do. Also you will find tutorials on how to build these graphs.

the D3 library can be found in the SDK as wel as in the OPENUI5 / SAPUI5 library that resides on HANA. I think it is really worthwile to go through the tutorials.I especially recommend the tutorials on youtube by d3vienno, he uploaded 20 tutorials that help you to get started on the subject : http://www.youtube.com/user/d3Vienno

For people who want to see the entire code I’ve listed the code in all the files in a separate document