Overlaying rectangle over a scatter chart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
whahahaha
Posts: 2
Joined: Thu Oct 29, 2015 9:30 am
antibot: No, of course not.

Overlaying rectangle over a scatter chart

Post by whahahaha » Thu Oct 29, 2015 9:38 am

What I am trying to do:
Image

What I have tried:
public void customize(JFreeChart chart, JRChart jasperChart) {
BufferedImage image = chart.createBufferedImage(20, 20);
Graphics2D g2 = image.createGraphics();

g2.setColor(Color.RED);
g2.fill(new Rectangle2D.Double(1, 1, 5, 5));

chart.draw(g2, new Rectangle(10, 10, 20, 20));
chart.fireChartChanged();
chart.setTitle("abcd");
}

But i failed =(

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: Overlaying rectangle over a scatter chart

Post by david.gilbert » Sat Oct 31, 2015 8:24 am

If the rectangle is in a fixed location, you could add an XYBoxAnnotation to the chart.
David Gilbert
JFreeChart Project Leader

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

whahahaha
Posts: 2
Joined: Thu Oct 29, 2015 9:30 am
antibot: No, of course not.

Re: Overlaying rectangle over a scatter chart

Post by whahahaha » Mon Nov 02, 2015 2:25 am

Awesome, it worked. Thank you very much :lol: . Just saved me from getting fired =D

Locked