cancel
Showing results for 
Search instead for 
Did you mean: 

Butterfly Chart in SAC

catchers9999
Explorer
0 Kudos

Hi I need to create a butterfly chart in SAC. From what I read it may need a custom widget, but again not much out there to explain how. The other issue I may have is that the data will come from a HANA LIVE connection. I am not a java programmer and this also limits my ability. Any help/guidance would be appreciated.

catchers9999
Explorer
0 Kudos

This is an example:

yogananda
Product and Topic Expert
Product and Topic Expert
0 Kudos

Unfortunately, creating a butterfly chart in SAP Analytics Cloud requires a custom widget. You would need to have some basic understanding of Java programming in order to create such a widget. If you do not have the technical expertise to create this widget, you may be able to find a developer who can help you create it. Alternatively, you may be able to use a third-party visualization library to create the chart, such as D3.js or Chart.js. As for the data source, you should be able to connect HANA Live to SAP Analytics Cloud. However, it may be necessary to use a different data source if the data needed for the chart is not available in HANA Live.

Accepted Solutions (0)

Answers (5)

Answers (5)

catchers9999
Explorer

Thanks James, I think we need to make a number of steps to allow for the R Visualization so will look into it.

JBARLOW
Contributor
0 Kudos

In theory... It should work out the box as such.

I just use the built in r server shipped with sac

JBARLOW
Contributor

A fairly rubbish (in my opinion) workaround would be to create the effect of a single chart by using 2 separate charts.

Using the BestRunJuice sample model

1. The right hand (green) chart contains Sales Manager & Price Fixed
Chart titles, axis lines & labels are hidden

2. The left chart contains Sales Manager and a calculated measure using the formula:
0-["BestRunJuice_SampleModel":Original_Sales_Price] so the bars run to the left of the Y axis

This relies on the charts using the same dimension and same sort order etc.

catchers9999
Explorer
0 Kudos

Yes, we can do that, but as you say rubbish and also gets Minus figures on one side unless you multiply by -1 - again all crude.

JBARLOW
Contributor
0 Kudos

Hi Andrew,

This was bugging me, so I had a stab at using R script to create something,

Using the BestRunJuice sample model I've managed to create the chart below,
needs some work on the formatting and numeric format.

Input data is below

R Script is:

library(ggplot2)

# Load data
data <- BestRunJuice_SampleModel

# Create the plot
ggplot(data, aes(x=`Sales Manager`)) +
  geom_col(aes(y = `Gross Margin`, fill = 'Gross Margin'), width = 0.4, position = "identity") +
  geom_col(aes(y = -Discount, fill = "Discount"), width = 0.4, position = "identity") +
  scale_fill_manual(name = "Measures", values = c("Discount" = "orange", "Gross Margin" = "skyblue")) +
  coord_flip() +
  labs(title = "Butterfly Chart", y = "", x = "") +
  theme_minimal() +
  theme(plot.title = element_text(face = "bold", size = 28, hjust = 0.5),
        axis.text.x = element_blank(),
        axis.text.y = element_text(size = 16, face = "bold"),
        axis.ticks.x = element_blank(),
        axis.line.x = element_line(size = 1.5, colour = "black"),
        axis.text.x.bottom = element_text(size = 14),
        legend.position = "bottom",
        legend.title = element_blank(),
        legend.text = element_text(size = 16))
       

N1kh1l
Active Contributor
0 Kudos

Cool. GGPLOT2 is a great library which can be used.

catchers9999
Explorer
0 Kudos

Thanks James, yes I thought about R script as well. I was just hoping for a simpler option, but I think SAC still has a way to go.

JBARLOW
Contributor
0 Kudos

Hi Andrew,

The only thing I can think of would be to use an R scripted chart - this blog provides an example
https://blogs.sap.com/2020/06/08/r-visualizations-in-sap-analytics-cloud/

I must admit I've had a go using the Best Run Juice sample data -- I can't get it to work, mind you I have minimal clue when it comes to R script 😞