List of usage examples for org.jfree.data.xy XYSeriesCollection addSeries
public void addSeries(XYSeries series)
From source file:org.jfree.chart.demo.CrosshairDemo4.java
private static XYDataset createDataset() { XYSeries xyseries = new XYSeries("First"); xyseries.add(1.0D, 1.0D);/*from w ww. j av a2 s .co m*/ xyseries.add(2D, 4D); xyseries.add(3D, 3D); xyseries.add(4D, 5D); xyseries.add(5D, 5D); xyseries.add(6D, 7D); xyseries.add(7D, 7D); xyseries.add(8D, 8D); XYSeries xyseries1 = new XYSeries("Second"); xyseries1.add(1.0D, 5D); xyseries1.add(2D, 7D); xyseries1.add(3D, 6D); xyseries1.add(4D, 8D); xyseries1.add(5D, 4D); xyseries1.add(6D, 4D); xyseries1.add(7D, 2D); xyseries1.add(8D, 1.0D); XYSeries xyseries2 = new XYSeries("Third"); xyseries2.add(3D, 4D); xyseries2.add(4D, 3D); xyseries2.add(5D, 2D); xyseries2.add(6D, 3D); xyseries2.add(7D, 6D); xyseries2.add(8D, 3D); xyseries2.add(9D, 4D); xyseries2.add(10D, 3D); XYSeriesCollection xyseriescollection = new XYSeriesCollection(); xyseriescollection.addSeries(xyseries); xyseriescollection.addSeries(xyseries1); xyseriescollection.addSeries(xyseries2); return xyseriescollection; }
From source file:cachedataanalysis.ReportChartGenerator.java
public static void DrawXYLineChart(String chartName, String xAxis, String yAxis, ArrayList<XYSeries> series) throws IOException { XYSeriesCollection serCol = new XYSeriesCollection(); for (XYSeries _xys : series) { serCol.addSeries(_xys); }/*from w w w.java 2s .c om*/ JFreeChart hitRateStat = ChartFactory.createXYLineChart( "Hit Rate variatoion throughout recording in " + chartName, "Seconds", "HitRate", serCol, PlotOrientation.VERTICAL, true, true, false); ChartUtilities.saveChartAsJPEG(new File("report/" + chartName + ".jpg"), hitRateStat, 1500, 900); }
From source file:org.jfree.chart.demo.PlotOrientationDemo1.java
private static XYDataset createDataset(int i) { XYSeries xyseries = new XYSeries("Series " + (i + 1)); xyseries.add(-10D, -5D);//from www . ja va2s .c o m xyseries.add(10D, 5D); XYSeriesCollection xyseriescollection = new XYSeriesCollection(); xyseriescollection.addSeries(xyseries); return xyseriescollection; }
From source file:org.jfree.chart.demo.AnnotationDemo2.java
private static XYDataset createDataset1() { XYSeries xyseries = new XYSeries("Random Data 1"); xyseries.add(1.0D, 181.80000000000001D); xyseries.add(2D, 167.30000000000001D); xyseries.add(3D, 153.80000000000001D); xyseries.add(4D, 167.59999999999999D); xyseries.add(5D, 158.80000000000001D); xyseries.add(6D, 148.30000000000001D); xyseries.add(7D, 153.90000000000001D); xyseries.add(8D, 142.69999999999999D); xyseries.add(9D, 123.2D);/*from w w w . ja va2 s .c om*/ xyseries.add(10D, 131.80000000000001D); xyseries.add(11D, 139.59999999999999D); xyseries.add(12D, 142.90000000000001D); xyseries.add(13D, 138.69999999999999D); xyseries.add(14D, 137.30000000000001D); xyseries.add(15D, 143.90000000000001D); xyseries.add(16D, 139.80000000000001D); xyseries.add(17D, 137D); xyseries.add(18D, 132.80000000000001D); XYSeriesCollection xyseriescollection = new XYSeriesCollection(); xyseriescollection.addSeries(xyseries); return xyseriescollection; }
From source file:org.jfree.chart.demo.AnnotationDemo2.java
private static XYDataset createDataset2() { XYSeries xyseries = new XYSeries("Random Data 2"); xyseries.add(1.0D, 429.60000000000002D); xyseries.add(2D, 323.19999999999999D); xyseries.add(3D, 417.19999999999999D); xyseries.add(4D, 624.10000000000002D); xyseries.add(5D, 422.60000000000002D); xyseries.add(6D, 619.20000000000005D); xyseries.add(7D, 416.5D);//from w w w. ja va 2 s .c o m xyseries.add(8D, 512.70000000000005D); xyseries.add(9D, 501.5D); xyseries.add(10D, 306.10000000000002D); xyseries.add(11D, 410.30000000000001D); xyseries.add(12D, 511.69999999999999D); xyseries.add(13D, 611D); xyseries.add(14D, 709.60000000000002D); xyseries.add(15D, 613.20000000000005D); xyseries.add(16D, 711.60000000000002D); xyseries.add(17D, 708.79999999999995D); xyseries.add(18D, 501.60000000000002D); XYSeriesCollection xyseriescollection = new XYSeriesCollection(); xyseriescollection.addSeries(xyseries); return xyseriescollection; }
From source file:jamel.gui.charts.AbstractScatterChart.java
/** * Returns a new plot./*from ww w.j a va2s. co m*/ * * @param xySeries the series. * @param xAxisLabel the label of the horizontal axis. * @param yAxisLabel the label of the vertical axis. * @return a new plot. */ static private Plot newPlot(XYSeries xySeries, String xAxisLabel, String yAxisLabel) { final XYSeriesCollection dataset = new XYSeriesCollection(); if (xySeries != null) dataset.addSeries(xySeries); final XYPlot plot = new XYPlot(dataset, new NumberAxis(xAxisLabel), new NumberAxis(yAxisLabel), new XYLineAndShapeRenderer(false, true)); plot.setOrientation(PlotOrientation.VERTICAL); return plot; }
From source file:com.imaging100x.tracker.TrackerUtils.java
/** * Create a frame with a plot of the data given in XYSeries *//* w w w .jav a 2 s . c om*/ public static void plotData(String title, final XYSeries data, String xTitle, String yTitle, int xLocation, int yLocation) { // JFreeChart code XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(data); JFreeChart chart = ChartFactory.createScatterPlot(title, // Title xTitle, // x-axis Label yTitle, // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation false, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); final XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setSeriesPaint(0, Color.black); renderer.setSeriesFillPaint(0, Color.white); renderer.setSeriesLinesVisible(0, true); Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 4.0f, 4.0f); renderer.setSeriesShape(0, circle, false); renderer.setUseFillPaint(true); ChartFrame graphFrame = new ChartFrame(title, chart); graphFrame.getChartPanel().setMouseWheelEnabled(true); graphFrame.setPreferredSize(new Dimension(SIZE, SIZE)); graphFrame.setResizable(true); graphFrame.pack(); graphFrame.setLocation(xLocation, yLocation); graphFrame.setVisible(true); dataset.addChangeListener(new DatasetChangeListener() { public void datasetChanged(DatasetChangeEvent dce) { double xRange = data.getMaxX() - data.getMinX(); double yRange = data.getMaxY() - data.getMinY(); double xAvg = (data.getMaxX() + data.getMinX()) / 2; double yAvg = (data.getMaxY() + data.getMinY()) / 2; double range = xRange; if (yRange > range) { range = yRange; } double offset = 0.55 * range; plot.getDomainAxis().setRange(xAvg - offset, xAvg + offset); plot.getRangeAxis().setRange(yAvg - offset, yAvg + offset); } }); }
From source file:org.matsim.contrib.drt.analysis.DensityScatterPlots.java
public static JFreeChart createPlot(String title, String xAxisLabel, String yAxisLabel, XYSeries series, Pair<Double, Double> lineCoeffs) { XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); double maxValue = Math.max(series.getMaxX(), series.getMaxY()); // y=x//from www . j a v a 2s .c o m XYSeries lineXY = new XYSeries("y = x"); lineXY.add(0, 0); lineXY.add(maxValue, maxValue); dataset.addSeries(lineXY); if (lineCoeffs != null) { // a*y+b=x double a = lineCoeffs.getLeft(); double b = lineCoeffs.getRight(); String namePrefix = a == 0 ? "" : (a + " * y + "); XYSeries lineABXY = new XYSeries(namePrefix + b + " = x"); lineABXY.add(b, 0); if (a == 0) { lineABXY.add(b, maxValue); } else { lineABXY.add(maxValue, (maxValue - b) / a); } dataset.addSeries(lineABXY); } final JFreeChart chart = ChartFactory.createScatterPlot(title, xAxisLabel, yAxisLabel, dataset); XYPlot xyPlot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyPlot.getRenderer(0); renderer.setSeriesPaint(0, new Color(255, 0, 0, 50)); renderer.setSeriesShape(0, CIRCLE); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesVisibleInLegend(0, false); for (int i = 1; i < dataset.getSeriesCount(); i++) { renderer.setSeriesPaint(i, new Color(0, 0, 0)); renderer.setSeriesLinesVisible(i, true); renderer.setSeriesShapesVisible(i, false); renderer.setSeriesVisibleInLegend(i, false); } xyPlot.getDomainAxis().setUpperBound(maxValue); xyPlot.getRangeAxis().setUpperBound(maxValue); xyPlot.getDomainAxis().setLowerBound(0); xyPlot.getRangeAxis().setLowerBound(0); return chart; }
From source file:gov.llnl.lc.infiniband.opensm.plugin.gui.chart.PaintScaleFactory.java
public static ValueAxis getPaintScaleAxis(double lower, double upper, String label) { // return a simple axis for the scale double inc = (upper - lower) / maxDivisions; final XYSeries s1 = new XYSeries("Series 1"); for (int i = 0; i < maxDivisions; i++) { s1.add(i, i * inc);//from w ww .j a va 2 s. c om } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(s1); JFreeChart chart = ChartFactory.createXYLineChart("Axis Demo", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, false); final XYPlot plot = chart.getXYPlot(); final NumberAxis domainAxis = new NumberAxis("xish"); final NumberAxis rangeAxis = new NumberAxis(label); plot.setDomainAxis(domainAxis); plot.setRangeAxis(rangeAxis); return plot.getRangeAxis(); }
From source file:org.jfree.chart.demo.XYStepChartDemo.java
/** * Creates and returns a sample dataset for the XY 'Step' chart. * * @return the sample dataset./*from w ww . j av a 2s. c o m*/ */ public static XYDataset createStepXYDataset() { final int feb = 2; final XYSeries s1 = new XYSeries("Plan 1", false, true); s1.add(DateUtilities.createDate(2002, feb, 19, 8, 0).getTime(), 0); s1.add(DateUtilities.createDate(2002, feb, 19, 8, 1).getTime(), 2); s1.add(DateUtilities.createDate(2002, feb, 19, 9, 5).getTime(), 4); s1.add(DateUtilities.createDate(2002, feb, 19, 10, 6).getTime(), 4); s1.add(DateUtilities.createDate(2002, feb, 19, 11, 6).getTime(), 5); s1.add(DateUtilities.createDate(2002, feb, 19, 12, 6).getTime(), 3); s1.add(DateUtilities.createDate(2002, feb, 19, 13, 6).getTime(), 6); s1.add(DateUtilities.createDate(2002, feb, 19, 14, 6).getTime(), 6); s1.add(DateUtilities.createDate(2002, feb, 19, 15, 30).getTime(), 2); s1.add(DateUtilities.createDate(2002, feb, 19, 16, 7).getTime(), 0); final XYSeries s2 = new XYSeries("Plan 2"); s2.add(DateUtilities.createDate(2002, feb, 19, 8, 40).getTime(), 0); s2.add(DateUtilities.createDate(2002, feb, 19, 8, 45).getTime(), 1); s2.add(DateUtilities.createDate(2002, feb, 19, 9, 0).getTime(), 6); s2.add(DateUtilities.createDate(2002, feb, 19, 10, 6).getTime(), 2); s2.add(DateUtilities.createDate(2002, feb, 19, 10, 45).getTime(), 4); s2.add(DateUtilities.createDate(2002, feb, 19, 12, 0).getTime(), 7); s2.add(DateUtilities.createDate(2002, feb, 19, 13, 0).getTime(), 5); s2.add(DateUtilities.createDate(2002, feb, 19, 14, 6).getTime(), 4); s2.add(DateUtilities.createDate(2002, feb, 19, 15, 15).getTime(), 4); s2.add(DateUtilities.createDate(2002, feb, 19, 16, 0).getTime(), 0); final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(s1); dataset.addSeries(s2); return dataset; }