Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Tools for Java
 QCChart2D for Java
 Resizing ChartView
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

rixmith

33 Posts

Posted - 05 Mar 2012 :  16:51:19  Show Profile  Reply with Quote
Hi,

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?



Rick

quinncurtis

1585 Posts

Posted - 06 Mar 2012 :  11:21:35  Show Profile  Reply with Quote
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();
lineplotsalesvolume.setPreferredSize(300,300);
lineplotsalesvolume.setMinimumSize(new Dimension(300,300));
lineplotsalesvolume.setMaximumSize(new Dimension(800,800));

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;

pane.add(lineplotsalesvolume, c);

If you still cannot get you chart to show, prepare an example program which demonstrates the problem that we can compile and run.
Go to Top of Page

rixmith

33 Posts

Posted - 07 Mar 2012 :  17:41:04  Show Profile  Reply with Quote
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?


Rick
Go to Top of Page

quinncurtis

1585 Posts

Posted - 07 Mar 2012 :  17:55:41  Show Profile  Reply with Quote
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.

gWG.setResizeMode(ChartConstants.NO_RESIZE_OBJECTS);

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.
Go to Top of Page

rixmith

33 Posts

Posted - 11 Mar 2012 :  12:58:03  Show Profile  Reply with Quote
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.

Rick
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Quinn-Curtis Forums © 2000-2018 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07