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:com.geminimobile.chart.GeminiChartUtil.java
public void createReport(OutputStream out, List<ChartSeries> chartData, String strTitle, String strDomainAxisLabel) { strDomainAxisLabel = "Time Interval: " + strDomainAxisLabel; String strYAxisLabel;//from w ww . j a v a 2s.c o m //String strCategoryType = " "; strYAxisLabel = "Count"; //SimpleDateFormat sdf = new SimpleDateFormat("MMMM-dd hh:mm a"); //build a dataset as needed by JFreeChart // note: strCategoryType is for a chart with multiple categories. // i.e. idisplay multiple bars for each time interval. // TimeSeriesCollection dataSet = new TimeSeriesCollection(); // For each series of data, create a TimeSeries for (int i = 0; i < chartData.size(); i++) { ChartSeries chartSeries = chartData.get(i); TimeSeries timeSeries = new TimeSeries(chartSeries.getName(), Millisecond.class); List<ChartValueByTime> data = chartSeries.getData(); //int cumulValue = 0; for (int j = 0; j < data.size(); j++) { ChartValueByTime chartVal = data.get(j); Millisecond ms = new Millisecond(new Date(chartVal.getTime())); // *NOT* Store the cumulative value . So maintain a running total. //cumulValue += chartVal.getValue(); //timeSeries.add(ms, cumulValue); timeSeries.add(ms, chartVal.getValue()); } dataSet.addSeries(timeSeries); } JFreeChart lineChart = ChartFactory.createTimeSeriesChart(strTitle, // chart title strDomainAxisLabel, // domain axis label strYAxisLabel, // range axis label dataSet, // data true, // legend false, // tooltips false // urls ); try { ChartUtilities.writeChartAsPNG(out, lineChart, 800, 400); } catch (IOException e) { e.printStackTrace(); } }
From source file:org.operamasks.faces.render.graph.LineChartRenderer.java
protected JFreeChart createChart(UIChart comp) { Dataset dataset = createDataset(comp); JFreeChart chart = null;/*from ww w . ja va 2 s. c om*/ if (dataset instanceof CategoryDataset) { if (comp.isEffect3D()) { chart = ChartFactory.createLineChart3D(null, null, null, (CategoryDataset) dataset, getChartOrientation(comp), false, false, false); } else { chart = ChartFactory.createLineChart(null, null, null, (CategoryDataset) dataset, getChartOrientation(comp), false, false, false); } } else if (dataset instanceof TimeSeriesCollection) { chart = ChartFactory.createTimeSeriesChart(null, null, null, (XYDataset) dataset, false, false, false); ((XYPlot) chart.getPlot()).setOrientation(getChartOrientation(comp)); } else if (dataset instanceof XYDataset) { chart = ChartFactory.createXYLineChart(null, null, null, (XYDataset) dataset, getChartOrientation(comp), false, false, false); } return chart; }
From source file:Business.Chart.ChartRespiratory.java
private JFreeChart createChart(final XYDataset dataset) { return ChartFactory.createTimeSeriesChart("Respiratory Rate", "Seconds", "Value", dataset, false, false, false);//from ww w . j av a 2 s. co m }
From source file:org.jfree.chart.demo.TimeSeriesDemo9.java
/** * A demonstration application showing how to create a simple time series chart. This * example uses monthly data.//w w w. j a va 2 s . c om * * @param title the frame title. */ public TimeSeriesDemo9(final String title) { super(title); // create a title... final String chartTitle = "Test"; final XYDataset dataset = createDataset(); final JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, "Date", "Price Per Unit", dataset, true, true, false); // final StandardLegend sl = (StandardLegend) chart.getLegend(); // sl.setDisplaySeriesShapes(true); final XYPlot plot = chart.getXYPlot(); final XYItemRenderer r = plot.getRenderer(); if (r instanceof StandardXYItemRenderer) { final StandardXYItemRenderer renderer = (StandardXYItemRenderer) r; renderer.setPlotShapes(true); renderer.setShapesFilled(true); renderer.setSeriesShape(0, new Ellipse2D.Double(-3.0, -3.0, 6.0, 6.0)); renderer.setSeriesShape(1, new Rectangle2D.Double(-3.0, -3.0, 6.0, 6.0)); final GeneralPath s2 = new GeneralPath(); s2.moveTo(0.0f, -3.0f); s2.lineTo(3.0f, 3.0f); s2.lineTo(-3.0f, 3.0f); s2.closePath(); renderer.setSeriesShape(2, s2); final GeneralPath s3 = new GeneralPath(); s3.moveTo(-1.0f, -3.0f); s3.lineTo(1.0f, -3.0f); s3.lineTo(1.0f, -1.0f); s3.lineTo(3.0f, -1.0f); s3.lineTo(3.0f, 1.0f); s3.lineTo(1.0f, 1.0f); s3.lineTo(1.0f, 3.0f); s3.lineTo(-1.0f, 3.0f); s3.lineTo(-1.0f, 1.0f); s3.lineTo(-3.0f, 1.0f); s3.lineTo(-3.0f, -1.0f); s3.lineTo(-1.0f, -1.0f); s3.closePath(); renderer.setSeriesShape(3, s3); } plot.getDomainAxis().setVisible(false); plot.getRangeAxis().setVisible(false); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:ws.moor.bt.gui.charts.ConnectionTypes.java
private JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Connection Types", "Time", "Connections", dataset, true, false, false);/*from w ww .j a v a2 s . co m*/ chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); return chart; }
From source file:org.activequant.util.charting.Chart.java
/** * overloaded constructor. //from w w w . j ava 2s . c o m * @param timeAxisLabel * @param valueAxisLabel */ public Chart(String timeAxisLabel, String valueAxisLabel) { chart = ChartFactory.createTimeSeriesChart(null, timeAxisLabel, valueAxisLabel, null, true, false, false); }
From source file:greenapi.ui.charts.LineChartPanelSupport.java
@Override public JFreeChart createChart() { this.timeSeries = new TimeSeriesCollection(); this.dataset = new TranslatingXYDataset(this.timeSeries); JFreeChart chart = ChartFactory.createTimeSeriesChart(this.getTitle(), null, this.getAxisLabel(), this.dataset, true, true, false); chart.setBackgroundPaint(getBackground()); XYPlot xyPlot = chart.getXYPlot();/* w w w.j a v a 2 s. co m*/ xyPlot.setOrientation(PlotOrientation.VERTICAL); xyPlot.setBackgroundPaint(Color.WHITE); xyPlot.setDomainGridlinePaint(Color.BLACK.darker()); xyPlot.setRangeGridlinePaint(Color.BLACK.darker()); xyPlot.setAxisOffset(new RectangleInsets(5.0D, 5.0D, 5.0D, 5.0D)); xyPlot.setDomainCrosshairLockedOnData(true); xyPlot.setRangeCrosshairVisible(true); chart.setAntiAlias(true); return chart; }
From source file:subterranean.crimson.server.graphics.graphs.LineChart.java
private JFreeChart createChart(final XYDataset dataset) { final JFreeChart result = ChartFactory.createTimeSeriesChart("", "", "", dataset, false, false, false); XYPlot plot = result.getXYPlot();/* w ww. j a v a 2s . co m*/ plot.setDataset(1, new TimeSeriesCollection(s2)); plot.setBackgroundPaint(new Color(0x000000)); plot.setDomainGridlinesVisible(false); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinesVisible(false); plot.setRangeGridlinePaint(Color.lightGray); ValueAxis xaxis = plot.getDomainAxis(); xaxis.setAutoRange(true); xaxis.setFixedAutoRange(160000.0); // 160 seconds xaxis.setVerticalTickLabels(false); ValueAxis yaxis = plot.getRangeAxis(); yaxis.setAutoRange(true); yaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return result; }
From source file:org.spf4j.perf.impl.chart.Charts.java
private static JFreeChart createJFreeChart(final String chartName, final String uom, final XYDataset timeseriescollection) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(chartName, "Time", uom, timeseriescollection, true, true, false);/*from w w w .jav a 2s.c o m*/ XYPlot xyplot = (XYPlot) jfreechart.getPlot(); DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setVerticalTickLabels(true); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setUseFillPaint(true); xylineandshaperenderer.setLegendItemToolTipGenerator(new StandardXYSeriesLabelGenerator("Tooltip {0}")); return jfreechart; }
From source file:com.mxgraph.examples.swing.chart.TimeSeriesChartDemo1.java
/** * Creates a chart./* w w w . j a va2 s. c o m*/ * * @param dataset a dataset. * * @return A chart. */ public static JFreeChart createChart(XYDataset dataset, String name) { JFreeChart chart = ChartFactory.createTimeSeriesChart(name, // title "Date", // x-axis label "Value", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); renderer.setItemLabelGenerator(new StandardXYItemLabelGenerator()); renderer.setBaseItemLabelsVisible(true); // renderer.setItemLabelsVisible(true); // renderer.setBaseShapesVisible(true); // renderer.setBaseShapesFilled(true); // renderer.setLegendItemLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})")); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss"/*"yyyy-MM-dd HH:mm:ss"*/)); chart.getTitle().setFont(new Font("", Font.BOLD, 15)); chart.getLegend().setItemFont(new Font("", Font.BOLD, 15)); // plot.getRangeAxis().setLabelFont(new Font("", Font.BOLD, 15)); // chart.getLegend().setItemFont(new Font("", Font.ITALIC, 15)); // plot.getDomainAxis().setTickLabelFont(new Font("", 1, 15)); // plot.getDomainAxis().setLabelFont(new Font("", 1, 12)); return chart; }