List of usage examples for org.jfree.chart ChartFactory createTimeSeriesChart
public static JFreeChart createTimeSeriesChart(String title, String timeAxisLabel, String valueAxisLabel, XYDataset dataset, boolean legend, boolean tooltips, boolean urls)
From source file:org.jfree.chart.demo.JDBCXYChartDemo.java
public JDBCXYChartDemo(String s) { super(s);/* ww w .j a v a 2s . c o m*/ XYDataset xydataset = readData(); JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("JDBC XY Chart Demo", "Date", "Value", xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.yellow); ChartPanel chartpanel = new ChartPanel(jfreechart); setContentPane(chartpanel); }
From source file:org.jfree.chart.demo.DifferenceChartDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Difference Chart Demo 1", "Time", "Value", xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); XYDifferenceRenderer xydifferencerenderer = new XYDifferenceRenderer(Color.green, Color.red, false); xydifferencerenderer.setRoundXCoordinates(true); xyplot.setDomainCrosshairLockedOnData(true); xyplot.setRangeCrosshairLockedOnData(true); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); xyplot.setRenderer(xydifferencerenderer); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); DateAxis dateaxis = new DateAxis("Time"); dateaxis.setLowerMargin(0.0D);//w ww . ja v a 2s. c om dateaxis.setUpperMargin(0.0D); xyplot.setDomainAxis(dateaxis); xyplot.setForegroundAlpha(0.5F); return jfreechart; }
From source file:org.jfree.chart.demo.PriceVolumeDemo1.java
private static JFreeChart createChart() { XYDataset xydataset = createPriceDataset(); String s = "Eurodollar Futures Contract (MAR03)"; JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(s, "Date", "Price", xydataset, true, true, false);/* w w w . j ava 2 s .c o m*/ XYPlot xyplot = (XYPlot) jfreechart.getPlot(); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setLowerMargin(0.40000000000000002D); DecimalFormat decimalformat = new DecimalFormat("00.00"); numberaxis.setNumberFormatOverride(decimalformat); XYItemRenderer xyitemrenderer = xyplot.getRenderer(); xyitemrenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: ({1}, {2})", new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00"))); NumberAxis numberaxis1 = new NumberAxis("Volume"); numberaxis1.setUpperMargin(1.0D); xyplot.setRangeAxis(1, numberaxis1); xyplot.setDataset(1, createVolumeDataset()); xyplot.setRangeAxis(1, numberaxis1); xyplot.mapDatasetToRangeAxis(1, 1); XYBarRenderer xybarrenderer = new XYBarRenderer(0.20000000000000001D); xybarrenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: ({1}, {2})", new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0,000.00"))); xyplot.setRenderer(1, xybarrenderer); return jfreechart; }
From source file:org.jfree.chart.demo.XYDrawableAnnotationDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("XYDrawableAnnotationDemo1", null, "$ million", xydataset, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setDomainPannable(true);//from w w w . j a v a 2 s .c o m xyplot.setRangePannable(true); DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setLowerMargin(0.20000000000000001D); dateaxis.setUpperMargin(0.20000000000000001D); dateaxis.setStandardTickUnits(createStandardDateTickUnits()); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setLowerMargin(0.20000000000000001D); numberaxis.setUpperMargin(0.20000000000000001D); XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(); xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseLinesVisible(true); xylineandshaperenderer.setSeriesShape(0, new java.awt.geom.Ellipse2D.Double(-5D, -5D, 10D, 10D)); xylineandshaperenderer.setSeriesShape(1, new java.awt.geom.Ellipse2D.Double(-5D, -5D, 10D, 10D)); xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(3F)); xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(3F, 1, 1, 5F, new float[] { 10F, 5F }, 0.0F)); xylineandshaperenderer.setSeriesFillPaint(0, Color.white); xylineandshaperenderer.setSeriesFillPaint(1, Color.white); xylineandshaperenderer.setUseFillPaint(true); xylineandshaperenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); xylineandshaperenderer.setDefaultEntityRadius(6); xylineandshaperenderer.addAnnotation(new XYDrawableAnnotation((new Month(4, 2005)).getFirstMillisecond(), 600D, 180D, 100D, 3D, createPieChart())); xylineandshaperenderer.addAnnotation(new XYDrawableAnnotation((new Month(9, 2007)).getFirstMillisecond(), 1250D, 120D, 100D, 2D, createBarChart())); xyplot.setRenderer(xylineandshaperenderer); return jfreechart; }
From source file:org.jfree.chart.demo.DeviationRendererDemo2.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Projected Values - Test", "Date", "Index Projection", xydataset, true, true, false); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setInsets(new RectangleInsets(5D, 5D, 5D, 20D)); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); //// w w w . ja v a 2 s. c o m DeviationRenderer renderer = new DeviationRenderer(true, false); renderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1)); renderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1)); renderer.setSeriesStroke(1, new BasicStroke(3F, 1, 1)); renderer.setSeriesFillPaint(0, new Color(255, 200, 200)); renderer.setSeriesFillPaint(1, new Color(200, 200, 255)); plot.setRenderer(renderer); // NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis(); valueAxis.setAutoRangeIncludesZero(false); valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:org.jfree.chart.demo.MouseListenerDemo3.java
public MouseListenerDemo3(String s) { super(s);/*from ww w .j a v a 2 s .co m*/ String s1 = "Legal & General Unit Trust Prices"; XYDataset xydataset = createDataset(); chart = ChartFactory.createTimeSeriesChart(s1, "Date", "Price Per Unit", xydataset, true, true, false); chart.addSubtitle(new TextTitle("Click on the legend to see series highlighted...")); XYPlot xyplot = (XYPlot) chart.getPlot(); DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); ChartPanel chartpanel = new ChartPanel(chart); chartpanel.setPreferredSize(new Dimension(500, 270)); chartpanel.setMouseZoomable(true, false); chartpanel.addChartMouseListener(this); setContentPane(chartpanel); }
From source file:application.TrendPlot.java
/** * initialiser plottet//from w w w .j av a 2 s .c om */ private void initialize() { TimeSeriesCollection dataset = new TimeSeriesCollection(timeSeries); JFreeChart chart = ChartFactory.createTimeSeriesChart(plotName, "Time", "Error Value", dataset, true, true, false); final XYPlot plot = chart.getXYPlot(); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(20000.0); label = new ChartPanel(chart); }
From source file:com.thecoderscorner.groovychart.chart.TimeseriesChart.java
public JFreeChart createChart() { JFreeChart chart = ChartFactory.createTimeSeriesChart(this.getTitle(), this.getTimeAxisLabel(), this.getValueAxisLabel(), (XYDataset) this.getDataset(), this.isLegend(), this.isTooltips(), this.isUrls()); return setExtraProperties(chart); }
From source file:com.tencent.wstt.apt.chart.CPURealTimeChart.java
@Override public JFreeChart createChart() { final JFreeChart chart = ChartFactory.createTimeSeriesChart("CPU", "", "CPU%", dataset, true, true, false);//from w w w .java2 s . c o m //?? chart.getTitle().setFont(new Font("", Font.BOLD, 20)); XYPlot xyPlot = (XYPlot) chart.getXYPlot(); ValueAxis domainAxis = xyPlot.getDomainAxis(); ValueAxis rangeAxis = xyPlot.getRangeAxis(); domainAxis.setLabelFont(new Font("", Font.BOLD, 14)); domainAxis.setTickLabelFont(new Font("", Font.BOLD, 12)); rangeAxis.setLabelFont(new Font("", Font.BOLD, 14)); rangeAxis.setTickLabelFont(new Font("", Font.BOLD, 12)); return chart; }
From source file:com.tencent.wstt.apt.chart.MemoryRealTimeChart.java
@Override public JFreeChart createChart() { final JFreeChart chart = ChartFactory.createTimeSeriesChart("", "", "kB", dataset, true, true, false); //??// w ww. j a v a 2 s .c o m chart.getTitle().setFont(new Font("", Font.BOLD, 20)); XYPlot xyPlot = (XYPlot) chart.getXYPlot(); ValueAxis domainAxis = xyPlot.getDomainAxis(); ValueAxis rangeAxis = xyPlot.getRangeAxis(); domainAxis.setLabelFont(new Font("", Font.BOLD, 14)); domainAxis.setTickLabelFont(new Font("", Font.BOLD, 12)); rangeAxis.setLabelFont(new Font("", Font.BOLD, 14)); rangeAxis.setTickLabelFont(new Font("", Font.BOLD, 12)); //rangeAxis.setAutoRange(true); //rangeAxis.setAutoTickUnitSelection(true); return chart; }