Example usage for org.jfree.data.category DefaultCategoryDataset addValue

List of usage examples for org.jfree.data.category DefaultCategoryDataset addValue

Introduction

In this page you can find the example usage for org.jfree.data.category DefaultCategoryDataset addValue.

Prototype

public void addValue(double value, Comparable rowKey, Comparable columnKey) 

Source Link

Document

Adds a value to the table.

Usage

From source file:edu.ku.brc.specify.plugins.ipadexporter.ChartHelper.java

/**
 * @param list/*from w w  w  . java 2s  .  c om*/
 * @return
 */
private DefaultCategoryDataset createDataSet(final List<Object> list) {
    String cat = ""; //$NON-NLS-1$
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    for (int i = 0; i < list.size(); i++) {
        Object descObj = list.get(i++);
        Object valObj = list.get(i);
        dataset.addValue(getInt(valObj), getString(descObj), cat);
    }
    return dataset;
}

From source file:org.bench4Q.console.ui.section.S_SPSSection.java

private JPanel printWIPSPic() throws IOException {
    double[][] value = sessionSmooth();
    for (int i = 0; i < value[0].length; ++i) {
        value[0][i] = i;/*from   www  .  ja va2s. c  o  m*/
        // value[1][i] = webInteractionThroughput[i];.
    }

    DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset();
    String series1 = "Basic";
    String series2 = "real";

    for (int i = 0; i < value[0].length; ++i) {
        defaultcategorydataset.addValue(value[1][i], series1, new Integer((int) value[0][i]));
        defaultcategorydataset.addValue(session[1][i], series2, new Integer((int) value[0][i]));
    }

    JFreeChart chart = ChartFactory.createLineChart("SPS = " + SPS, "time", "SPS", defaultcategorydataset,
            PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
    categoryplot.setBackgroundPaint(Color.WHITE);
    categoryplot.setRangeGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setAutoRangeIncludesZero(true);
    LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer();
    lineandshaperenderer.setShapesVisible(false);
    lineandshaperenderer.setSeriesStroke(0, new BasicStroke(2.0F, 1, 1, 1.0F, new float[] { 1F, 1F }, 0.0F));
    lineandshaperenderer.setSeriesStroke(1,
            new BasicStroke(2.0F, 1, 0, 2.0F, new float[] { 1F, 10000F }, 0.0F));
    return new ChartPanel(chart);
}

From source file:pe.egcc.eureka.app.view.RepoResumen.java

private Object crearImagen(List<Map<String, ?>> lista) {

    //datos del grfico
    String moneda = null;/*from www .j  a va 2  s. c o m*/
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (Map<String, ?> map : lista) {
        double importe = Double.parseDouble(map.get("IMPORTE").toString());
        moneda = map.get("MONENOMBRE").toString();
        String accion = map.get("ACCION").toString();
        dataset.addValue(importe, moneda, accion);
    }

    JFreeChart graficoBarras = ChartFactory.createBarChart("RESUMEN DE MOVIMIENTOS", //Ttulo de la grfica
            "TIPOS DE MOVIMIENTOS", //leyenda Eje horizontal
            "MILES DE " + moneda, //leyenda Eje vertical
            dataset, //datos
            PlotOrientation.VERTICAL, //orientacin
            true, //incluir leyendas
            true, //mostrar tooltips
            true);

    graficoBarras.setBackgroundPaint(Color.LIGHT_GRAY);

    CategoryPlot plot = (CategoryPlot) graficoBarras.getPlot();
    plot.setBackgroundPaint(Color.CYAN); //fondo del grafico
    plot.setDomainGridlinesVisible(true);//lineas de rangos, visibles
    plot.setRangeGridlinePaint(Color.BLACK);//color de las lineas de rangos

    // Crear imagen
    BufferedImage imagen = graficoBarras.createBufferedImage(500, 300);
    return imagen;
}

From source file:se.backede.jeconomix.forms.report.SingleTransactionReport.java

private DefaultCategoryDataset createDataset(TransactionReportDto reports) {

    String lineTitle = "Kronor";

    Map<Month, BigDecimal> sums = new HashMap<>();

    List<Month> monthList = new LinkedList<>(Arrays.asList(Month.values()));

    monthList.forEach((month) -> {//from  w ww.  j  av a  2 s . co  m
        sums.put(month, BigDecimal.valueOf(0));
    });

    reports.getTransctions().forEach((TransactionDto transaction) -> {
        monthList.stream().filter((month) -> (transaction.getBudgetMonth().equals(month)))
                .forEachOrdered((month) -> {
                    BigDecimal currentSum = sums.get(month);
                    if (transaction.getSum() != null) {
                        double abs = Math.abs(transaction.getSum().doubleValue());
                        BigDecimal newSum = currentSum.add(BigDecimal.valueOf(abs));
                        sums.put(month, newSum);
                    }
                });
    });

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.addValue(sums.get(Month.JANUARY), lineTitle, "Jan");
    dataset.addValue(sums.get(Month.FEBRUARY), lineTitle, "Feb");
    dataset.addValue(sums.get(Month.MARCH), lineTitle, "Mar");
    dataset.addValue(sums.get(Month.APRIL), lineTitle, "Apr");
    dataset.addValue(sums.get(Month.MAY), lineTitle, "May");
    dataset.addValue(sums.get(Month.JUNE), lineTitle, "Jun");
    dataset.addValue(sums.get(Month.JULY), lineTitle, "Jul");
    dataset.addValue(sums.get(Month.AUGUST), lineTitle, "Aug");
    dataset.addValue(sums.get(Month.SEPTEMBER), lineTitle, "Sep");
    dataset.addValue(sums.get(Month.OCTOBER), lineTitle, "Oct");
    dataset.addValue(sums.get(Month.NOVEMBER), lineTitle, "Nov");
    dataset.addValue(sums.get(Month.DECEMBER), lineTitle, "Dec");
    return dataset;
}

From source file:sernet.gs.ui.rcp.main.bsi.views.chart.ISRSpiderChart.java

protected Object createSpiderDataset() throws CommandException {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    MassnahmenSummaryHome dao = new MassnahmenSummaryHome();

    Map<String, Double> items2 = dao.getControlMaxGroupsISR(elmt);
    Set<Entry<String, Double>> entrySet2 = items2.entrySet();
    for (Entry<String, Double> entry : sort(entrySet2)) {
        dataset.addValue(entry.getValue(), Messages.ISRSpiderChart_1, entry.getKey());
    }/*from   w  w w.  j ava2  s . c om*/

    Map<String, Double> items4 = dao.getControlGoal2Groups(elmt);
    Set<Entry<String, Double>> entrySet4 = items4.entrySet();
    for (Entry<String, Double> entry : sort(entrySet4)) {
        dataset.addValue(entry.getValue(), Messages.ISRSpiderChart_2, entry.getKey());
    }

    Map<String, Double> items3 = dao.getControlGoal1Groups(elmt);
    Set<Entry<String, Double>> entrySet3 = items3.entrySet();
    for (Entry<String, Double> entry : sort(entrySet3)) {
        dataset.addValue(entry.getValue(), Messages.ISRSpiderChart_3, entry.getKey());
    }

    Map<String, Double> items1 = dao.getControlGroupsISR(elmt);
    Set<Entry<String, Double>> entrySet = items1.entrySet();

    for (Entry<String, Double> entry : sort(entrySet)) {
        dataset.addValue(entry.getValue(), Messages.ISRSpiderChart_4, entry.getKey());
    }

    return dataset;
}

From source file:UserInterface.WaterSupplyAdmin.UsagePatternJPanel.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    int selectedRow = customerTable.getSelectedRow();
    if (selectedRow < 0) {
        JOptionPane.showMessageDialog(null, "Select a customer first");
        return;/*ww w .  j  a va2  s. c  om*/
    }

    Customer customer = (Customer) customerTable.getValueAt(selectedRow, 1);
    if (customer.getSourceSensor() == null) {
        JOptionPane.showMessageDialog(null, "Water Supply not available yet for this customer");
        return;
    }
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (SensorValue sensorValue : customer.getTargetSensor().getSensorValueList()) {
        dataset.addValue(sensorValue.getFlowrate(), "Date", sensorValue.getDate());
    }
    if (customer.getTargetSensor().getSensorValueList().size() == 1) {
        JFreeChart chart = ChartFactory.createBarChart(
                "Customer's water flowrate variation over a period of time", "Time of Usage",
                "FlowRate(gallons/sec)", dataset, PlotOrientation.VERTICAL, true, true, true);
        CategoryPlot p = chart.getCategoryPlot();
        p.setRangeGridlinePaint(Color.cyan);
        ChartFrame frame = new ChartFrame("Bar Char for Weight", chart);

        frame.setVisible(true);
        frame.setSize(450, 350);
    } else {
        JFreeChart chart = ChartFactory.createLineChart(
                "Customer's water flowrate variation over a period of time", "Time of Usage",
                "FlowRate(gallons/sec)", dataset, PlotOrientation.VERTICAL, true, true, true);
        CategoryPlot p = chart.getCategoryPlot();
        p.setRangeGridlinePaint(Color.cyan);
        ChartFrame frame = new ChartFrame("Bar Char for Weight", chart);
        RefineryUtilities.centerFrameOnScreen(frame);

        frame.setVisible(true);
        frame.setSize(450, 350);
    }

}

