JFreeChartWrapper question (Timeline addon from Vaadin)

I have one question regarding to the methods of setting Canvas size. By default, I can render the a good looling graph using
JFreeChartWrapper fchart = new JFreeChartWrapper(chart);
Where chart is a JFreeChart

However, when I tried to set the size of the canvas using below code, I got the following graph. Instead of the canvas size change, it seems that the font size changes, which is not I wanted.
JFreeChartWrapper fchart = new JFreeChartWrapper(chart);

I have been working on it for a while, but still couldn’t figure out what went wrong. Does anyone have any quick thought about it?

Thank you very much!


The problem is that you are using wrong methods. You should use standard setWidth and setHeight to control the actual component size.

graphHeight/Width controls kind of a reference size into which the JFreeChart renders its chart. The graph (rendered as SVG or PNG) will then be scaled to the components size on the client side. Most commonly JFreeCharWrapper can guess a good enough value for your use case, but in some cases there is a need for fine tuning. As stated in javadocs (I agree - there should be better explanations) you most often want to fine tune these values only if you have relative sized graph.

The font size changes as the JFreeChart library tries to render optimal font size for the requested graph height. Font sizes etc. can be modified with JFreeChart API’s.


Hi Matti,

Thank you so much for your reply.

To make things worse and harder, I am new to both Vaadin and JFreeChart/Wrapper. If my questions are too naive or stupid, please do bear with me.

Regarding to what you said that I should use standard setWidth and setHeight to change the actual component time. I assume the actual component in my case is that JFreeCharWrapper instance? I didn’t find the setWidth and setHeight methods with it.

My code logic is very straightforward.
void init(){

	main = new Window();

            XYDataset dataset = createDataset();
            JFreeChart chart = createChart(dataset); //here return an object of a JFreeChart
            JFreeChartWrapper jfc = new JFreeChartWrapper(chart);


As to JFreeChart object ‘chart’, I know that we can use ChartPanel to manage the size if we use it a standalone application . But, JFreeChartWrapper can’t take ChartPanel as its argument.

If you could please help me clarify that, that would be highly appreciated!

Thanks again!

All the best!


All components in Vaadin have methods to control size. You can’t see them in JFreeChartWrapper java file, but they are there. The magic behind the scene is called inheritance.

See Vaadin manual for more help with sizing components:

See java tutorial for more information about inheritance:


Ah, how naive is that. Shame on me! :slight_smile:

Thanks a lot,