Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

In JFreeChart is there a notion of a composite Chart.

I need to layout several charts in a grid like arrangement.

Each chart in the grid needs to have its own separate title.

I would like to be able to save this composite chart into a png file

I would get a code snippet that explains how to do this.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
353 views
Welcome To Ask or Share your Answers For Others

1 Answer

As shown here, ChartPanel can be placed in any desired Swing layout. The example cited uses GridLayout. ChartUtilities has methods for rendering a chart as a .png. I see several approaches to getting a composite image:

  • Use Robot#createScreenCapture() to image the layout, as shown here and here; the resulting BufferedImage can be saved using ImageIO.write().

  • Use JFreeChart#createBufferedImage() to render each chart and impose the individual images into a BufferedImage to create a single image, as suggested here.

  • Implement the Printable interface to render the image in a graphics context, as shown here.

image


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...