Subscribe Bookmark RSS Feed

How to create a legend in Graph Builder which preserves row state coloring?

markschahl

Community Trekker

Joined:

Jun 18, 2012

I'm working on an asset performance analysis using multiple datasets. I've created custom colors (from ColorBrewer: Color Advice for Maps) for each asset and used the (anonymized) script below to set the Row State Color. It's a nice color scheme that fits my specific needs. The problem is that the Make Row Legend in the various platforms and Coloring schemes in Graph Builder will only allow selection of specific color schemes (JMP default, or 'Custom'). Also, all of the assets may not be in each of the datasets that I am analyzing.

Is there a way to create a legend or custom color scheme that preserves my scripted color scheme in Graph Builder?

For Each Row(

Color Of( Row State( Row() ) ) = Match( :Asset,

  "aaa", RGB Color( 255, 217, 47 ),

  "bbb", RGB Color( 222, 45, 38 ),

  "ccc", RGB Color( 35, 139, 69 ),

  "ddd", RGB Color( 116, 196, 118 ),

  "eee", RGB Color( 186, 228, 179 ),

  "fff", RGB Color( 178, 24, 43 ),

  "ggg", RGB Color( 8, 81, 156 ),

  "hhh", RGB Color( 107, 174, 214 ),

  "iii", RGB Color( 106, 61, 154 ),

  "jjj", RGB Color( 202, 178, 214 )

)

);

4754_RowState Color.PNG

I found a similar, previous, unanswered discussion here: https://communities.sas.com/message/101026#101026

1 ACCEPTED SOLUTION

Accepted Solutions
XanGregg

Staff

Joined:

Jun 23, 2011

Solution

Hi Mark,

Graph Builder is not yet noticing when the data table color is suitable for the overlay coloring variable. That is, it would need to check that all the rows with "aaa" have the same color and no other rows have that color. Possible, but not there yet.

There are a couple alternatives though. One is to use a Value Color property, which tells Graph Builder that the colors are connected to values instead of rows. Here's a script for that:

Column("Asset") << Set Property(

  "Value Colors",

  {"aaa" = RGB Color( 255, 217, 47 ),

  "bbb" = RGB Color( 222, 45, 38 ),

  "ccc" = RGB Color( 35, 139, 69 ),

  "ddd" = RGB Color( 116, 196, 118 ),

  "eee" = RGB Color( 186, 228, 179 ),

  "fff" = RGB Color( 178, 24, 43 ),

  "ggg" = RGB Color( 8, 81, 156 ),

  "hhh" = RGB Color( 107, 174, 214 ),

  "iii" = RGB Color( 106, 61, 154 ),

  "jjj" = RGB Color( 202, 178, 214 )

  }

);

The other way, which may make more sense if you want to use the same colors elsewhere is to create a custom color theme in Preferences and make it the default. You may notice that some of the built-in color themes are from Color Brewer.

Finally, the second problem "all of the assets may not be in each of the data sets that I am analyzing" is a different issue. One work-around to get a non-existent data value to show up in a legend is to add it to the data set with a missing data value or 0 Freq value.

3 REPLIES
XanGregg

Staff

Joined:

Jun 23, 2011

Solution

Hi Mark,

Graph Builder is not yet noticing when the data table color is suitable for the overlay coloring variable. That is, it would need to check that all the rows with "aaa" have the same color and no other rows have that color. Possible, but not there yet.

There are a couple alternatives though. One is to use a Value Color property, which tells Graph Builder that the colors are connected to values instead of rows. Here's a script for that:

Column("Asset") << Set Property(

  "Value Colors",

  {"aaa" = RGB Color( 255, 217, 47 ),

  "bbb" = RGB Color( 222, 45, 38 ),

  "ccc" = RGB Color( 35, 139, 69 ),

  "ddd" = RGB Color( 116, 196, 118 ),

  "eee" = RGB Color( 186, 228, 179 ),

  "fff" = RGB Color( 178, 24, 43 ),

  "ggg" = RGB Color( 8, 81, 156 ),

  "hhh" = RGB Color( 107, 174, 214 ),

  "iii" = RGB Color( 106, 61, 154 ),

  "jjj" = RGB Color( 202, 178, 214 )

  }

);

The other way, which may make more sense if you want to use the same colors elsewhere is to create a custom color theme in Preferences and make it the default. You may notice that some of the built-in color themes are from Color Brewer.

Finally, the second problem "all of the assets may not be in each of the data sets that I am analyzing" is a different issue. One work-around to get a non-existent data value to show up in a legend is to add it to the data set with a missing data value or 0 Freq value.

markschahl

Community Trekker

Joined:

Jun 18, 2012

Xan: That worked great! Thanks. I'm a scripting newbie- it will take some years to learn the vast lexicon of JSL...

XanGregg

Staff

Joined:

Jun 23, 2011

Glad to hear it! I should have added that the Value Colors property can be set in the Column Info dialog. I only did it through scripting because you already had a script.