Showing results for 
Search instead for 
Did you mean: 

Getting Top N values in Chart to display in Text Box - Analytics Applications / Analytics Designer

0 Kudos

Hi all, I am currently having trouble figuring out the various functions that can be used with the widgets provided in SAC (e.g. applyText for text box). Is there a centralised location/ documentation for the functions that can be used for each widget?

Relating to my main question, I am trying to get the Top N values from my bar chart to display in a text box. The bar chart currently shows top 5, and I would like to get the specific names to show up in the text box on the right. Tutorials I have found mainly focus on the usage of Input Text, which is not what I want, since this is just for display. Please point me in the right direction for this.

Accepted Solutions (1)

Accepted Solutions (1)


The code below will pick up the dimension descriptions from a chart and write them to a text box - it's not perfect but
hopefully a starting point.


I've put the code in the button

var DIMKEY =Chart_1.getDimensions(Feed.CategoryAxis)[0];
var selections = Chart_1.getDataSource().getDataSelections();

for (var i=0;i<selections.length;i++)
{var member = Chart_1.getDataSource().getResultMember(DIMKEY,selections[i]);
 var DESC = member.description;
 var TEXT_VALUE =Text.getPlainText();
0 Kudos

Hi! I forgot to mention that the bar graph (Chart_14) I have uses two data sources. This solution worked great for my chart that only used one data source (Chart_12), but fails to render for the chart that has two data sources.

I did a bit of debugging and noticed that the DIMKEY is no longer a nice string, but a dictionary. Please see the image below:

When I tried to use that as a string, it throws up an error saying that it is not a valid string:

var DIMKEY = Chart_12.getDimensions(Feed.CategoryAxis)[0];
var selections = Chart_12.getDataSource().getDataSelections();
for (var i=0; i<selections.length; i++){
	var member = Chart_12.getDataSource().getResultMember(DIMKEY,selections[i]);
	var DESC = member.description;
	var TEXT_VALUE =Text_15.getPlainText();
	Text_15.applyText(TEXT_VALUE + "\n" + DESC);
var other_key = "@{["t.C.C2Z5Y9G9ZEGLEOLAMXCI8TN6YO:C2Z5Y9G9ZEGLEOLAMXCI8TN6YO","assignee"]}";
var selections2 = Chart_14.getDataSource().getDataSelections();

Is there a way for me to change the dimension name to fit my use case?

0 Kudos

Hi, I managed to resolve it! Improper string may not have been the issue. I made some tweaks to your code and it managed to work with the blended chart.

Thank you so much for your help 🙂

Putting it below in case anyone needs reference in the future:

var DIMKEY = Chart_14.getDimensions(Feed.CategoryAxis)[0];
var selections = Chart_14.getDataSource().getDataSelections();

for (var i=0; i< selections.length; i++){
	var DESC = Chart_14.getDataSource().getDataSelections()[i][DIMKEY];
	var TEXT_VALUE =Text_15.getPlainText();
	Text_15.applyText(TEXT_VALUE + "\n" + DESC);

Answers (1)

Answers (1)

0 Kudos

You find the API documentation under "SAP Analytics Cloud Analytics Designer API Reference Guide" at

In your case you might want to use DataSource#getResultSet to find the right values and DataSource#getResultMember to get the member description.

0 Kudos

Thanks for pointing me in the right direction for the SAC Analytics Designer documentation! 🙂