cancel
Showing results for 
Search instead for 
Did you mean: 

is it possible to set css by script in sap design studio?

former_member241445
Participant
0 Kudos

As follow picture,I want the bubble color auto changed by data,eg:if the value>0 the color red,else the color blue.

I've use follow code to get data,but if I follow like this,all of bubble will red or blue,not like I want just value less than 0.

How can I do to make it realize?Just the value greater than 0 will red,and others blue?

var va=DS_1.getMembers("ZCQYF", 2000);
va.forEach(function(element, index) {
var v=DS_1.getData("OVERDUE_TTL", {"ZCQYF": element.internalKey}).value;
LISTBOX_1.addItem(v+"", v+"");
 if(v>=0){
   LISTBOX_1.setCSSClass("red");
 }else if(v<0){
  LISTBOX_1.setCSSClass("blue");
 }
});

Accepted Solutions (0)

Answers (2)

Answers (2)

MustafaBensan
Active Contributor
0 Kudos

Hi Jing,

The scenario you have documented is confusing. It appears that you would like to dynamically change the bubble colours in a geo map via CSS yet your script example is changing the CSS applied to a List Box. Can you clarify?

Regards,

Mustafa.

former_member241445
Participant
0 Kudos

Hi Mustafa.

It's my typo.the code I was used for a List Box,but if I change the LISTBOX_1.setCSSClass("red") to GEOMAP_1.setCSSClass("red") ,it's same mean.So it isn't matter to my result.

And follow code was I changed ,if I add element by html,it's ok.I hope this can help some new ideas.

Thanks.

Jing

var result="";
var va=DS_1.getMembers("ZCQYF", 2000);
va.forEach(function(element, index) {
var v=DS_1.getData("OVERDUE_TTL", {"ZCQYF": element.internalKey}).value;
var style="";
 if(v>=0){
result=result+"<span>"+v+"</span><br/>";
 }else{
result=result+"<span class='red'>"+v+"</span><br/>";
 }
});
FORMATTEDTEXTVIEW_1.setHtmlText(result);
MustafaBensan
Active Contributor
0 Kudos

Hi Jing,

I don't see how your script code above relates to the Geo Map component. It looks like the script is generating formatted HTML text which is completely unrelated to the Geo Map. Also, it would be helpful if you provided the custom CSS file you are using where you have defined the "red" CSS class.

Regards,

Mustafa.

former_member241445
Participant
0 Kudos

Hi Mustafa.

Maybe I'm not express clear.

I want to realize a situation in geomap that when the data less than 0,then "red",else "blue".Above code is just an eg to show that is a way to realize color according to data.But if I use geomap,I can't use html,so whether there have another way to realize color changed by data?

Thanks .

Jing

martinguixe89
Explorer
0 Kudos

Hi Jing,

Did you archieve this? i need to do same, change color of bubble according to measure value.

Thanks,

Martin

Vidhya
Active Participant
0 Kudos

Hi jing,

How are you using Geo or Leaflet Map??

If leaflet map, Please refer the below URL,

https://blogs.sap.com/2016/01/07/design-studio-16-sdk-leaflet-maps-for-more-mapping-goodness/

Regards,

Vidhya.C

former_member241445
Participant
0 Kudos

Hi Vidhya.

I'm use Geo Map.I've view the url that you recommend ,but I still like use Geo Map,which bubble maybe more suit to my situation.

Thanks.

Jing