From source file:com.polivoto.vistas.acciones.Datos.java

private CategoryDataset crearDatasetBar() {
    DefaultCategoryDataset datos = new DefaultCategoryDataset();
    try {/*from ww w . j a v a2  s .c  om*/
        String sector = ac.getPreguntas().getJSONObject(pox).getString("pregunta");

        if (ac.getConteoOpcionesPregunta().getJSONObject(pox).getInt("participantes") == 0) {
            datos.addValue(0, sector, "No hay ningn voto");
        } else {
            for (int i = 0; i < ac.getConteoOpcionesPregunta().getJSONObject(pox).getJSONArray("conteo")
                    .length(); i++) {
                int p = ac.getConteoOpcionesPregunta().getJSONObject(pox).getJSONArray("conteo")
                        .getJSONObject(i).getInt("cantidad");
                if (ac.getConteoOpcionesPregunta().getJSONObject(pox).getJSONArray("conteo").getJSONObject(i)
                        .getString("reactivo").equals("Anular mi voto")) {
                    datos.addValue(p, sector, "Nulo");
                } else {
                    datos.addValue(p, sector, ac.getConteoOpcionesPregunta().getJSONObject(pox)
                            .getJSONArray("conteo").getJSONObject(i).getString("reactivo"));
                }
            }
        }
    } catch (JSONException ex) {
        ex.printStackTrace();
    }
    return datos;
}

