Subscribe Bookmark RSS Feed

How to copy value colors to row state

markschahl

Community Trekker

Joined:

Jun 18, 2012

I have manually assigned column value colors through column properties. Is there a way to copy the value color scheme to the row states via scripting? I tried the following, but it  didn't work since the get property returns a list:

For Each Row(Color of(row state(row()))= :PolyGrade <<get property("Value Colors"));

1 ACCEPTED SOLUTION

Accepted Solutions
markbailey

Staff

Joined:

Jun 23, 2011

Solution

Try this:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

:age << Set Property( "Value Colors", {12 = -13977687, 13 = -3780931, 14 = -4222943, 15 = -13596966, 16 = -2211217, 17 = -10562780} );

value color property = :age << Get Property( "Value Colors" );

For( i = 1, i <= N Items( value color property ), i++,

value = Arg( value color property[i], 1 );

color = Arg( value color property[i], 2 );

target = dt << Get Rows Where( :age == value );

For( r = 1, r <= N Rows( target ), r++,

Row State( target[r] ) = Color State( color );

);

);

Learn it once, use it forever!
2 REPLIES
markbailey

Staff

Joined:

Jun 23, 2011

Solution

Try this:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

:age << Set Property( "Value Colors", {12 = -13977687, 13 = -3780931, 14 = -4222943, 15 = -13596966, 16 = -2211217, 17 = -10562780} );

value color property = :age << Get Property( "Value Colors" );

For( i = 1, i <= N Items( value color property ), i++,

value = Arg( value color property[i], 1 );

color = Arg( value color property[i], 2 );

target = dt << Get Rows Where( :age == value );

For( r = 1, r <= N Rows( target ), r++,

Row State( target[r] ) = Color State( color );

);

);

Learn it once, use it forever!
markschahl

Community Trekker

Joined:

Jun 18, 2012

Thanks, Mark. That worked. I did not know about the Arg() function.

I also found out that once Value Colors column property is set, this will work: dt<<Color or Mark by Column( :ColName )