Skip to Content
Technical Articles
Author's profile photo Rakhi Gawde

Gauge Chart in SAP Analytics cloud using R visualization

Introduction

In the age of big  data, visualizing and analyzing trillions of rows in a single chart or KPI is very demanding among customers. Many times as developers we need variety of charts which at one glance gives the correct information, analysis and aesthetics on the dashboard/report.

In SAC stories and analytic applications apart from readily provided charts and graphs we can also design variety of other charts using R visualization feature.

Gauge chart is very nice example for showing whether data values fall within an acceptable range or not. We can set the maximum value, the range maximums, and can display ranges in different colors to quickly assess the required value. This type of chart are very intuitive and also help us to identify problems in important data points or measures.

Below given example is of a customized radial gauge which can be used in SAC story and analytic application.

Steps for creation of Gauge chart in SAC

There are two parts of this demo;

  1. Creation of a simple radial gauge chart
  2. Customization of a gauge chart

I have created demo model which has following type of data;

To start with , after creation of data model on SAC insert a “R Visualization”.

Select the field from the input data for which gauge chart is required.

  • Simple radial gauge chart

To create a basic gauge, On “+Edit script”  add below script to the editor and apply;

With above script chart will display like this;

In this snapshot, the total sales of all equipment’s is shown as KPI on the range of gauge.

  • Customization of a gauge chart with Delta, Threshold and color ranges

This chart can be customized with addition of delta and threshold and more color ranges using below script.

In above figure, assuming example of sales amount of previous year as 80k the delta is displayed and if the target sales to achieve is 95k a indicator (red) is given.

Color segregation in the gauge is displayed to explain  if we want to divide the half, quarter of full range of sales achieved.

Below snapshot is one more example designed to show further more customization.

Conclusion

Referring above given demo, one can easily design a Gauge chart to show as KPI in SAC story or application.

Thank you for reading the blog. Hope you find this helpful:)

 

Assigned Tags

      9 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Rajesh Salvi
      Rajesh Salvi

      This is excellent. As this chart is not provided by SAP, this blog gives us ability to use this chart by codes shared by you. Thank you, Rakhi !

      Author's profile photo Aleksey Salinin
      Aleksey Salinin

      library(plotly)
      library(ggplot2)

      fig <- plot_ly(
      domain = list(x = c(0,100000), y = c(0,100000)),
      value = model$`measure`,
      title = list(text="Title"),
      type = "indicator",
      mode = "gauge+number")
      fig <- fig%>%
      layout(margin = list(l=20,r=30))
      fig

      Author's profile photo Pooja Joglekar
      Pooja Joglekar

      Very well explained! Thank you Rakhi for helping us co-developers with this kind of charts!

      Author's profile photo Kanchan Padhan
      Kanchan Padhan

      Very good informative article.Thanks Rakhi for sharing!

      Author's profile photo Debajyoti Dan
      Debajyoti Dan

      This is pretty good stuff! Thanks for sharing..

      Author's profile photo Adem Baykal
      Adem Baykal

      Thanks for sharing Rakhi, nice blog ?

      And R visualizations also works with live connectivity. You can see an example with SAP BW/4HANA live data here: https://blogs.sap.com/2020/01/08/analyse-your-data-live-with-sap-analytics-cloud-on-sap-bw-on-hana-sap-bw-4hana/

      Cheers

      Adem

       

      Author's profile photo Kuldeep Solanki
      Kuldeep Solanki

      Hi Rakhi Gawde, Thanks a lot for sharing. Not sure if it will be useful but just adding the source code as below:

      library(plotly)
      library(ggplot2)
      fig <- plot_ly(
      domain = list(x = c(0,100000), y = c(0,100000)),
      value =  select model$ 'variable',
      title = list(text="Give your Title"),
      type = "indicator",
      mode = "gauge+number+delta",
      delta= list(reference=80000),
      gauge= list(
      axis = list(range= list(NULL,100000), tickwidth=1, tickcolor="darkblue"),
      bar = list(color= "limegreen"),
      steps = list(
                         list(range = c(0,40000), color="darkslategrey"),
                         list(range =c(40000,80000), color= "cadetblue"),
                         list(range =c(40000,95000), color= "darkturquoise")),
                         threshold=list(
                         line= list(color= "red" , width =4),
                         thickness=0.75,
                         value=95000)))
      fig <- fig%>%
      layout(
      margin =list(l=50,r=50),
      font = list(color="Black", family =" Arial"))
      fig

      Thanks again!

      Best regards,
      Kuldeep Singh Solanki

      Author's profile photo Mario Panzenboeck
      Mario Panzenboeck

      Hello! Thx for providing the code.

       

      I´m trying to get this working on my SAC tenant with no success. The loading indicator is shown for hours with no results.

      I think there might be a problem with the value = parameter. I provided the model name (is the $ symbol needed?) and what should I enter at the placeholder `variable`?

       

      Thanks and best regards,

      Mario

      Author's profile photo Ricardo Silva Volney
      Ricardo Silva Volney

      Hi Rakhi Gawde first thank for you post.

      I would like to know if we can do some changes in the gauge.

      First the number in the top is it possible to show the as % for example 20%, 40%, 60%, 80% 100%? I was able to change the number in the bottom but not in the top.

      I need to change the length of the gauge to 130 for example when I do it I dont have the number in the top the way I want. is it possible to set the length of the gauge to 130 and creates the number in the top with specific point for example 10% 50% 90% 100% and 130%

      Thanks for the help.