How to hide bar outline in stacked bar?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
merctron
Posts: 2
Joined: Tue Jun 30, 2015 12:00 am
antibot: No, of course not.

How to hide bar outline in stacked bar?

Post by merctron » Tue Jun 30, 2015 12:10 am

Image

In the stacked bar chart above, how can i remove the line (in the red circle) and keep the other lines?

I have done the above by extending StackedBarRenderer

Code: Select all

class MECustomRenderer extends StackedBarRenderer {

        /**
		 * 
		 */
		private static final long serialVersionUID = 1L;
		/** The colors. */
        private Paint[] colors;
        private PrintWriter out; 

        /**
         * Creates a new renderer.
         *
         * @param colors  the colors.
         */
        public MECustomRenderer(final Paint[] colors, PrintWriter out) {
            this.colors = colors;
            this.out = out;
        }

        public Paint getItemOutlinePaint(final int row, final int column){
        	if (this.colors[column % this.colors.length] != null){
        			
        	}
        	return this.colors[column % this.colors.length];
        }
        public Stroke getItemOutlineStroke(final int row, final int column){
        	return new BasicStroke(2.5f);
        }
        //public
    }

merctron
Posts: 2
Joined: Tue Jun 30, 2015 12:00 am
antibot: No, of course not.

Re: How to hide bar outline in stacked bar?

Post by merctron » Wed Jul 01, 2015 1:57 am

i was able to do a dirty fix around this.
the main aim was to highlight the wanted bar of the stacked bars. having failed to figure out a way to do the mentioned above, i used a second chart which i layered on top.

The chart that i put over was made with a transparent background, and the bar color was also given some transparency.

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

Re: How to hide bar outline in stacked bar?

Post by paradoxoff » Wed Jul 01, 2015 3:58 pm

Your "fix" really seems dirty.
I have two cleaner (but not neccessarily easier codeable) solutions:
1. Write your own renderer that extends StackedBarRenderer that allows to draw a border around the rectangle that is the sum of the stacked bars.
2. I f you can guarantee that your bars strech over the entire height of the data area: you could use a CategoryMarker with a transparent paint.

Locked