draw border of the chart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
june
Posts: 7
Joined: Tue Jul 08, 2003 3:31 pm

draw border of the chart

Post by june » Fri Jul 11, 2003 3:51 pm

Is there any way to draw a border around the whole chart?



Thanks.

TMazzotta
Posts: 40
Joined: Thu Mar 27, 2003 7:11 pm

Post by TMazzotta » Fri Jul 11, 2003 8:43 pm

june -
I posted the same question a while back.. I never did get it resolved

If you get a solution, can you email it to me (tomMazzotta@yahoo.com).

Thanks in advance.. I'll do the same

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

Post by david.gilbert » Tue Jul 15, 2003 11:16 am

It's not a feature that is supported yet, although it is easy to add. Put the following code in the draw method of the JFreeChart class to draw a red border around a chart:

Code: Select all

        // draw the chart background...
        if (backgroundPaint != null) {
            g2.setPaint(backgroundPaint);
            g2.fill(chartArea);
            // new code below...
            Rectangle2D borderArea = new Rectangle2D.Double(chartArea.getX(), chartArea.getY(),
                  chartArea.getWidth() - 1.0, chartArea.getHeight() - 1.0);
            g2.setPaint(Color.red);
            g2.setStroke(new BasicStroke(1.0f));
            g2.draw(borderArea);
        }
Of course, it needs to be generalised, but you get the idea.
David Gilbert
JFreeChart Project Leader

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

june
Posts: 7
Joined: Tue Jul 08, 2003 3:31 pm

thank you

Post by june » Fri Jul 25, 2003 4:39 pm

tried, no problem

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

Post by david.gilbert » Fri Jul 25, 2003 4:44 pm

I've since generalised the code and you will find this feature supported in 0.9.10.
David Gilbert
JFreeChart Project Leader

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

Locked