StackedBarChart+line (Overlaid)

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

StackedBarChart+line (Overlaid)

Post by guest » Fri Dec 19, 2003 9:35 am

Hii,

I am trying to put the stacked bar chart and line chart together...overlaid charts...but, the stacked bar chart is just taking the data for one bar...the line chart is coming fine.Following ís the code..

Code: Select all


		JFreeChart chart = null;
		CategoryItemRenderer renderer2 = new LineAndShapeRenderer();

		CategoryPlot plot = new CategoryPlot();
		LineAndShapeRenderer linerenderer = null;
		CategoryItemRenderer barrenderer = new StackedBarRenderer();
....
....
...

				if ("BAR".equals(key) || ("STACKEDBAR".equals(key))) {
					plot.setDataset(
						(CategoryDataset) provideDataset((ArrayList) value));
					plot.setRenderer(barrenderer);
				} else if ("LINE".equals(key)) {
					plot.setSecondaryDataset(
						counter,
						(CategoryDataset) provideDataset((ArrayList) value));
						maxRangeValue = DatasetUtilities.getMaximumRangeValue((CategoryDataset) provideDataset((ArrayList) value));
						if(counter==0){
							plot.setSecondaryRenderer(0, renderer2);
						}else{
							plot.setSecondaryRenderer(counter,new LineAndShapeRenderer());
						}
						
						linerenderer= (LineAndShapeRenderer) plot.getSecondaryRenderer(counter);
						linerenderer.setDrawShapes(false);
						counter++;
				}
I believe the renderer i m using for stacked bar is not correct...can anyone give me idea??

Regards
guest

guest

Post by guest » Fri Dec 19, 2003 10:37 am

Am i clear with my question??

Please guide.

Regards
guest

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 Dec 19, 2003 6:08 pm

It's not clear to me. If you can, post a small sample application that I can cut and paste then run.
David Gilbert
JFreeChart Project Leader

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

guest

Post by guest » Fri Dec 19, 2003 6:18 pm

Hii David,

Thanks for your reply. Actually i was doing mistake with my dataset. Just now, i found it and was about to post a message. Well, but i m having another problem now.

The thing is, i set the autorange true....it works fine. But, now the chart has a gap between the 0 level and the x axis.

How can i fix this??

Regards
guest

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 Dec 19, 2003 7:28 pm

There is a setAutoRangeIncludesZero(boolean) method in the ValueAxis or NumberAxis class.
David Gilbert
JFreeChart Project Leader

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

premkumark
Posts: 2
Joined: Thu Aug 14, 2014 3:07 pm
antibot: No, of course not.

Re: StackedBarChart+line (Overlaid)

Post by premkumark » Thu Aug 14, 2014 6:45 pm

I am new to jFreeChart, in my project i have to create overlaid stacked bar and line chart, I was not able to figure out how to generate the chart, i see that you have done similar thing, please share your code to do this. I appreciate your help.

Locked