Table Row Labels Adjustment

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Table Row Labels Adjustment

Jon Peck
RonOz asked for a way to automatically adjust the width of the row labels column in a table so that, within limits, the label would not wrap but would be as small as possible.

I thought that others might find this functionality useful.  I wrote a custom function for SPSSINC MODIFY TABLES that does this.  Here is an example using the employee data.sav file shipped with Statistics that adjusts the innermost row label.

* make a label long enough to wrap.
ADD VALUE LABELS jobcat 1 "a long multiword label that will wrap".

CTABLES
  /TABLE gender > jobcat [COUNT F40.0] BY minority
  /CATEGORIES VARIABLES=gender ORDER=A KEY=VALUE EMPTY=INCLUDE TOTAL=YES POSITION=AFTER
  /CATEGORIES VARIABLES=jobcat minority ORDER=A KEY=VALUE EMPTY=INCLUDE MISSING=EXCLUDE.

SPSSINC MODIFY TABLES subtype="customtable"
SELECT=-1 DIMENSION= ROWS PROCESS = PRECEDING 
/STYLES  APPLYTO=LABELS
CUSTOMFUNCTION="textsize.setNonwrappingLabelWidth"

There are options to specify minimum and maximum widths and the right margin and to override the font and style.  Details are in the .py file.

MODIFY TABLES can be installed from the Extensions menu.  If you want the the textsize.py custom module, send me a direct email, and I will send it to you.



--
Jon K Peck
[hidden email]

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Table Row Labels Adjustment

Jon Peck
p.s. I forgot to mention that this sizing custom module only works on Windows as it is necessary to use some Windows-specific functions to calculate the size of the text strings.

On Sun, Dec 16, 2018 at 9:15 AM Jon Peck <[hidden email]> wrote:
RonOz asked for a way to automatically adjust the width of the row labels column in a table so that, within limits, the label would not wrap but would be as small as possible.

I thought that others might find this functionality useful.  I wrote a custom function for SPSSINC MODIFY TABLES that does this.  Here is an example using the employee data.sav file shipped with Statistics that adjusts the innermost row label.

* make a label long enough to wrap.
ADD VALUE LABELS jobcat 1 "a long multiword label that will wrap".

CTABLES
  /TABLE gender > jobcat [COUNT F40.0] BY minority
  /CATEGORIES VARIABLES=gender ORDER=A KEY=VALUE EMPTY=INCLUDE TOTAL=YES POSITION=AFTER
  /CATEGORIES VARIABLES=jobcat minority ORDER=A KEY=VALUE EMPTY=INCLUDE MISSING=EXCLUDE.

SPSSINC MODIFY TABLES subtype="customtable"
SELECT=-1 DIMENSION= ROWS PROCESS = PRECEDING 
/STYLES  APPLYTO=LABELS
CUSTOMFUNCTION="textsize.setNonwrappingLabelWidth"

There are options to specify minimum and maximum widths and the right margin and to override the font and style.  Details are in the .py file.

MODIFY TABLES can be installed from the Extensions menu.  If you want the the textsize.py custom module, send me a direct email, and I will send it to you.



--
Jon K Peck
[hidden email]



--
Jon K Peck
[hidden email]

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD