A line chart
or line graph is a type of chart which displays information as a series of data
points called 'markers' connected by straight line segments.
import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartFrame; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.category.DefaultCategoryDataset; public class Main { public static void main(String args[]) { String title = "Line chart demo"; DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(500, "Revenue", "2009"); dataset.addValue(550, "Revenue", "2010"); dataset.addValue(498, "Revenue", "2011"); dataset.addValue(325, "Revenue", "2012"); dataset.addValue(670, "Revenue", "2013"); dataset.addValue(710, "Revenue", "2014"); /* create chart */ JFreeChart chart = ChartFactory.createLineChart(title, null, "Revenue in M$", dataset, PlotOrientation.VERTICAL, false, true, false); /* create and display chart on frame */ ChartFrame frame = new ChartFrame("JFreeChart Demo", chart); frame.setVisible(true); frame.pack(); } }
No comments:
Post a Comment