Example usage for org.jfree.chart.plot PiePlot setNoDataMessage

List of usage examples for org.jfree.chart.plot PiePlot setNoDataMessage

Introduction

In this page you can find the example usage for org.jfree.chart.plot PiePlot setNoDataMessage.

Prototype

public void setNoDataMessage(String message) 

Source Link

Document

Sets the message that is displayed when the dataset is empty or null, and sends a PlotChangeEvent to all registered listeners.

Usage

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

/**
 * Creates a sample chart.//  www.ja  va  2s .  c  o  m
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
protected JFreeChart createChart(PieDataset dataset) {
    JFreeChart chart = ChartFactory.createPieChart(chartTitle, // chart title
            dataset, // dataset
            !legendPanelOn, // include legend
            true, false);

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setNoDataMessage("No data available");

    for (int i = 0; i < pulloutFlag.length; i++) {
        //System.out.println("\""+pulloutFlag[i]+"\"");
        if (isPullout(i)) {
            Comparable key = dataset.getKey(i);
            plot.setExplodePercent(key, 0.30);
        }
    }

    plot.setLegendLabelToolTipGenerator(new StandardPieSectionLabelGenerator("Tooltip for legend item {0}"));

    if (rotateOn) {
        Rotator rotator = new Rotator(plot);
        rotator.start();
    }

    setCategorySummary(dataset);
    return chart;
}

From source file:org.sonar.server.charts.deprecated.PieChart.java

private void configurePlot() {
    PiePlot plot = (PiePlot) jfreechart.getPlot();
    plot.setNoDataMessage(DEFAULT_MESSAGE_NODATA);
    plot.setInsets(RectangleInsets.ZERO_INSETS);
    plot.setDataset(dataset);//w w w . ja  va  2  s  .  com
    plot.setBackgroundAlpha(0.0f);
    plot.setCircular(true);
    plot.setLabelGenerator(null);
    plot.setIgnoreNullValues(true);
    plot.setIgnoreZeroValues(true);
    plot.setShadowPaint(null);
    plot.setLabelLinkMargin(0.0);
    plot.setInteriorGap(0.02);
    plot.setMaximumLabelWidth(0.10);
}

From source file:com.rapidminer.gui.plotter.charts.RingChartPlotter.java

@Override
public JFreeChart createChart(PieDataset pieDataSet, boolean createLegend) {
    JFreeChart chart = ChartFactory.createRingChart(null, pieDataSet, createLegend, // legend
            true, false);/*from   w  w w.  ja v  a 2  s  .c o  m*/

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setSectionOutlinesVisible(false);
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 11));
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);

    return chart;
}

From source file:com.tencent.wstt.apt.chart.PieChart.java

private JFreeChart createChart() {
    this.dataset = new DefaultPieDataset();
    final JFreeChart chart = ChartFactory.createPieChart("??", this.dataset, true, true, false);
    chart.getTitle().setFont(new Font("", Font.BOLD, 20));
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}:{1}"));
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);//  w w  w.  j  a  va  2s.  c  o m
    plot.setLabelGap(0.02);
    return chart;
}

From source file:it.marcoberri.mbmeteo.action.chart.GetLastUPie.java

/**
 * Processes requests for both HTTP/*from   w ww. j  av a2s  .  c  om*/
 * <code>GET</code> and
 * <code>POST</code> methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    log.debug("start : " + this.getClass().getName());

    final HashMap<String, String> params = getParams(request.getParameterMap());
    final Integer dimy = Default.toInteger(params.get("dimy"), 600);
    final Integer dimx = Default.toInteger(params.get("dimx"), 800);

    Meteolog meteolog = ds.find(Meteolog.class).order("-time").limit(1).get();

    final DefaultPieDataset dataset = new DefaultPieDataset();

    dataset.setValue(ChartEnumMinMaxHelper.outdoorHumidityMin.getUm(), meteolog.getOutdoorHumidity());
    dataset.setValue("", 100 - meteolog.getOutdoorHumidity());

    JFreeChart chart = ChartFactory.createPieChart("Humidity %", // chart title
            dataset, // data
            true, // include legend
            true, false);

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);

    final File f = File.createTempFile("mbmeteo", ".jpg");
    ChartUtilities.saveChartAsJPEG(f, chart, dimx, dimy);

    response.setContentType("image/jpeg");
    response.setHeader("Content-Length", "" + f.length());
    response.setHeader("Content-Disposition", "inline; filename=\"" + f.getName() + "\"");
    final OutputStream out = response.getOutputStream();
    final FileInputStream in = new FileInputStream(f.toString());
    final int size = in.available();
    final byte[] content = new byte[size];
    in.read(content);
    out.write(content);
    in.close();
    out.close();

}

