Example usage for org.jfree.chart ChartFactory createPolarChart

List of usage examples for org.jfree.chart ChartFactory createPolarChart

Introduction

In this page you can find the example usage for org.jfree.chart ChartFactory createPolarChart.

Prototype

public static JFreeChart createPolarChart(String title, XYDataset dataset, boolean legend, boolean tooltips,
        boolean urls) 

Source Link

Document

Creates a polar plot for the specified dataset (x-values interpreted as angles in degrees).

Usage

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createPolarChart("Polar Chart Demo 1", xydataset, true, false, false);
    jfreechart.setBackgroundPaint(Color.white);
    PolarPlot polarplot = (PolarPlot) jfreechart.getPlot();
    polarplot.setBackgroundPaint(Color.lightGray);
    polarplot.addCornerTextItem("Corner Item 1");
    polarplot.addCornerTextItem("Corner Item 2");
    polarplot.setAngleGridlinePaint(Color.white);
    polarplot.setRadiusGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis) polarplot.getAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    return jfreechart;
}

From source file:com.thecoderscorner.groovychart.chart.PolarChart.java

public JFreeChart createChart() {
    JFreeChart chart = ChartFactory.createPolarChart(getTitle(), (XYDataset) getDataset(), isLegend(),
            isTooltips(), isUrls());
    return setExtraProperties(chart);

}

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

public SatelliteRadar() {
    super(null);//from   www.  j  a  va2 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:dao.Graficos.java

public void tipoGrafico(TipoGrafico tipo) {

    switch (tipo) {

    case linear://from   w ww .  j av  a  2 s . c  o m

        grafico = ChartFactory.createXYLineChart(titulo, xx, xy, dados, PlotOrientation.VERTICAL, true, true,
                true);

        break;

    case polar:

        grafico = ChartFactory.createPolarChart(titulo, dados, true, true, true);

        break;

    //            case barras:
    //
    //      
    //
    //                break;
    //            case pizza:
    //
    //                grafico = ChartFactory.createXYStepChart(titulo, xx, xy, dados);
    //
    //                break;
    case area:

        grafico = ChartFactory.createXYStepAreaChart(titulo, xx, xy, dados);

        break;

    }

}

From source file:biz.ixnay.pivot.charts.skin.jfree.PolarChartViewSkin.java

protected JFreeChart createChart() {
    PolarChartView chartView = (PolarChartView) getComponent();
    String title = chartView.getTitle();
    boolean showLegend = chartView.getShowLegend();

    String seriesNameKey = chartView.getSeriesNameKey();
    List<?> chartData = chartView.getChartData();

    JFreeChart chart = ChartFactory.createPolarChart(title, new XYSeriesDataset(seriesNameKey, chartData),
            showLegend, false, false);/*  w w w. j  a va2 s .c o  m*/
    return chart;
}

From source file:edu.ucla.stat.SOCR.chart.demo.PolarChartDemo1.java

/**
 * Creates a sample chart.// w w w .  j ava2  s  .  c o m
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
protected JFreeChart createChart(XYDataset dataset) {

    // create the chart...
    JFreeChart chart = ChartFactory.createPolarChart(chartTitle, dataset, true, false, false);

    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    PolarPlot plot = (PolarPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    if (isDemo) {
        plot.addCornerTextItem("Corner Item 1");
        plot.addCornerTextItem("Corner Item 2");
    }

    plot.setRenderer(new SOCRPolarItemRenderer());
    //PolarItemRenderer renderer = plot.getRenderer();
    //renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

    // set the range axis to display integers only...
    NumberAxis rangeAxis = (NumberAxis) plot.getAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    setXSummary(dataset);
    if (legendPanelOn)
        chart.removeLegend();

    return chart;

}

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

/**
 * Creates a sample chart./*from  w ww . j  av a2 s. c o m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return A sample chart.
 */
private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart chart = ChartFactory.createPolarChart("Polar Chart Demo", dataset, true, true, false);
    final PolarPlot plot = (PolarPlot) chart.getPlot();
    final DefaultPolarItemRenderer renderer = (DefaultPolarItemRenderer) plot.getRenderer();
    renderer.setSeriesFilled(2, true);
    return chart;
}

From source file:com.bdb.weather.display.day.ItemRenderer.java

