category area charts look like mountains, not horizons

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
micah

category area charts look like mountains, not horizons

Post by micah » Thu Oct 13, 2005 1:27 am

Hi,
I'm working on a project that includes some fairly simple area and line charts, and selected JFreeChart + Cewolf because of the low barrier to entry and robust configurability. However, at the moment, I've hit something of a wall in finding just the configuration I want. My spec calls for area charts which fill right to the edges of the data area, but I've been unable thus far to figure out how to pull that off. I found the AreaRendererEndType, which looked promising, but setting to TRUNCATE still leaves an unfilled margin on the left and right sides of my data area, and I can't see any difference between setting TAPER and LEVEL.
Perhaps some pictures will make this a bit more clear. What I want is a chart that looks like this:
Image.
What I've been able to get so far is a chart like this:
Image.
I've seen that JFreeChart can generate charts like what I'm after. The XY Area Chart Demo, for instance, fills right to the edge of the data area. I'm currently using Category datasets, but could shift to XY datasets if that is the only way to get what I'm after. Is that the way for me to go, or is there some other setting which is alluding me? Any help on this would be hugely appreciated. Thanks,

-micah

pmlb
Posts: 31
Joined: Thu Aug 25, 2005 5:18 pm
Location: France

Post by pmlb » Thu Oct 13, 2005 4:55 pm

Hi,

Sounds like this : http://www.jfree.org/phpBB2/viewtopic.php?t=14697

Try to set set the upper and lower margins of your domain axis, may be something like that:

Code: Select all

CategoryAxis axis = plot.getDomainAxis();
axis.setLowerMargin(0.0); 
axis.setUpperMargin(0.0); 
Pierre-Marie

micah

Post by micah » Thu Oct 13, 2005 7:36 pm

pmlb wrote:Hi,

Sounds like this : http://www.jfree.org/phpBB2/viewtopic.php?t=14697

Try to set set the upper and lower margins of your domain axis, may be something like that:

Code: Select all

CategoryAxis axis = plot.getDomainAxis();
axis.setLowerMargin(0.0); 
axis.setUpperMargin(0.0); 
That does seem to help a little, but I'm still left with a margin.

Here is the code currently in my ChartPostProcessor:

Code: Select all

                JFreeChart jfc = (JFreeChart) chart;
		CategoryPlot plot = (CategoryPlot)jfc.getPlot();
		plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 0.0, 0.0, 0.0, 0.0));
		CategoryAxis axis = plot.getDomainAxis();
		axis.setCategoryMargin(0.0);
		axis.setLowerMargin(0.0);
		axis.setUpperMargin(0.0);
		
		//CategoryItemRenderer r = plot.getRenderer();
		AreaRenderer r = (AreaRenderer)plot.getRenderer();
		r.setSeriesPaint(0, new Color(255, 144, 14));
		r.setSeriesPaint(1, new Color(23, 88, 124));
		
		r.setEndType(AreaRendererEndType.TRUNCATE);
All these things seem like they ought to be doing the job, but none of them do.

BTW: I'm using JFreeChart 0.9.21.

-micah

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Fri Oct 14, 2005 9:09 am

The StackedAreaRenderer isn't honoring the setAreaEndType() setting. That needs to be fixed, and I think also an option for the category axis to show "half" categories at each end would be helpful. In the short term, you might want to try the XYPlot option instead.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked