Gap between bars of same series
Gap between bars of same series
Trying to create bar chart with 2 series items.
I am setting the setItemMargin to 0.0 on BarRenderer for no gap between the bars.
If i have only one item(2-series) on the bar then it adds the gap between the bars, But if have multiple items then it doesn't have gap between the series bars.
Don't know how i am getting the gap..
Do you have any clue?
I am setting the setItemMargin to 0.0 on BarRenderer for no gap between the bars.
If i have only one item(2-series) on the bar then it adds the gap between the bars, But if have multiple items then it doesn't have gap between the series bars.
Don't know how i am getting the gap..
Do you have any clue?
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: Gap between bars of same series
It comes from the CategoryAxis and you can control it with setCategoryMargin().
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


-
- Posts: 10
- Joined: Mon Jan 11, 2010 6:54 am
- antibot: No, of course not.
Re: Gap between bars of same series
I think Mailkr wants to reduce the gap between the bars that belong to the same category and not the gap between the different categories.
Is it true?
Because I am also facing the same problem.
I can reduce the gap between the different categories but not between the bars of same category.
Is there any function or any other workaround in jfreechart to achieve that?
Thanks in advance,
Abhinav
Is it true?
Because I am also facing the same problem.
I can reduce the gap between the different categories but not between the bars of same category.
Is there any function or any other workaround in jfreechart to achieve that?
Thanks in advance,
Abhinav
Re: Gap between bars of same series
Stacked bar(column) charts are a popular way to depict 2 more series of related data, like sales of 2 products.But there are several ways to stack the bars in a bar chart. Hard to compare, only first value starts at zero, takes more space, needs extra calculation for the gap series, needs extra calculation, One series dominates another, good where domination is needed, Needs extra formatting, not always produces good results, difficult to compare, needs extra formula to calculate gap series.
____________
stocktake
____________
stocktake
-
- Posts: 5
- Joined: Fri Aug 27, 2010 7:57 am
- antibot: No, of course not.
Re: Gap between bars of same Category
I am facing the same issue with adjusting the gaps between the same category ,setCategoryMargin() does not seem to work at all ,if we are having two series for the same category,niether adjusting the BarRender class is comfortable,there should be some way to deal with this problem, or either please suggest a code , to adjust the BarRenderer Class to get the required output
Re: Gap between bars of same series
Still no solution?
I'm having the same problem, using a XYPlot an a XYBarRenderer to generate my bars. And obvious there's no chance to divide my bars, as long as they are in the same series.
also, if I'm not totally wrong, I'm even not having a CategroyAxis to use setCategoryMargin() in any way:
As you can see, I'm generating Bars für date values on a DateAxis. But I've already overwritten the XYBarRenderer to show different colors on positive or negative values, so any additional override to insert a gap ist a welcome solution...
anyone any idea?
I'm having the same problem, using a XYPlot an a XYBarRenderer to generate my bars. And obvious there's no chance to divide my bars, as long as they are in the same series.
also, if I'm not totally wrong, I'm even not having a CategroyAxis to use setCategoryMargin() in any way:
Code: Select all
XYPlot plot = new XYPlot(
dataSetBar,
new DateAxis(dateAxisLabel),
new NumberAxis(valueAxisLabel),
new DifferenceBarRenderer(
getPositiveColor(),
getNegativeColor(),
getThreshold()));
JFreeChart result = new JFreeChart(getTitle(), getFont(), plot, true);
anyone any idea?
Re: Gap between bars of same series
Somedays... looking for a solution for days and finding only post asking the same question an no answer... Now, after viewing and seraching the code for another time, I've found the solution:
For a BarRenderer, you can call the method setItemMargin(double percent) - the equvalent to this method on XYBarRenderer seems to be setMargin(double percent).
sorry for exhuming this old post...
For a BarRenderer, you can call the method setItemMargin(double percent) - the equvalent to this method on XYBarRenderer seems to be setMargin(double percent).
sorry for exhuming this old post...
Re: Gap between bars of same series
HI everyone
I too ahve same issuse
i tried using plt.getDomainAxis().setCategoryMargin(0.00);
as well as StackedBarRenderer renderer = (StackedBarRenderer) chart.getCategoryPlot().getRenderer();
renderer.setItemMargin(0);
for my stacked bar chart
nothing is working fine for sme.
it will be helpful if am able to resolve this
Thanks in advance
I too ahve same issuse
i tried using plt.getDomainAxis().setCategoryMargin(0.00);
as well as StackedBarRenderer renderer = (StackedBarRenderer) chart.getCategoryPlot().getRenderer();
renderer.setItemMargin(0);
for my stacked bar chart
nothing is working fine for sme.
it will be helpful if am able to resolve this
Thanks in advance