Example usage for org.jfree.data.xy XYSeriesCollection XYSeriesCollection

List of usage examples for org.jfree.data.xy XYSeriesCollection XYSeriesCollection

Introduction

In this page you can find the example usage for org.jfree.data.xy XYSeriesCollection XYSeriesCollection.

Prototype

public XYSeriesCollection() 

Source Link

Document

Constructs an empty dataset.

Usage

From source file:com.spotify.heroic.http.render.RenderUtils.java

public static JFreeChart createChart(final List<ShardedResultGroup> groups, final String title,
        Map<String, String> highlight, Double threshold, int height) {
    final XYLineAndShapeRenderer lineAndShapeRenderer = new XYLineAndShapeRenderer(true, true);
    final DeviationRenderer intervalRenderer = new DeviationRenderer();

    final XYSeriesCollection regularData = new XYSeriesCollection();
    final YIntervalSeriesCollection intervalData = new YIntervalSeriesCollection();

    int lineAndShapeCount = 0;
    int intervalCount = 0;

    for (final ShardedResultGroup resultGroup : groups) {
        final MetricCollection group = resultGroup.getMetrics();

        if (group.getType() == MetricType.POINT) {
            final XYSeries series = new XYSeries(resultGroup.getMetrics().toString());

            final List<Point> data = group.getDataAs(Point.class);

            for (final Point d : data) {
                series.add(d.getTimestamp(), d.getValue());
            }/*from  ww w . ja v  a 2s . c  om*/

            lineAndShapeRenderer.setSeriesPaint(lineAndShapeCount, Color.BLUE);
            lineAndShapeRenderer.setSeriesShapesVisible(lineAndShapeCount, false);
            lineAndShapeRenderer.setSeriesStroke(lineAndShapeCount, new BasicStroke(2.0f));
            regularData.addSeries(series);
            ++lineAndShapeCount;
        }

        if (group.getType() == MetricType.SPREAD) {
            final YIntervalSeries series = new YIntervalSeries(resultGroup.getMetrics().toString());

            final List<Spread> data = group.getDataAs(Spread.class);

            for (final Spread d : data) {
                series.add(d.getTimestamp(), d.getSum() / d.getCount(), d.getMin(), d.getMax());
            }

            intervalRenderer.setSeriesPaint(intervalCount, Color.GREEN);
            intervalRenderer.setSeriesStroke(intervalCount, new BasicStroke(2.0f));
            intervalRenderer.setSeriesFillPaint(intervalCount, new Color(200, 255, 200));
            intervalRenderer.setSeriesShapesVisible(intervalCount, false);
            intervalData.addSeries(series);
            ++intervalCount;
        }
    }

    final JFreeChart chart = buildChart(title, regularData, intervalData, lineAndShapeRenderer,
            intervalRenderer);

    chart.setAntiAlias(true);
    chart.setBackgroundPaint(Color.WHITE);

    final XYPlot plot = chart.getXYPlot();

    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.BLACK);
    plot.setRangeGridlinePaint(Color.BLACK);

    if (threshold != null) {
        final ValueMarker marker = new ValueMarker(threshold, Color.RED,
                new BasicStroke(Math.max(Math.min(height / 20, 6), 1)), Color.RED, null, 0.5f);
        plot.addRangeMarker(marker);
    }

    plot.setRenderer(lineAndShapeRenderer);

    // final DateAxis rangeAxis = (DateAxis) plot.getRangeAxis();
    // rangeAxis.setStandardTickUnits(DateAxis.createStandardDateTickUnits());

    return chart;
}

From source file:org.jfree.chart.demo.MouseListenerDemo4.java

public XYDataset createDataset() {
    XYSeries xyseries = new XYSeries("Series 1");
    xyseries.add(12.5D, 11D);//from  ww  w . j  av a  2s.  co  m
    xyseries.add(15D, 9.3000000000000007D);
    xyseries.add(20D, 21D);
    XYSeriesCollection xyseriescollection = new XYSeriesCollection();
    xyseriescollection.addSeries(xyseries);
    return xyseriescollection;
}

From source file:org.owasp.benchmark.score.report.ScatterInterpretation.java

