Reducing charts heigh in CombinedDomainXYPlot

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
sergiovsj
Posts: 4
Joined: Fri Dec 02, 2011 1:22 pm
antibot: No, of course not.

Reducing charts heigh in CombinedDomainXYPlot

Post by sergiovsj » Wed Jan 04, 2012 1:57 pm

Hello.
I've created a CombinedDomainXYPlot chart with 4 subplots. #1 and #2 subplot have the same height, that's correct. I would like to set the heigh for #3 and #4 subplot.
Image

Reading the forum I've searched these topics
viewtopic.php?f=3&t=25563&hilit=height+subplot
viewtopic.php?f=3&t=25357

In which is recommended to use setWeight(int) in order to control the height of each subplot. I've used it but nothing happens. (I know that there are other factors affects to subplot heigh such as legend, labels,...).

I also set some other properties that I found in other topics related to chart heigh, before adding to CombinedDomainXYPlot.

Code: Select all

LOGGER.error("INSETS plot1: " + xyplot.getInsets());
xyplot.setInsets(new RectangleInsets(0, 8, 0, 8), true);
LOGGER.error("INSETS plot2: " + xyplot.getInsets());

LOGGER.error("AXIS plot1: " + xyplot.getAxisOffset());
RectangleInsets a = new RectangleInsets(-10, 0, -10, 0);
xyplot.setAxisOffset(a);
LOGGER.error("AXIS plot2: " + xyplot.getAxisOffset());

localCombinedDomainXYPlot.add(xyplot);
But nothing happens.

Setting AxisSpace for subplot #3 and #4

Code: Select all

AxisSpace space = new AxisSpace();
space.setBottom(80D);
space.setTop(80D);
space.setLeft(80D);
space.setRight(80D);
xyplot.setFixedDomainAxisSpace(space, true);
Image

It's like changing subplot AxisSpace doesn't notify CombinedDomainXYPlot.
How can I managed to remove the blank space between charts?

code404
Posts: 2
Joined: Tue Dec 13, 2011 11:16 am
antibot: No, of course not.

Re: Reducing charts heigh in CombinedDomainXYPlot

Post by code404 » Thu Jan 05, 2012 4:26 pm

I think this is not possible.
Use this patch to add fixed size functionality:
http://sourceforge.net/tracker/index.ph ... tid=315494

sergiovsj
Posts: 4
Joined: Fri Dec 02, 2011 1:22 pm
antibot: No, of course not.

Re: Reducing charts heigh in CombinedDomainXYPlot

Post by sergiovsj » Tue Jan 10, 2012 11:46 am

Thanks for your response code404.
I can't use the patch you recommend me because I'm using a Maven repository and I'm not allowed (my boss doesn't allowed me) to recompile a new jar with the files in this patch.

I've tried to extend some files such as XYPlot.java. Overwiten "draw" method I can set the size of the rectangle that contains the chart.

Code: Select all

@Override
	public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor,
			PlotState parentState, PlotRenderingInfo info) {

// x, y, width and heigt are attributes with getters and setters
		area.setRect(this.x, this.y, this.width, this.height);
		this.xyplot.draw(g2, area, anchor, parentState, info);
	}
It works fine. But it has his own problems. Charts #3 and #4 doesn't align with #1 and #2. I think this was cause by a theme I apply later. The problem is that using an extended class doesn't allowed me to use a theme later, to set some basic aspects such as background, colors, fonts,... I also tried to extend the StandardChartTheme, ChartUtilities and ChartFactory classes in order to set them to my needs, but it's impossible to obtain some nice results. In fact, we have change our mind and we start thinking in creating a table with the data, hahaha.

Locked