Bar Chart With Round Corner Edges

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
haran_123
Posts: 7
Joined: Wed Jan 20, 2010 5:57 am
antibot: No, of course not.

Bar Chart With Round Corner Edges

Post by haran_123 » Fri Jan 22, 2010 2:02 pm

Hi,
How to implement the bar chart with Round Edge Corners.

I have tried as below but it is not even reflecting any thing in the Bar Chart.

Code: Select all

renderer.setSeriesShape(1, new RoundRectangle2D.Float(3, 3, 6, 6, 10, 10));
How can i achieve the round corners.please help

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: Bar Chart With Round Corner Edges

Post by paradoxoff » Sat Jan 23, 2010 1:16 pm

A BarRenderer ignores the setting for the series shape and will always render the data items as bars, i.e. as rectangles.
If you want to change that, you would have to create your own renderer that extends BarRenderer, override the drawItem method.

haran_123
Posts: 7
Joined: Wed Jan 20, 2010 5:57 am
antibot: No, of course not.

Re: Bar Chart With Round Corner Edges

Post by haran_123 » Wed Feb 17, 2010 12:11 pm

Hi,
paradoxoff,thanks for your reply.I have created my own CustomBarRenderer class which extends BarRenderer for round corners.
Just providing few points to others.
Insted of,

Code: Select all

Rectangle2D bar = null;
I have used,

Code: Select all

RoundRectangle2D bar = null;
		if (orientation == PlotOrientation.HORIZONTAL) {
			 bar = new java.awt.geom.RoundRectangle2D.Double(barL0 - barL0Adj,barW0, barLength + barLengthAdj, state.getBarWidth(),10,10);
		} else {			
			bar = new RoundRectangle2D.Double(barW0, barL0 - barL0Adj, state.getBarWidth(), (barLength + barLengthAdj), 10, 10);
		}

verma.ankush1991
Posts: 1
Joined: Tue May 05, 2015 9:21 am
antibot: No, of course not.

Re: Bar Chart With Round Corner Edges

Post by verma.ankush1991 » Tue May 05, 2015 9:25 am

haran_123 wrote:Hi,
paradoxoff,thanks for your reply.I have created my own CustomBarRenderer class which extends BarRenderer for round corners.
Just providing few points to others.
Insted of,

Code: Select all

Rectangle2D bar = null;
I have used,

Code: Select all

RoundRectangle2D bar = null;
		if (orientation == PlotOrientation.HORIZONTAL) {
			 bar = new java.awt.geom.RoundRectangle2D.Double(barL0 - barL0Adj,barW0, barLength + barLengthAdj, state.getBarWidth(),10,10);
		} else {			
			bar = new RoundRectangle2D.Double(barW0, barL0 - barL0Adj, state.getBarWidth(), (barLength + barLengthAdj), 10, 10);
		}
Could you please share the entire code of the customiser class how you have made the edges look rounded. Thanks in advance for your help.

Regards

Locked