Invisible Subplots in Combined Category Chart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Reggie3
Posts: 12
Joined: Mon Mar 10, 2008 5:19 pm

Invisible Subplots in Combined Category Chart

Post by Reggie3 » Mon Apr 21, 2008 9:22 pm

I have created a CombinedDomainCategoryPlot that is made up of several subplots that are pulled from several 3D bar charts using the following loop:

Code: Select all

for(int i=0; i<alCharts.size(); i++){
  subPlot = (CategoryPlot)alCharts.get(i).getPlot();
  BarRenderer bRenderer = (BarRenderer)subPlot.getRenderer();
  bRenderer = new BarRenderer3D(12.0, 8.0 );
  bRenderer.setMaximumBarWidth(0.05);
  bRenderer.setItemMargin(0.0);
  bRenderer.setBaseToolTipGenerator(new   StandardCategoryToolTipGenerator());
  plot.add(subPlot, 1);
}
The problem manifests itself by giving me a CombinedDomainCategoryPlot that only shows the first plot that is added. All the other charts are present but can't be seen. The reason I say they are present is that I am getting the correct tooltip information for those charts when I mouseover where they should be. The CombinedDomainCategoryPlot looks like this:

Image

My charts are type JFreeChartWithData which is a subclass of JFreeChart that includes an arraylist of strings that holds the same data that is in the dataset that is used to build the chart. Here is the code for it, but it shouldn't be related to the problem:



Any idea what could be causing this?

Code: Select all

public class JFreeChartWithData extends JFreeChart {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private ArrayList alData = new ArrayList();
	private JFreeChart chart;
	
	public JFreeChartWithData(String arg0, Font arg1, Plot arg2, boolean arg3) {
		super(arg0, arg1, arg2, arg3);
		// TODO Auto-generated constructor stub
	}
	
	public JFreeChartWithData(String arg0, Font arg1, Plot arg2, boolean arg3, ArrayList alListData) {
		super(arg0, arg1, arg2, arg3);
		this.alData = alListData;
	}
	
	public JFreeChartWithData(CategoryPlot plot, JFreeChart chart, ArrayList alListData){
		super(plot);
		this.chart=chart;
		this.alData = alListData;

	}
	
	public boolean SetChartData(ArrayList alListData){
		this.alData = alListData;
		return true;
	}
	
	public ArrayList GetChartData(){
		return this.alData;
	}
	
	public boolean SetChart(JFreeChart chart){
		this.chart=chart;
		return true;
	}
	
	public JFreeChart GetChart(){
		return chart;
	}
}

Reggie3
Posts: 12
Joined: Mon Mar 10, 2008 5:19 pm

More Information

Post by Reggie3 » Thu Apr 24, 2008 10:15 pm

Just in case it helps anybody figure out what the problem is, the output from calling plot.getSubplots() on my combined category plot is:

Subplots : [org.jfree.chart.plot.CategoryPlot@898540, org.jfree.chart.plot.CategoryPlot@8b677f, org.jfree.chart.plot.CategoryPlot@37d490, org.jfree.chart.plot.CategoryPlot@1647278, org.jfree.chart.plot.CategoryPlot@1972e3a]

Which points to the subplots being obtained and entered into the combined category plot correctly.

RoyW
Posts: 93
Joined: Wed Apr 23, 2008 7:42 pm
Contact:

Post by RoyW » Fri Apr 25, 2008 6:46 pm

I notice a couple of things

Code: Select all

BarRenderer bRenderer = (BarRenderer)subPlot.getRenderer(); 
bRenderer = new BarRenderer3D(12.0, 8.0 ); 
When you do this you are not creating a new bar renderer for the sub plot. You just create a new renderer and then never use it. Maybe you meant

Code: Select all

for(int i=0; i<alCharts.size(); i++){ 
  subPlot = (CategoryPlot)alCharts.get(i).getPlot(); 
  BarRenderer bRenderer = new BarRenderer3D(12.0, 8.0 ); 
  bRenderer.setMaximumBarWidth(0.05); 
  bRenderer.setItemMargin(0.0); 
  bRenderer.setBaseToolTipGenerator(new   StandardCategoryToolTipGenerator()); 
  subPlot.setRenderer( bRenderer );
  plot.add(subPlot, 1); 
}
Also

Code: Select all

  plot.add(subPlot, 1); 
What plot is that? Looking at the source for JFreeChart.java shows plot has private access so you cannot be adding to that plot.

Maybe if you changed it to

Code: Select all

getPlot().add(subPlot, 1);
it may work but I would need to see which "plot" you are adding to.

RichardWest
Posts: 844
Joined: Fri Oct 13, 2006 9:29 pm
Location: Sunnyvale, CA

Post by RichardWest » Fri Apr 25, 2008 6:51 pm

RoyW wrote:it may work but I would need to see which "plot" you are adding to.
I suspect plot is the variable name for his CombinedDomainCategoryPlot just as subPlot is the name for the current sub-CategoryPlot he is processing.
Richard West
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA

Locked