9

I have an example here from the solution of @krasten 7. In this I would like some vertical spacing between the checkboxes. Any ideas?

prjs = {prj1, prj2, prj3} = RandomReal[#, 100] & /@ {1, 2, 3};

Manipulate[ListPlot[prjs[[projectNo]], Joined -> True], {{projectNo, {1}}, Range[Length@prjs], ControlType -> CheckboxBar,Appearance -> "Vertical", ControlPlacement -> Right }]

In addition to it, I am also looking for more control options like checkbox size or relative postions. Appreciate your time. Thanks.

enter image description here

Alexey Popkov
  • 61,809
  • 7
  • 149
  • 368
Rupesh
  • 887
  • 5
  • 10

3 Answers3

11

You can wrap CheckboxBar with Style using the option DefaultOptions to modify the Spacings option of Grid objects:

ClearAll[addVerticalSpace]
addVerticalSpace[vs_: .3] := 
 Style[#, DefaultOptions -> {Grid -> {Spacings -> {Automatic, vs}}}] &

Examples:

cbb = CheckboxBar[{1}, Range[4], Appearance -> "Vertical"];

Row[{cbb, addVerticalSpace[] @ cbb, addVerticalSpace[0] @ cbb, addVerticalSpace[1] @ cbb, addVerticalSpace[2] @ cbb}, Spacer[20]]

enter image description here

prjs = RandomReal[#, 100] & /@ {1, 2, 3};

addVerticalSpace[2] @ Manipulate[ListPlot[prjs[[projectNo]], Joined -> True], {{projectNo, {1}}, Range[Length@prjs], ControlType -> CheckboxBar, Appearance -> "Vertical", ControlPlacement -> Right}]

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896
6
prjs = {prj1, prj2, prj3} =
   RandomReal[#, 100] & /@ {1, 2, 3};

To widen the spacing of the checkboxes, you can use multi-row labels with the extra rows empty.

Manipulate[
 ListPlot[prjs[[projectNo]],
  Joined -> True],
 {{projectNo, {1}, "Project\nNumber"},
  (# -> StringForm["``\n\n\n", #]) & /@
   Range[Length@prjs],
  ControlType -> CheckboxBar,
  Appearance -> "Vertical",
  ControlPlacement -> Right}]

enter image description here

Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198
5

You can also wrap labels with Pane and use the option ImageSize to control the vertical span of labels:

ClearAll[paneWrap]
paneWrap[vSize_: 20] := Map[# -> Pane[#, Alignment -> Center, 
   BaselinePosition -> Baseline, ImageSize -> {Automatic, vSize}] &]

Examples:

prjs = RandomReal[#, 100] & /@ {1, 2, 3};

Row[{CheckboxBar[{1}, Range[Length @ prjs], Appearance -> "Vertical"], CheckboxBar[{1}, paneWrap[] @ Range[Length @ prjs], Appearance -> "Vertical"], CheckboxBar[{1}, paneWrap[30] @ Range[Length @ prjs], Appearance -> "Vertical"]}, Spacer[20]]

enter image description here

Manipulate[ListPlot[prjs[[projectNo]], Joined -> True], 
 {{projectNo, {1}}, paneWrap[75] @ Range[Length @ prjs],
   ControlType -> CheckboxBar, Appearance -> "Vertical", ControlPlacement -> Right}]

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896