Subscribe Bookmark RSS Feed

Automatically resizing graph boxes

Hi,

I have several Graph Boxes in an assortment of different tabs within the same overall window. Any of them can be resized manually by the user dragging the borders and/or the corners in the usual way. However, I want all of them to be automatically and immediately resized to the same new size if the user changes the size of any one of them. Can anyone tell me how this could be scripted, please?

Many thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
danschikore

Staff

Joined:

Sep 21, 2012

Solution

One option would be to make the graphs auto-stretching.  In this type of window you will want to resize the window rather than resizing an individual graph.

New Window( "stretch",

      Tab Box(

            "Tab 1",

            Graph Box(

                  Y Scale( -10, 90 ),

                  X Scale( -10, 90 ),

                  Fill Color( "red" ),

                  Oval(

                        X Origin() + 10,

                        (Y Origin() + Y Range()) - 10,

                        (X Origin() + X Range()) - 10,

                        Y Origin() + 10,

                        1

                  ),

                  Title( "Oval 1" ),

                  <<Set Auto Stretching( 1, 1 )

            ),

            "Tab 2",

            Graph Box(

                  Y Scale( -10, 90 ),

                  X Scale( -10, 90 ),

                  Fill Color( "green" ),

                  Oval(

                        X Origin() + 10,

                        (Y Origin() + Y Range()) - 10,

                        (X Origin() + X Range()) - 10,

                        Y Origin() + 10,

                        1

                  ),

                  Title( "Oval 2" ),

                  <<Set Auto Stretching( 1, 1 )

            )

      )

)

3 REPLIES
danschikore

Staff

Joined:

Sep 21, 2012

Solution

One option would be to make the graphs auto-stretching.  In this type of window you will want to resize the window rather than resizing an individual graph.

New Window( "stretch",

      Tab Box(

            "Tab 1",

            Graph Box(

                  Y Scale( -10, 90 ),

                  X Scale( -10, 90 ),

                  Fill Color( "red" ),

                  Oval(

                        X Origin() + 10,

                        (Y Origin() + Y Range()) - 10,

                        (X Origin() + X Range()) - 10,

                        Y Origin() + 10,

                        1

                  ),

                  Title( "Oval 1" ),

                  <<Set Auto Stretching( 1, 1 )

            ),

            "Tab 2",

            Graph Box(

                  Y Scale( -10, 90 ),

                  X Scale( -10, 90 ),

                  Fill Color( "green" ),

                  Oval(

                        X Origin() + 10,

                        (Y Origin() + Y Range()) - 10,

                        (X Origin() + X Range()) - 10,

                        Y Origin() + 10,

                        1

                  ),

                  Title( "Oval 2" ),

                  <<Set Auto Stretching( 1, 1 )

            )

      )

)

markbailey

Staff

Joined:

Jun 23, 2011

You might need to use a script, such as the one supplied by Dan.

Did you try resizing one of the plots by dragging WHILE holding the CTRL key in Windows or the Apple key in Mac? This modifier key generally 'broadcasts' any interaction (such as resizing with a drag) with other objects that can respond to the same action.

Learn it once, use it forever!
clausa

Community Trekker

Joined:

Jan 16, 2014

A bit convoluted, but if you want the user to control the window size I think that this would work: you could add a button the graph window that says change size and create a prompt from there for them to input the size in pixels. This could then be sent to each graph to alter its size.