public WindDirPane() {
    setPrefSize(300, 300);//  ww w . j  a v a  2 s. c o m
    JFreeChart chart = ChartFactory.createPolarChart(null, null, false, true, false);

    ChartFactory.getChartTheme().apply(chart);

    plot = (PolarPlot) chart.getPlot();

    ItemRenderer renderer = new ItemRenderer();
    XYToolTipGenerator ttg = (XYDataset dataset, int series, int item) -> {
        double time = dataset.getXValue(series, item);
        long millis = Math.round(time);
        return "" + millis;
    };
    renderer.setBaseToolTipGenerator(ttg);
    plot.setRenderer(renderer);

    ((NumberAxis) plot.getAxis()).setRange(-240.0, 60.0 * 24);
    ((NumberAxis) plot.getAxis()).setAutoRange(false);
    ((NumberAxis) plot.getAxis()).setTickUnit(new NumberTickUnit(240.0, new DecimalFormat("00")) {
        @Override
        public String valueToString(double number) {
            if (number < 0.0 || (int) number % 240 != 0)
                return "";
            else
                return super.valueToString(number / 60.0);
        }
    });

    ChartViewer chartViewer = new ChartViewer(chart);
    this.setTabContents(chartViewer, table);

    plot.setDataset(new XYSeriesCollection(windDirSeries));

    TableColumn<HistoricalRecord, String> column = new TableColumn<>("Time");
    column.setCellValueFactory((rec) -> new ReadOnlyStringWrapper(
            DisplayConstants.formatTime(rec.getValue().getTime().toLocalTime())));
    table.getColumns().add(column);

    column = new TableColumn<>("Direction");
    column.setCellValueFactory(
            (rec) -> new ReadOnlyStringWrapper(rec.getValue().getAvgWind().getDirection().getCompassLabel()));
    table.getColumns().add(column);
}

From source file:net.sf.jsfcomp.chartcreator.utils.ChartUtils.java

public static JFreeChart createChartWithXYDataSet(ChartData chartData) {
    XYDataset dataset = (XYDataset) chartData.getDatasource();
    String type = chartData.getType();
    String xAxis = chartData.getXlabel();
    String yAxis = chartData.getYlabel();
    boolean legend = chartData.isLegend();

    JFreeChart chart = null;//from  w  w w. j a  v  a  2s  .c  o m
    PlotOrientation plotOrientation = ChartUtils.getPlotOrientation(chartData.getOrientation());

    if (type.equalsIgnoreCase("timeseries")) {
        chart = ChartFactory.createTimeSeriesChart("", xAxis, yAxis, dataset, legend, true, false);
    } else if (type.equalsIgnoreCase("xyline")) {
        chart = ChartFactory.createXYLineChart("", xAxis, yAxis, dataset, plotOrientation, legend, true, false);
    } else if (type.equalsIgnoreCase("polar")) {
        chart = ChartFactory.createPolarChart("", dataset, legend, true, false);
    } else if (type.equalsIgnoreCase("scatter")) {
        chart = ChartFactory.createScatterPlot("", xAxis, yAxis, dataset, plotOrientation, legend, true, false);
    } else if (type.equalsIgnoreCase("xyarea")) {
        chart = ChartFactory.createXYAreaChart("", xAxis, yAxis, dataset, plotOrientation, legend, true, false);
    } else if (type.equalsIgnoreCase("xysteparea")) {
        chart = ChartFactory.createXYStepAreaChart("", xAxis, yAxis, dataset, plotOrientation, legend, true,
                false);
    } else if (type.equalsIgnoreCase("xystep")) {
        chart = ChartFactory.createXYStepChart("", xAxis, yAxis, dataset, plotOrientation, legend, true, false);
    } else if (type.equalsIgnoreCase("bubble")) {
        chart = ChartFactory.createBubbleChart("", xAxis, yAxis, (XYZDataset) dataset, plotOrientation, legend,
                true, false);
    } else if (type.equalsIgnoreCase("candlestick")) {
        chart = ChartFactory.createCandlestickChart("", xAxis, yAxis, (OHLCDataset) dataset, legend);
    } else if (type.equalsIgnoreCase("boxandwhisker")) {
        chart = ChartFactory.createBoxAndWhiskerChart("", xAxis, yAxis, (BoxAndWhiskerXYDataset) dataset,
                legend);
    } else if (type.equalsIgnoreCase("highlow")) {
        chart = ChartFactory.createHighLowChart("", xAxis, yAxis, (OHLCDataset) dataset, legend);
    } else if (type.equalsIgnoreCase("histogram")) {
        chart = ChartFactory.createHistogram("", xAxis, yAxis, (IntervalXYDataset) dataset, plotOrientation,
                legend, true, false);
    } else if (type.equalsIgnoreCase("wind")) {
        chart = ChartFactory.createWindPlot("", xAxis, yAxis, (WindDataset) dataset, legend, true, false);
    }

    if (chart.getPlot() instanceof XYPlot) {
        chart.getXYPlot().setDomainGridlinesVisible(chartData.isDomainGridLines());
        chart.getXYPlot().setRangeGridlinesVisible(chartData.isRangeGridLines());

        if (chartData.getGenerateMap() != null)
            chart.getXYPlot().getRenderer().setURLGenerator(new StandardXYURLGenerator(""));
    }

    setXYSeriesColors(chart, chartData);

    setXYExtensions(chart, chartData);

    return chart;
}

From source file:org.hxzon.demo.jfreechart.XYDatasetDemo.java

private static JFreeChart createPolarChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createPolarChart("Legal & General Unit Trust Prices", // chart title
            dataset, // data
            true, // include legend
            true, // tooltips?
            false // URLs?
    );/*from  w ww . j  a v a 2s.  co m*/

    chart.setBackgroundPaint(Color.white);

    PolarPlot plot = (PolarPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);

    return chart;
}