can we use jfreechart to display an image - jfreechart

Is there anyway to use jfreechart to load and display an image? say some image.png to display on a JPanel using jfreechart so that we can zoomin, zoomout etc?

The ChartPanel class provided in the JFreeChart distribution is the recommmended mechanism for displaying charts in a Swing user interface.

Related

Reporting with Jfreechart?

I have created a chart using jfreechart library. I have the data set that use to create the graph. Is there any way I can get a report of the data in a tabular form directly from the jfreechart chart object.. Or any other ways where i can create report using jfreechart
Thank you
Assuming an XYDataset for example, one approach is to extend AbstractXYDataset and implement TableModel. Then you can construct a JTable, which is easy to render or print.

In JFreeChart XYPlot how to change the bar colors

In JFreeChart XYPlot, how to change the bar colors?
Use one of your chosen renderer's setSeriesPaint() methods, as shown in this example and code.

mouse events in JfreeChart

I need a way to distinguish when a mouse event occurs in the chart itself and not in the chartPanel (the plot area).
Thanks
You should be able to use the mouse event from your panel and use ChartMouseEvent.getEntity() to find if your chart is over one of the chart entities. See the api docs for ChartMouseEvent.

mouse over chart line in jfreechart

I'd like to know if there is a way to detect when the mouse is over the graph line/lines and to be able to acces the data from the dataset corresponding to that point.
Getting this data depends on where you are using the chart.
In a swing application use the mouse listeners from the panel that the chart is displayed in.
On a web page using an image you will not be able to get to the data (as it is only an image), but JFreeChart will generate an image map for you which can call java script on hover.
In a recent project I did something like:
ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
String pngLocation = Servlet.saveChartAsPNG(chart, 200, 200, info, request.getPortletSession());
StringWriter sw = new StringWriter();
ChartUtilities.writeImageMap(new PrintWriter(sw), pngLocation, info, false);
Here chart is a JFreeChart with the appropriate flags for what it is you are seeking to do (tool tips, url's, labels)

setting chart size to fixed value in JFreeChart

In JFreeChart graphics, if you resize the application window, the graphics are repainted according to the application window size. Is it possible to set the chart size to fixed values?
Well.
I would like to suggest a different approach. Without worrying to fix it in jfreechart graphics, I think you can easily do it using a java swing layout (e.g: GridBagLayout) .
Add the ChartPanel to a swing Panel and set the layout to GridBagLayout.
Hope this helps..

Resources