From source file:com.himtech.googlechart.GglPieChart.java

private JFreeChart createChart(PieDataset pdSet, String title) {
    JFreeChart chart = ChartFactory.createPieChart3D(title, pdSet, true, true, false);

    /*PiePlot3D plot = (PiePlot3D)chart.getPlot();
    plot.setStartAngle(290);//from   ww  w .j  a v  a  2  s  .  c o  m
    plot.setDirection(Rotation.CLOCKWISE);
    //plot.setForegroundAlpha(0.5f);
    plot.setLabelGap(0.02);*/

    PiePlot plot = (PiePlot) chart.getPlot();
    //plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    return chart;

}

From source file:com.jtk.pengelolaanujian.view.dashboard.PiePanelUjian.java

private ChartPanel createChart(PieDataset data) {
    piechart = ChartFactory.createPieChart("Ujian Status", data, true, true, false);
    PiePlot plot = (PiePlot) piechart.getPlot();
    plot.setSectionPaint("Terlalui", new Color(60, 70, 5));
    plot.setSectionPaint("Belum", new Color(100, 20, 30));
    plot.setNoDataMessage("Data Tidak Ada");
    plot.setExplodePercent("data", 0.1D);
    plot.setLabelBackgroundPaint(new Color(255, 228, 225));
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})"));
    plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator());

    // Key = 0 ----> section as String (Windows, Linux, Lainnya)
    // Key = 1 ----> section as value (300,200,100)
    // KEy - 2 ----> section as percentage (50%,33%,17 %) Muncul jika aplikasi telah di running

    plot.setSimpleLabels(true);//w w  w .j a v  a 2s.c o m
    plot.setInteriorGap(0.0D);
    return new ChartPanel(piechart);
}

From source file:com.okmich.hackerday.client.tool.dashboard.ReportItemPanel.java

/**
 *
 * @return A panel./*from  w  ww .  j  a v a  2s .  c  om*/
 */
public JPanel createChartPanel() {
    JFreeChart chart = ChartFactory.createPieChart(title, // chart title
            getChartDataset(), // data
            true, // include legend
            true, false);

    TextTitle textTitle = new TextTitle(title, new Font("SansSerif", Font.BOLD, 16));
    chart.setTitle(textTitle);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);

    LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.BOTTOM);
    this.chartPanel = new ChartPanel(chart);
    this.chartPanel.addMouseListener(new MouseListenerImpl(this));

    return this.chartPanel;
}

From source file:com.thalesgroup.hudson.plugins.klocwork.graph.KloPieChart.java

protected JFreeChart createGraph() {

    JFreeChart chart = ChartFactory.createPieChart(null, dataset, true, true, false);
    chart.setBackgroundPaint(Color.white);

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setDataset(dataset);/*from w  w  w .jav  a  2s .c o m*/
    plot.setOutlinePaint(null);
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No Klocwork data found.");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{1}"));

    // Set colours
    //plot.setOutlinePaint("New", new Color(200, 0, 0));
    int i = 0;
    if (kloConfig.getBuildGraph().isNeww() && kloReport.getNeww() > 0) {
        plot.setSectionPaint(plot.getDataset().getKey(i), new Color(200, 0, 0));
        i++;
    }
    if (kloConfig.getBuildGraph().isExisting() && kloReport.getExisting() > 0) {
        plot.setSectionPaint(plot.getDataset().getKey(i), new Color(0, 0, 200));
        i++;
    }
    if (kloConfig.getBuildGraph().isFixed() && kloReport.getFixed() > 0) {
        plot.setSectionPaint(plot.getDataset().getKey(i), new Color(0, 200, 0));
    }

    //plot.setOutlinePaint("Existing", new Color(0, 0, 200));
    //plot.setOutlinePaint("Fixed", new Color(0, 200, 0));

    return chart;

}