cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
txnelson
Super User

How do you get the color of a specific cell in a data table using JSL?

I have a script where I need to determine what color specific cells in a data table have been set to.  I can find messages that can be sent to specific cells to color them, but my searches have failed to see anyway to retrieve the color of specific cells.  Does anyone have a solution?

Jim
2 REPLIES 2
ms
Super User (Alumni) ms
Super User (Alumni)

Re: How do you get the color of a specific cell in a data table using JSL?

The cell colors seem to be stored in a hierarchical list but I, too, can't find an easy way to access them.

Try something like this:

//Example table

dt=New Table( "test",

  Add Rows( 5 ),

  New Column( "X",

  Numeric,

  Continuous,

  Format( "Best", 12 ),

  Color Cells( {{38, {1}}, {9, {2}}, {74, {3, 4}}} ),

  Set Selected,

  Set Values( [1, 2, 3, 4, 5] )

  )

);

// Define function

get_cell_color = Function( {col, r},

  s = col << get script;

     //Locate argument "Color Cells" in column script

  For( i = 1, i <= N Arg( s ), i++,

  If( Head Name( Arg( s, i ) ) == "Color Cells",

  p = i;

  Break();

  )

  );

     //Identify the sublist that contains the color of row r

  L = Arg( Arg( s, p ), 1 );

  For( i = 1, N Items( L ), i++,

  If( N Row( Loc( L[i][2], r ) ) == 1,

  color = L[i][1];

  Break();

  )

  );

  color;

);

// Run function to find color of row four in first column

cellcolor = get_cell_color( Column( 1 ), 4 );

// Confirm..

New Window( "color",

  Spacer Box( size( 200, 100 ), color( cellcolor ) )

);


txnelson
Super User

Re: How do you get the color of a specific cell in a data table using JSL?

Thanks for the quick response. Function works well. I had to modify it a bit to handle the case where the all of the cells in a column have been set to the same color.

Jim Nelson,

Sent from Windows Mail

Jim