private JFreeChart display(String title, int height) {
    JFrame f = new JFrame(title);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    XYSeriesCollection dataset = new XYSeriesCollection();
    chart = ChartFactory.createScatterPlot(title, "False Positive Rate", "True Positive Rate", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    theme.apply(chart);/*  w w  w. j  a v a 2s  .c  o m*/

    XYPlot xyplot = chart.getXYPlot();
    initializePlot(xyplot);

    makePointer(xyplot, 7, 93, " Ideal vulnerability detection", TextAnchor.TOP_LEFT, 45);
    makePointer(xyplot, 10, 10, " Tool reports nothing is vulnerable", TextAnchor.TOP_LEFT, 45);
    // makePointer( xyplot, 70, 30, " Worse than random", TextAnchor.TOP_LEFT, 45 );
    makePointer(xyplot, 90, 90, "Tool reports everything is vulnerable ", TextAnchor.TOP_LEFT, 45);
    // makePointer( xyplot, 50, 50, "Tool reports vulnerabilities randomly ", TextAnchor.BOTTOM_RIGHT, 225);
    makePointer(xyplot, 50, 50, "Tool reports vulnerabilities randomly ", TextAnchor.TOP_LEFT, 45);

    makeOval(xyplot, 0, 3, 20, 10, 45);
    makeOval(xyplot, 42, 3, 20, 10, 45);
    makeOval(xyplot, 84, 3, 20, 10, 45);
    makeOval(xyplot, 43, 64, 20, 10, 45);

    ChartPanel cp = new ChartPanel(chart, height, height, 400, 400, 1200, 1200, false, false, false, false,
            false, false);
    f.add(cp);
    f.pack();
    f.setLocationRelativeTo(null);
    // f.setVisible(true);
    return chart;
}

From source file:xdevs.lib.util.ScopeView.java

public ScopeView(String windowsTitle, String title, String xTitle, String yTitle) {
    super(windowsTitle);
    XYSeriesCollection dataSet = new XYSeriesCollection();
    serie = new XYSeries(yTitle);
    dataSet.addSeries(serie);// w w  w .jav a  2s .co  m
    JFreeChart chart = ChartFactory.createXYStepChart(title, xTitle, yTitle, dataSet, PlotOrientation.VERTICAL,
            true, false, false);
    chart.getXYPlot().setDomainAxis(new NumberAxis());
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    chartPanel.setMouseZoomable(true, false);
    setContentPane(chartPanel);
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            dispose();
        }
    });
    super.pack();
    RefineryUtilities.centerFrameOnScreen(this);
    this.setVisible(true);
}

From source file:com.windows.Chart.java

public static XYDataset createDataset() {
    XYSeries xyseries1 = new XYSeries("FCFS");
    xyseries1.add(1987, 50);/*  w  w  w  . ja v a2  s  . c  o m*/
    xyseries1.add(1997, 20);
    xyseries1.add(2007, 30);

    XYSeries xyseries2 = new XYSeries("Two");
    xyseries2.add(1987, 20);
    xyseries2.add(1997, 10D);
    xyseries2.add(2007, 40D);

    XYSeries xyseries3 = new XYSeries("Three");
    xyseries3.add(1987, 40);
    xyseries3.add(1997, 30.0008);
    xyseries3.add(2007, 38.24);

    XYSeriesCollection xySeriesCollection = new XYSeriesCollection();
    xySeriesCollection.addSeries(xyseries1);
    xySeriesCollection.addSeries(xyseries2);
    xySeriesCollection.addSeries(xyseries3);
    return xySeriesCollection;
}

From source file:scheduler.benchmarker.manager.CreateSimpleSplineChart.java

private XYDataset createDataset() {
    XYSeries cpuTime = new XYSeries(sName + ": CPU");
    XYSeries ioTime = new XYSeries(sName + ": IO");
    double i = 0D;

    for (PlanningResult planningResult : dataSource) {
        cpuTime.add(i, planningResult.getTotalCPUTime());
        ioTime.add(i, planningResult.getTotalIOTime());
        i++;//from  w ww. j a v  a  2  s .  com
    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(cpuTime);
    dataset.addSeries(ioTime);
    return dataset;
}

From source file:br.prof.salesfilho.oci.image.GraphicBuilder.java

public GraphicBuilder(final String title) {
    super(title);
    this.title = title;
    dataSet = collectionDataset = new XYSeriesCollection();
    chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);//w ww .j av  a2s .  c  o  m
}

