Example usage for org.jfree.chart.plot XYPlot setRenderer

List of usage examples for org.jfree.chart.plot XYPlot setRenderer

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot setRenderer.

Prototype

public void setRenderer(XYItemRenderer renderer) 

Source Link

Document

Sets the renderer for the primary dataset and sends a change event to all registered listeners.

Usage

From source file:Charts.LineChart.java

@Override
protected JFreeChart createChart(String title, String x, String y) {

    JFreeChart lineChart = this.makeJFreeChart(title, x, y);

    // Custom chart..
    lineChart.setBackgroundPaint(Color.white);

    final XYPlot plot = lineChart.getXYPlot();

    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesShapesVisible(0, false);
    plot.setRenderer(renderer);

    return lineChart;
}

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

/**
 * Creates a chart.//from   www . j  a  v  a2s  .  co m
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
private JFreeChart createChart(final XYDataset dataset) {

    final JFreeChart chart = ChartFactory.createXYAreaChart("XY Area Chart Test", "Domain (X)", "Range (Y)",
            dataset, PlotOrientation.VERTICAL, true, // legend
            true, // tool tips
            false // URLs
    );

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    //plot.setOutlinePaint(Color.black);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setForegroundAlpha(0.65f);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    plot.setRenderer(new XYAreaRenderer2());
    final ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setTickMarkPaint(Color.black);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);

    final ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setTickMarkPaint(Color.black);

    return chart;

}

From source file:de.uniol.ui.tsv.ui.StepChartDialog.java

protected JFreeChart createChart() {
    JFreeChart chart = ChartFactory.createXYStepChartFast(title, xTitle, yTitle, xy, PlotOrientation.VERTICAL,
            true, false, false);/*w  w w.j  ava 2 s  . c  om*/

    chart.setBackgroundPaint(Color.white);
    chart.getLegend().setBackgroundPaint(new Color(224, 224, 224));

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(new Color(224, 224, 224));
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setRenderer(new XYStepRendererFast(null, null));

    XYItemRenderer xyr = plot.getRenderer();
    //      xyr.setBaseToolTipGenerator(new XYToolTipGenerator() {
    //         public String generateToolTip(XYDataset dataset, int series,
    //               int item) {
    //            return nf.format(dataset.getXValue(series, item))
    //                  + tooltipRangeUnits + ", "
    //                  + nf2.format(dataset.getYValue(series, item))
    //                  + tooltipValueUnits;
    //         }
    //      });

    for (int i : seriesStrokes.keySet()) {
        xyr.setSeriesStroke(i, seriesStrokes.get(i));
    }
    for (int i : seriesColors.keySet()) {
        xyr.setSeriesPaint(i, seriesColors.get(i));
    }

    DateAxis da = new DateAxis(xTitle);
    if (useRelativeHourFormat) {
        da.setDateFormatOverride(new RelativeHourFormat());
    }
    da.setLowerMargin(0.03);
    plot.setDomainAxis(da);

    ValueAxis yaxis = plot.getRangeAxis();
    yaxis.setRange(new Range(minRange, maxRange));

    return chart;
}

From source file:net.anthonypoon.fintech.assignment.one.part2.Plotter.java

private void render(boolean showGraph) {
    chart = ChartFactory.createXYLineChart(this.title, "Index Return", "Stock Return", dataObj,
            PlotOrientation.VERTICAL, true, true, false);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    XYPlot plot = chart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShapesVisible(0, true);
    renderer.setSeriesLinesVisible(1, true);
    //renderer.setSeriesShapesVisible(1, false);
    plot.setRenderer(renderer);
    setContentPane(chartPanel);//  www  .  jav  a2  s . co m
    if (showGraph) {
        this.pack();
        RefineryUtilities.centerFrameOnScreen(this);
        this.setVisible(true);
    }
}

From source file:svacee.form.Grafico.java

public JPanel createChartPanel() {

    String chartTitle = "Grfico de Consumo";
    String xAxisLabel = "Hora";
    String yAxisLabel = "Kw/h";

    XYDataset dataset = createDataset();

    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, xAxisLabel, yAxisLabel, dataset);

    XYPlot plot = chart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    plot.setRenderer(renderer);

    return new ChartPanel(chart);
}

From source file:daylightchart.daylightchart.chart.DaylightChart.java

/**
 * Creates the daylight chart./*  ww  w.  j a va 2  s .co  m*/
 */
private void createChart(final Options options) {

    setBackgroundPaint(Color.white);

    final XYPlot plot = getXYPlot();

    // Set the first renderer, so that the grid lines can be shown
    plot.setRenderer(new StandardXYItemRenderer());
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    plot.setBackgroundPaint(ChartConfiguration.nightColor);

    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    createMonthsAxis(plot);
    createHoursAxis(plot);

    // Create a marker region for daylight savings time
    if (riseSetData.usesDaylightTime()) {
        createDSTMarker(plot);
    }

    createBandsInPlot(plot);

    ChartOrientation chartOrientation = ChartOrientation.STANDARD;
    if (options != null) {
        chartOrientation = options.getChartOrientation();
    }
    adjustForChartOrientation(chartOrientation);

    final Options optionsNotNull;
    if (options == null) {
        optionsNotNull = new Options();
    } else {
        optionsNotNull = options;
    }
    createTitles(optionsNotNull.getChartOptions(), ChartConfiguration.chartFont.deriveFont(Font.BOLD, 18));

    createLegend(optionsNotNull, ChartConfiguration.chartFont.deriveFont(Font.PLAIN, 12));

}

