Example usage for org.jfree.data.general DefaultPieDataset setValue

List of usage examples for org.jfree.data.general DefaultPieDataset setValue

Introduction

In this page you can find the example usage for org.jfree.data.general DefaultPieDataset setValue.

Prototype

public void setValue(Comparable key, double value) 

Source Link

Document

Sets the data value for a key and sends a DatasetChangeEvent to all registered listeners.

Usage

From source file:org.openmrs.module.usagestatistics668.web.view.chart.AccessEncounterPieChartView.java

/**
 * create pie chart for encounter data// w w w  .j a  va2 s  .co m
 * @param model model built for view
 * @param request
 * @return JFREEChar pie chart
 */
@Override
protected JFreeChart createChart(Map<String, Object> model, HttpServletRequest request) {

    AccessEncounterService svc = Context.getService(AccessEncounterService.class);
    List<Object[]> data = svc.getMostViewedEncounter(getFromDate(), getUntilDate(), getUsageFilter(),
            getMaxResults());
    String[] categories = new String[data.size()];
    int[] count = new int[data.size()];
    for (int i = 0; i < categories.length; i++) {
        categories[i] = String.valueOf(data.get(i)[0]);
        count[i] = ((BigInteger) data.get(i)[1]).intValue();
    }

    String seriesView = ContextProvider.getMessage("usagestatistics668.summary.any");
    String title = "Most Accessed Encounter Data";

    if (getUsageFilter() == ActionCriteria.CREATED) {
        seriesView = ContextProvider.getMessage("usagestatistics668.summary.created");
        title = "Most Created Encounter Data";
    } else if (getUsageFilter() == ActionCriteria.UPDATED) {
        seriesView = ContextProvider.getMessage("usagestatistics668.summary.updated");
        title = "Most Updated Encounter Data";
    } else if (getUsageFilter() == ActionCriteria.VIEWED) {
        seriesView = ContextProvider.getMessage("usagestatistics668.summary.viewed");
        title = "Most Vieweded Encounter Data";
    } else if (getUsageFilter() == ActionCriteria.VOIDED) {
        seriesView = ContextProvider.getMessage("usagestatistics668.summary.voided");
        title = "Most Voided Encounter Data";
    } else if (getUsageFilter() == ActionCriteria.UNVOIDED) {
        seriesView = ContextProvider.getMessage("usagestatistics668.summary.unvoided");
        title = "Most Unvoided Encounter Data";
    }

    DefaultPieDataset dataset = new DefaultPieDataset();
    for (int c = 0; c < data.size(); c++) {
        dataset.setValue(String.valueOf(data.get(c)[0]), ((BigInteger) data.get(c)[1]).intValue());
    }

    JFreeChart chart = ChartFactory.createPieChart(title, // chart title
            dataset, // data
            false, // no legend
            true, // tooltips
            false // no URL generation
    );

    return chart;
}

From source file:org.openmrs.module.usagestatistics668.web.view.chart.AccessVisitPieChartView.java

/**
 * create pie chart for visit data// w w  w  .  j a v  a 2 s . c  om
 * @param model model built for view
 * @param request
 * @return JFREEChar pie chart
 */
@Override
protected JFreeChart createChart(Map<String, Object> model, HttpServletRequest request) {
    AccessVisitService svc = Context.getService(AccessVisitService.class);

    List<Object[]> data = svc.getMostViewedVisit(getFromDate(), getUntilDate(), getUsageFilter(),
            getMaxResults());
    String[] categories = new String[data.size()];
    int[] count = new int[data.size()];
    for (int i = 0; i < categories.length; i++) {
        categories[i] = String.valueOf(data.get(i)[0]);
        count[i] = ((BigInteger) data.get(i)[1]).intValue();
    }

    String seriesView = ContextProvider.getMessage("usagestatistics668.summary.any");
    String title = "Most Accessed Visit Data";

    if (getUsageFilter() == ActionCriteria.CREATED) {
        seriesView = ContextProvider.getMessage("usagestatistics668.summary.created");
        title = "Most Created Visit Data";
    } else if (getUsageFilter() == ActionCriteria.UPDATED) {
        seriesView = ContextProvider.getMessage("usagestatistics668.summary.updated");
        title = "Most Updated Visit Data";
    } else if (getUsageFilter() == ActionCriteria.VIEWED) {
        seriesView = ContextProvider.getMessage("usagestatistics668.summary.viewed");
        title = "Most Vieweded Visit Data";
    } else if (getUsageFilter() == ActionCriteria.VOIDED) {
        seriesView = ContextProvider.getMessage("usagestatistics668.summary.voided");
        title = "Most Voided Visit Data";
    } else if (getUsageFilter() == ActionCriteria.UNVOIDED) {
        seriesView = ContextProvider.getMessage("usagestatistics668.summary.unvoided");
        title = "Most Unvoided Visit Data";
    }

    DefaultPieDataset dataset = new DefaultPieDataset();
    for (int c = 0; c < data.size(); c++) {
        dataset.setValue(String.valueOf(data.get(c)[0]), ((BigInteger) data.get(c)[1]).intValue());
    }

    JFreeChart chart = ChartFactory.createPieChart(title, // chart title
            dataset, // data
            false, // no legend
            true, // tooltips
            false // no URL generation
    );

    return chart;
}