From source file:az.kanan.batterystat.frame.MainFrame.java

private DefaultCategoryDataset createDataset() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    List<Battery> baterryTrackList = queriesImpl.getTrackedInfo(jDateChooser1.getDate(),
            jDateChooser2.getDate());/*from w  ww.j av a 2s  .c o  m*/

    baterryTrackList.forEach((baterry) -> {
        dataset.addValue(baterry.getBatteryLife(), "percent", baterry.getDate());
    });
    return dataset;
}

From source file:com.devoteam.srit.xmlloader.core.report.derived.DerivedCounter.java

public JFreeChart getHistogramChart() {

    double[] hits = this.counter.histogramDataset.getHistogramArray();
    double[] intervals = this.counter.histogramDataset.histogramParameters.histogramIntervals;
    double hitsCount = this.counter.histogramDataset.hits;
    DefaultCategoryDataset datasetNormal = new DefaultCategoryDataset();

    datasetNormal.addValue(0, "a", "          -INF");
    datasetNormal.addValue(0, "b", "          -INF");

    double cumul = 0;
    for (int i = 0; i < intervals.length - 1; i++) {
        String intervalName;//from w  w  w .  j av  a  2s .c  om

        if (i == intervals.length - 2) {
            intervalName = "          +INF";
        } else {
            intervalName = "          " + Double.toString(intervals[i + 1]);
        }

        cumul += hits[i];
        datasetNormal.addValue((100 * hits[i]) / hitsCount, "a", intervalName);
        datasetNormal.addValue((100 * cumul) / hitsCount, "b", intervalName);
    }

    JFreeChart jFreeChart = ChartFactory.createBarChart("", "", "%", datasetNormal, PlotOrientation.VERTICAL,
            false, false, false);

    CategoryPlot plot = jFreeChart.getCategoryPlot();
    CategoryAxis axis = plot.getDomainAxis();
    LayeredBarRenderer layeredBarRenderer = new LayeredBarRenderer();
    layeredBarRenderer.setSeriesPaint(0, new Color(0, 0, 255, 85));
    layeredBarRenderer.setSeriesPaint(1, new Color(255, 0, 0, 85));
    plot.setRenderer(layeredBarRenderer);

    plot.setRowRenderingOrder(SortOrder.DESCENDING);
    axis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
    axis.setMaximumCategoryLabelWidthRatio(1);

    jFreeChart.setBackgroundPaint(Color.WHITE);
    return jFreeChart;

}

From source file:org.mili.jmibs.jfree.JFreeChartBarIterationObjectLoadBenchmarkSuiteResultRenderer.java

private CategoryDataset createDataset(List<BenchmarkResult> lbr) {
    DefaultCategoryDataset ds = new DefaultCategoryDataset();
    for (int i = 0, n = lbr.size(); i < n; i++) {
        BenchmarkResult br = lbr.get(i);
        IterationObjectLoadBenchmarkContext iolbc = (IterationObjectLoadBenchmarkContext) br
                .getBenchmarkContext();/*from  ww  w.java  2s. c o m*/
        Benchmark b = iolbc.getBenchmark();
        int ic = iolbc.getIteration();
        int oc = iolbc.getObjectLoad();
        ds.addValue(br.getTotalTimeNanos(), String.valueOf(ic) + "/" + String.valueOf(oc), b.getName());
    }
    return ds;
}