From source file:statistic.graph.JChartPanel.java

protected static JFreeChart createChart() {
    stepDataset = new XYSeriesCollection();
    linearDataset = new XYSeriesCollection();

    chart = ChartFactory.createXYLineChart("Fluss", "Zeiteinheiten", "Flusseinheiten", stepDataset,
            PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(Color.WHITE);

    plot = (XYPlot) chart.getPlot();//  w w  w .  j a v a2  s  .co m
    plot.setBackgroundPaint(Color.LIGHT_GRAY);
    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);

    plot.setDataset(0, stepDataset);
    plot.setDataset(1, linearDataset);

    XYItemRenderer r = plot.getRenderer();
    //r.setBaseOutlinePaint(Color.BLACK);
    //r.setBasePaint();
    //r.setItemLabelPaint();
    //r.setOutlinePaint(Color.BLACK);
    //r.setSeriesItemLabelPaint();
    //r.setSeriesOutlinePaint();
    r.setSeriesPaint(0, Color.GREEN.darker());
    r.setSeriesPaint(1, Color.MAGENTA.darker());
    if (r instanceof XYLineAndShapeRenderer) {
        XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(true);
        renderer.setBaseShapesFilled(true);
    }
    //XYStepRenderer r3 = new XYStepRenderer();
    //r.setBaseOutlinePaint(Color.BLACK);
    //r.setBasePaint();
    //r.setItemLabelPaint();
    //r.setOutlinePaint(Color.BLACK);
    //r.setSeriesItemLabelPaint();
    //r.setSeriesOutlinePaint();
    //r3.setSeriesPaint(0, Color.BLACK);
    //r3.setShapesVisible(true);
    //r3.setShapesFilled(true);
    //r3.setSeriesShapesFilled(0,true);
    //r3.set
    //r3.setSeriesStroke(0, new BasicStroke(2.0f));

    XYItemRenderer r2 = new XYStepRenderer();
    r2.setSeriesPaint(2, Color.BLACK);
    plot.setRenderer(r2);
    plot.setRenderer(1, r);
    //plot.setRenderer(2, r3);

    plot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    plot.getDomainAxis().setRange(-0.5, 10);

    plot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    plot.getRangeAxis().setRange(-0.5, 8.5);

    return chart;
}

From source file:it.alus.GPSreceiver.instruments.SatelliteRadar.java

public SatelliteRadar() {
    super(null);/*ww  w . j  a v a 2  s . c  o m*/
    azimuth = new int[MAX_SAT];
    elevation = new int[MAX_SAT];
    snr = new int[MAX_SAT];
    resetArray();
    satSeries = new XYSeries("Satellites");
    XYSeriesCollection seriescollection = new XYSeriesCollection();
    seriescollection.addSeries(satSeries);
    jChart = ChartFactory.createPolarChart("Satellites", seriescollection, true, false, false);
    jChart.setBackgroundPaint(Color.white);
    PolarPlot polarplot = (PolarPlot) jChart.getPlot();
    polarplot.setBackgroundPaint(Color.lightGray);
    polarplot.setAngleGridlinePaint(Color.white);
    polarplot.setRadiusGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis) polarplot.getAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    super.setChart(jChart);
    super.setMouseZoomable(false);
    super.setPreferredSize(new Dimension(500, 270));
}

From source file:eu.choreos.vv.chart.XYChart.java

public static ChartPanel createChart(String chartTitle, List<PlotData> reports, String xLabel, String yLabel) {
    XYSeriesCollection dataset = new XYSeriesCollection();

    for (PlotData report : reports) {
        createDataset(dataset, (LineData) report);
    }/* w  w  w  .  j  a v a2s  .c o m*/
    JFreeChart chart = createChart(dataset, chartTitle, xLabel, yLabel);
    ChartPanel panel = new ChartPanel(chart);
    return panel;
}