From source file:net.sf.jdmf.visualization.clustering.ChartGenerator.java

/**
 * Generates a pie chart showing the percentage of points falling into each
 * cluster./*from   www .j a  v a 2s  .c  om*/
 * 
 * @param clusters clusters found by a clustering algorithm
 * @return a pie chart showing the distribution of points into clusters
 */
public JFreeChart generatePieChart(List<Cluster> clusters) {
    DefaultPieDataset dataset = new DefaultPieDataset();

    for (Cluster cluster : clusters) {
        dataset.setValue(cluster.getName(), cluster.getPointPercentage());
    }

    return ChartFactory.createPieChart3D("Cluster Analysis", dataset, true, true, false);
}

From source file:org.openmrs.module.usagestatistics668.web.view.chart.AccessPatientPieChartView.java

/**
 * create pie chart for patient data/*  ww  w  . j  a  va2 s .  c om*/
 * @param model model built for view
 * @param request
 * @return JFREEChar pie chart
 */
@Override
protected JFreeChart createChart(Map<String, Object> model, HttpServletRequest request) {
    AccessPatientService svc = Context.getService(AccessPatientService.class);

    List<Object[]> data = svc.getMostViewedPatient(getFromDate(), getUntilDate(), getUsageFilter(),
            getMaxResults());

    String[] categories = new String[data.size()];
    int[] count = new int[data.size()];
    for (int i = 0; i < categories.length; i++) {
        categories[i] = String.valueOf(data.get(i)[0]);
        count[i] = ((BigInteger) data.get(i)[1]).intValue();
    }

    String seriesView = ContextProvider.getMessage("usagestatistics668.summary.any");
    String title = "Most Accessed Patient Data";

    if (getUsageFilter() == ActionCriteria.CREATED) {
        seriesView = ContextProvider.getMessage("usagestatistics668.summary.created");
        title = "Most Created Patient Data";
    } else if (getUsageFilter() == ActionCriteria.UPDATED) {
        seriesView = ContextProvider.getMessage("usagestatistics668.summary.updated");
        title = "Most Updated Patient Data";
    } else if (getUsageFilter() == ActionCriteria.VIEWED) {
        seriesView = ContextProvider.getMessage("usagestatistics668.summary.viewed");
        title = "Most Vieweded Patient Data";
    } else if (getUsageFilter() == ActionCriteria.VOIDED) {
        seriesView = ContextProvider.getMessage("usagestatistics668.summary.voided");
        title = "Most Voided Patient Data";
    } else if (getUsageFilter() == ActionCriteria.UNVOIDED) {
        seriesView = ContextProvider.getMessage("usagestatistics668.summary.unvoided");
        title = "Most Unvoided Patient Data";
    }

    DefaultPieDataset dataset = new DefaultPieDataset();
    for (int c = 0; c < data.size(); c++) {
        dataset.setValue(String.valueOf(data.get(c)[0]), ((BigInteger) data.get(c)[1]).intValue());
    }

    JFreeChart chart = ChartFactory.createPieChart(title, // chart title
            dataset, // data
            false, // no legend
            true, // tooltips
            false // no URL generation
    );

    return chart;
}

From source file:application.logik.Logik.java

