Hi,
it would be great if we can add background image and icons to a chart.
new features : background image, icons
RE: new features : background image, icons
Better yet, I would like the capability of setting a JFreeChartPanel component opaque so that an existing background image shows behind a chart.
RE: new features : background image, icons
There's a couple of approaches to adding a background image.
(1) If you just want the image to appear on screen, then JFreeChartPanel can be modified to draw an image just before it draws the chart. You'd have to decide whether you want the image scaled or not, but otherwise I can't think of any problems. Just add the code in the paintComponent(...) method.
(2) If you want the image to appear anywhere that the chart is drawn (screen, printer, BufferedImage or arbitrary Graphics2D) then it needs to be part of the JFreeChart class and added in the draw() method. Again, you need to decide whether the image needs scaling. Images won't always look good on the printer, so you'd want to be able to disable the image temporarily (a simple flag).
Option 2 is more general, so probably is better. Anyone else have any thoughts (or time to write the code?)
DG.
(1) If you just want the image to appear on screen, then JFreeChartPanel can be modified to draw an image just before it draws the chart. You'd have to decide whether you want the image scaled or not, but otherwise I can't think of any problems. Just add the code in the paintComponent(...) method.
(2) If you want the image to appear anywhere that the chart is drawn (screen, printer, BufferedImage or arbitrary Graphics2D) then it needs to be part of the JFreeChart class and added in the draw() method. Again, you need to decide whether the image needs scaling. Images won't always look good on the printer, so you'd want to be able to disable the image temporarily (a simple flag).
Option 2 is more general, so probably is better. Anyone else have any thoughts (or time to write the code?)
DG.