Paint chart background for specific region only

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
hsp707
Posts: 18
Joined: Thu May 15, 2008 4:58 pm

Paint chart background for specific region only

Post by hsp707 » Wed Oct 08, 2008 5:43 pm

Hi everyone,

How can I paint the background of a chart (say) black only for specific region i.e. from (x1,y1) to (x2, y2) only. In this case, say, my range upper bound is 100, I want to paint the chart black from

(x1, 0) to (x2, 100).

Right now, I am doing this by adding XYLineAnnotation and choosing basic stroke,a s shown below: -

Code: Select all

for (float i = fromX; i <= toX; i++) {

			Stroke stroke = new BasicStroke(8);

			XYLineAnnotation xyLineAnnotation = new XYLineAnnotation(i, 0, i,
					RANGE_UPPER_BOUND, stroke, Color.black);
			chart.getXYPlot().addAnnotation(xyLineAnnotation);
			
		}
But the problem with this is that, when my chart 's dimensions change, e.g. height is increased, basic stroke doesn't completely fill the area and it looks like line annotations with thick stroke, but not wide enough to make it look like as if it is all black.

Thank You in Advance.

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Post by skunk » Wed Oct 08, 2008 5:47 pm

Have you tried one of these yet?

Code: Select all

org.jfree.chart.annotations.XYPolygonAnnotation
org.jfree.chart.annotations.XYShapeAnnotation

Locked