|T O P I C R E V I E W
||Posted - 05 Mar 2012 : 16:51:19
I have a Chartview as one of several panels controlled by a GridBagLayout. When I resize my window the ChartView disapears.
Do I have to set something on the ChartView to enable enable resizing of my chart?
|4 L A T E S T R E P L I E S (Newest First)
||Posted - 11 Mar 2012 : 12:58:03
Thank you for pointing me in the right direction.
Your advice aboout the resize mode was exactly what I needed to achieve the required behaviour.
||Posted - 07 Mar 2012 : 17:55:41
Glad you were able to solve your problem.
Your next question is much easier.
Read the section in the QCChart2D manual titled ChartView Object Resize Modes, Chapter 5, and the example program ResizeExamples.FixedSizeObjects.
You can't change the number of ticks as you resize though. The default behavior of the axis labels will remove overlapping labels as the tick marks move closer.
||Posted - 07 Mar 2012 : 17:41:04
Thank you for confirming that ChartView dos not require any special settings to allow resizing. I have determined my problem was caused by code related to the GridBagLayout and not with the ChartView component.
Now that my chart is resizing as expected, I have a follow-up question. Is it possible to keep the font size of the axis
constant as the chart is resized?
When the chart is made smaller I would like the font to remain a constant size (to be readable) and reduce the number of ticks on the
axis instead. For example: in regular size the x-axis might show tick marks for each day of the month. When the user narrows the chart (by resizing the window), the x-axis label font would remain the same but there would be fewer ticks on the axis, perhaps only 1 tick per month.
Is such behaviour possible?
||Posted - 06 Mar 2012 : 11:21:35
We can't say the ChartView works particularly well with a GridBagLayout layout manager, but it does seem to work. We cannot reproduce a situation where the chart does not show. It is important that you set the setPreferredSize, setMinimumSize and setMaximumSize values. We find that it works best if you can set the minimum size, and the preferred size the same, because once the size drops below the preferred size, the GridBagLayout seems to then reduce it immediately to the minimum size.
GridBagConstraints c = new GridBagConstraints();
lineplotsalesvolume = new LinePlotSalesVolume();
c.fill = GridBagConstraints.CENTER;
c.ipady = 0; //reset to default
c.weighty = 1.0; //request any extra vertical space
c.anchor = GridBagConstraints.CENTER; //bottom of space
c.insets = new Insets(10,0,0,0); //top padding
c.gridx = 0; //aligned with button 2
c.gridwidth = 3; //2 columns wide
c.gridy = 1;
If you still cannot get you chart to show, prepare an example program which demonstrates the problem that we can compile and run.