LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Legend disappear when resizing graph in CVI 2009

Hi forum,

 

i have a problem with the graph control and the legend of a graph. I want to resize a graph by using the splitter. I attach the graph to two splitters to resize it in width and height by doubleclicking the panel. If the legend is in the range of the control, means the top of the legend is not greater than top + height of the graph control everthing is working fine. But if the top of the legend is greater than top + height of the graph the legend moves to the right, but dont moves back to the old position if the panel is resizing again.

 

Also there seems to be a positioning problem. If i resize the panel height to a minimum by click and hold the bottom of the panel and i do this again to a normal size the position of the second graph is not set correctly.

 

Please review my little source code. Maybe this happens due to an error by my side.

 

 

Thomas

0 Kudos
Message 1 of 2
(2,889 Views)

Resizing graphs with legends is tricky because, when  you grow or shrink a graph, the legend moves depending on how it is positioned relative to the graph. Let's your bottom graph as an example:

 

In your bottom graph, the top legend is (just barely) below the bottom edge of the graph. In this position, when you increase or decrease the width of the graph, the legend does not move. However, if the top edge of the legend were above the bottom edge of the graph, then the legend would move whenever you changed the width. This implicit movement of the legend needs to happen so that it doesn't end up overlapping the body of the graph as the graph changes size.

 

This is what happens when the panel grows:

 

You first grow the graphs vertically (by operating the horizontal splitter). This forces the bottom edge of the graph to be below the top edge of the splitter. Then, you grow the graphs horizontally (by operating the vertical splitter). Because the bottom edge of the graph is now below the top edge of the legend, the legend is forced to move to the right.

 

Now this is what happens when the panel shrinks:

 

You first shrink the graphs vertically (by operating the horizontal splitter). This forces the bottom edge of the graph to once again be above the top edge of the splitter. Then, you shrink the graphs horizontally (by operating the vertical splitter). But now, because the bottom edge of the graph is above the top edge of the legend, the legend does not move, and as a result you no longer see it (because it's clipped by the panel's right edge)

 

You could fix this by alternating the order in which you operate the splitters depending on whether the panel is growing or shrinking. You could also fix it by slightly tweaking the original position of the legend (moving it up by 1 pixel would be sufficient), such that it is always above the bottom edge of the graph. Your top legend, by the way, is already above the bottom edge of the top graph. This is why you're only seeing the problem with the bottom graph.

 

Luis




0 Kudos
Message 2 of 2
(2,878 Views)