Javatpoint Logo
Javatpoint Logo

JFreeChart Class

  • This class includes one of the most important classes in the JFreeChart library and is itself called "JFreeChart".
  • JFreeChart class provides a representation of a Java 2D chart. Methods present in the class enable developers to control various aspects of a generated chart and to create an Abstract Window Toolkit (AWT) BufferedImage representing the chart.
  • Several simple types of charts can be created using JFreeChart class directly.
  • This class comes under the org.jfree.chart package.
  • JFreeChart method is used to create bar charts, line charts, pie charts, and xy plots including time series data.

Constructors:

Constructor Description
JfreeChart(Plot plot) It creates a new chart based on the supplied plot.
JfreeChart(String title, Font titleFont, Plot plot, boolean createLegend) It creates a new chart with the given title and plot.
JfreeChart(String title, Plot plot) It creates a new chart with the given title and plot.

Method Summary:

Method Description
addChangeListener(ChartChangeListener listener) This method registers an object for notification of changes to the chart.
addLegend(LegendTitle legend) This method adds a legend to the plot and sends a ChartChangeEvent to all registered listeners.
addSubtitle(Title subtitle) This method adds a chart subtitle, and notifies registered listeners that the chart has been modified.
clearSubtitles( ) This method clears all subtitles from the chart and sends a ChartChangeEvent to all registered listeners.
createBufferedImage(int width, int height) This method creates and returns a buffered image into which the chart has been drawn.
draw(Graphics2D g2, Rectangle2D area) This method draws the chart on a Java 2D graphics device (Such as the screen or a printer).
getBackgroundImage( ) This method returns the background image for the chart, or null if there is no image.
getCategoryPlot( ) This method returns the plot cast as a CategoryPlot.
getID( ) This method returns the ID for the chart.
getLegend( ) This method returns the legend for the chart, if there is one.
getPlot( ) This method returns the plot for the chart.
getSubtitle(int index) This method returns a chart subtitle.
getTitle( ) This method returns the main chart title.
getXYPlot( ) This method returns the plot cast as a XYPlot.
removeLegend( ) This method removes the first legend in the chart and sends a ChartChangeEvent to all registered listeners.

Next TopicChartFactory class




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


B.Tech / MCA