From source file:syg_Wykresy.PanelRysunek_Wykres.java

private void initGUI() {
    try {/*ww w  .j a va 2  s. c o m*/
        GridLayout thisLayout = new GridLayout(1, 1);
        thisLayout.setHgap(5);
        thisLayout.setVgap(5);
        thisLayout.setColumns(1);
        this.setLayout(thisLayout);
        setPreferredSize(new Dimension(400, 300));

        if (this.wykres) {

            XYSeries series = new XYSeries("Sygna "
                    + (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.CIAGLY ? "cigy" : "dyskretny"));
            double punkt;
            double ta = this.sygnalWyswietlany.gett1();

            if (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.CIAGLY
                    || sygnalWyswietlany.getPunktyY_wykres().size() <= 0) {
                punkt = this.sygnalWyswietlany.gett1();
                while (ta <= this.sygnalWyswietlany.gett1() + this.sygnalWyswietlany.getd()) {
                    punkt = this.sygnalWyswietlany.wykres_punkty(punkt, ta);
                    this.sygnalWyswietlany.setPunktyY_wykres(punkt);
                    series.add(ta, punkt);
                    if (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.CIAGLY) {
                        if (this.sygnalWyswietlany.gettyp() != 9 && this.sygnalWyswietlany.gettyp() != 10)
                            ta = ta + this.sygnalWyswietlany.getkroczek();
                        else
                            ta = ta + this.sygnalWyswietlany.getkroczek() * 10;
                    } else {
                        if (this.sygnalWyswietlany.gettyp() != 9 && this.sygnalWyswietlany.gettyp() != 10)
                            ta = ta + this.sygnalWyswietlany.getkrok();
                        else
                            ta = ta + this.sygnalWyswietlany.getkrok() * 10;
                    }
                }
            } else if (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.DYSKRETNY
                    && sygnalWyswietlany.getPunktyY_wykres().size() > 0) {
                int iloscProbek = (int) (this.sygnalWyswietlany.getPunktyY_wykres().size());
                for (int i = 0; i < iloscProbek; i++) {
                    punkt = this.sygnalWyswietlany.getPunktzindexu(i);
                    series.add(ta, punkt);
                    ta = ta + this.sygnalWyswietlany.getkrok();
                }
            }

            XYSeriesCollection dataset = new XYSeriesCollection(series);
            JFreeChart chart;

            if ((this.sygnalWyswietlany.gettyp() != 9 && this.sygnalWyswietlany.gettyp() != 10)
                    && (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.CIAGLY)) {
                chart = ChartFactory.createXYLineChart(null, null, null, dataset, PlotOrientation.VERTICAL,
                        true, true, true);

                final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
                renderer.setSeriesLinesVisible(0, false);
            } else {
                chart = ChartFactory.createXYLineChart(null, null, null, dataset, PlotOrientation.VERTICAL,
                        true, true, true);

                final XYPlot plot = chart.getXYPlot();
                final XYDotRenderer renderer = new XYDotRenderer();
                renderer.setDotHeight(3);
                renderer.setDotWidth(3);
                plot.setRenderer(renderer);

                final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
                rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            }

            // JOptionPane.showMessageDialog(null, "Rysowanie wykresu...",
            // "PanelRysunek_Wykres", JOptionPane.INFORMATION_MESSAGE);

            ChartPanel chartpanel = new ChartPanel(chart);
            chartpanel.setDomainZoomable(true);

            this.add(chartpanel);
        }

        Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(this);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:es.unex.meigas.extFillData.FittingDataPanel.java

private void createChart() {

    updateDataset();/*from w w w .  ja v  a  2s . c  o  m*/

    chart = ChartFactory.createScatterPlot(null, m_sParameters[m_XY.x], m_sParameters[m_XY.y], m_Data1,
            PlotOrientation.VERTICAL, false, true, true);

    final XYPlot plot = chart.getXYPlot();
    plot.setRenderer(new XYDotRenderer());
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    plot.getRenderer().setSeriesPaint(0, Color.blue);

    final XYItemRenderer renderer = new StandardXYItemRenderer();
    renderer.setSeriesPaint(0, Color.red);

    plot.setDataset(1, m_Data2);
    plot.setRenderer(1, renderer);

}

From source file:bzstats.chart.KillRatioHistoryChart.java

protected JFreeChart getChart() {

    DefaultTableXYDataset dataset = new DefaultTableXYDataset();

    fillDataset(dataset);//from   ww w .jav a2 s  .c  o  m

    XYPlot plot = new XYPlot();

    NumberAxis xaxis = new NumberAxis("Time");
    xaxis.setTickLabelsVisible(false);
    NumberAxis yaxis = new NumberAxis("Killratio");

    plot.setDomainAxis(xaxis);
    plot.setRangeAxis(yaxis);
    plot.setDataset(dataset);
    plot.setRenderer(new StandardXYItemRenderer(StandardXYItemRenderer.LINES));

    JFreeChart chart = new JFreeChart("Killratio", JFreeChart.DEFAULT_TITLE_FONT, plot, true);

    chart.addSubtitle(new TextTitle("kills/deaths"));

    chart.setBackgroundPaint(Color.white);

    return chart;

}

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

private JFreeChart createChart(final XYDataset dataset) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createXYLineChart("Line Chart", // chart title
            "X", // x axis label
            "Y", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );//from w  ww.  j a  v  a 2 s . c o  m

    chart.setBackgroundPaint(Color.white);

    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShapesVisible(1, false);
    plot.setRenderer(renderer);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    return chart;

}