public void stats() {
    //http://www.math.hu-berlin.de/~ccafm/lehre_BZQ_Numerik/allg/JAVA_Pakete/JFreeChart/Codes/PieChart_code.html
    //JFreeChart Library (GNU License deshalb benutzen wir die MIT-Lizenz)
    long[] arr = new long[3];
    arr[0] = trT;/*from   w  w  w.  j  a va 2s  .c o  m*/
    arr[2] = trR;
    arr[1] = trC;
    arr[step] += trackStop();
    String[] timeText = new String[3];
    for (int i = 0; i < timeText.length; i++) {
        arr[i] = arr[i] / 1000;
        long sek = arr[i] % 60;
        long min = arr[i] / 60;
        if (sek < 10) {
            timeText[i] = min + " : 0" + sek;
        } else {
            timeText[i] = min + " : " + sek;
        }
    }
    long ges = (trT + trR + trC) / 100;
    DefaultPieDataset pieDataset = new DefaultPieDataset();
    pieDataset.setValue("Red: " + timeText[0] + "min", ges * arr[0]);
    pieDataset.setValue("Refactor: " + timeText[2] + "min", ges * arr[2]);
    pieDataset.setValue("Green: " + timeText[1] + "min", ges * arr[1]);

    JFreeChart chart = ChartFactory.createPieChart("Time", pieDataset, true, false, false);
    ChartFrame frame = new ChartFrame("Chart", chart);
    frame.pack();
    RefineryUtilities.centerFrameOnScreen(frame);
    frame.setVisible(true);
}

From source file:com.kodemore.freechart.KmSimplePieChart.java

@Override
protected JFreeChart createAbstractChart() {
    DefaultPieDataset ds = new DefaultPieDataset();

    int n = _names.size();
    for (int i = 0; i < n; i++)
        ds.setValue(_names.get(i), _values.get(i));

    boolean tooltips = false;
    boolean urls = false;

    return ChartFactory.createPieChart3D("", ds, getLegend(), tooltips, urls);
}

From source file:gui.images.ClassifierResultPanel.java

/**
 * Sets the new results for display./*from   w w  w .j  a v  a2s .  co m*/
 *
 * @param prediction Float array corresponding to the classifier prediction.
 * @param classifierName String that is the classifier name.
 * @param classColors Color array representing the class color.
 * @param classNames String array representing the class names.
 */
public void setResults(float[] prediction, String classifierName, Color[] classColors, String[] classNames) {
    int numClasses = classNames.length;
    DefaultPieDataset pieData = new DefaultPieDataset();
    for (int cIndex = 0; cIndex < numClasses; cIndex++) {
        pieData.setValue(classNames[cIndex], prediction[cIndex]);
    }
    JFreeChart chart = ChartFactory.createPieChart3D(classifierName + " prediction", pieData, true, true,
            false);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setDirection(Rotation.CLOCKWISE);
    plot.setForegroundAlpha(0.5f);
    PieRenderer prend = new PieRenderer(classColors);
    prend.setColor(plot, pieData);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(140, 140));
    resultChartPanel.removeAll();
    resultChartPanel.add(chartPanel);
    resultChartPanel.revalidate();
    resultChartPanel.repaint();
}

From source file:Graphics.Piechart.java

private PieDataset createDataset() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    Collections.sort(valores);/* w  w w.ja  v  a  2s . co  m*/
    for (int h = 0; h < valores.size(); h++) {
        dataset.setValue(
                lingua.translate(valores.get(h).getTipo().getTypeOfMaterialName()) + " "
                        + lingua.translate(valores.get(h).getTipo().getDescription()),
                valores.get(h).getNumber());
        if (h == quantidade - 1) {
            break;
        }
    }
    return dataset;
}

From source file:userInterface.MonitoringTeamRole.AnalysisJPanel.java

private PieDataset createDataset() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("User Profiling Suspicious events", system.numberofsuspiciousevents);
    dataset.setValue("Network based suspicious events", system.networksuspiciousevents);
    return dataset;

}

From source file:edu.monash.merc.struts2.action.TLSumChartAction.java

@SuppressWarnings("unchecked")
public String piechart() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("Green", l4);
    dataset.setValue("Yellow", l3);
    dataset.setValue("Red", l2);
    dataset.setValue("Black", l1);

    chart = ChartFactory.createPieChart(dt, dataset, true, true, false);
    PiePlot plot = (PiePlot) chart.getPlot();

    plot.setBackgroundPaint(Color.WHITE);
    //no border/*from w w  w . j  a  v a2s .c o m*/
    plot.setOutlineStroke(null);
    //no label
    plot.setLabelGenerator(null);

    NumberFormat percentFormat = NumberFormat.getPercentInstance();
    percentFormat.setMaximumFractionDigits(2);
    plot.setLegendLabelGenerator(
            new StandardPieSectionLabelGenerator("{0}={2}", NumberFormat.getNumberInstance(), percentFormat));
    //set specific colors  green, yellow, red and black
    Color[] colors = { new Color(0, 140, 0), new Color(254, 172, 0), new Color(226, 0, 40),
            new Color(0, 0, 0) };
    setColor(plot, dataset, colors);

    chart.setBackgroundPaint(Color.WHITE);
    chart.getTitle().setFont(chart.getTitle().getFont().deriveFont(11.0f));
    return SUCCESS;
}