Example usage for org.jfree.chart JFreeChart getCategoryPlot

List of usage examples for org.jfree.chart JFreeChart getCategoryPlot

Introduction

In this page you can find the example usage for org.jfree.chart JFreeChart getCategoryPlot.

Prototype

public CategoryPlot getCategoryPlot() 

Source Link

Document

Returns the plot cast as a CategoryPlot .

Usage

From source file:flight_ranker.my_Jframe.java

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(85, "Marks", "Science");
    dataset.setValue(91, "Marks", "Maths");
    dataset.setValue(97, "Marks", "Computer");
    dataset.setValue(95, "Marks", "English");

    JFreeChart chart = ChartFactory.createBarChart("Bar Chart", "Subject", "Marks", dataset,
            PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot P = chart.getCategoryPlot();
    P.setRangeGridlinePaint(Color.black);
    ChartFrame frame = new ChartFrame("Bar chart", chart);
    frame.setVisible(true);// ww  w.j  a v a2  s  . co m
    frame.setSize(450, 351);

}

From source file:br.unicamp.cst.motivational.MotivationalMonitor.java

@Override
public synchronized void run() {

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    final JFreeChart chart = ChartFactory.createBarChart(getTitle(), getEntity(), "Value", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    chart.setBackgroundPaint(Color.lightGray);

    ChartFrame frame = new ChartFrame(getTitle(), chart);
    frame.pack();/* ww w.j a  v a 2  s  .c  om*/
    frame.setVisible(true);

    while (true) {
        ArrayList<Codelet> tempCodeletsList = new ArrayList<Codelet>();
        tempCodeletsList.addAll(this.getListOfMotivationalEntities());

        synchronized (tempCodeletsList) {

            for (Codelet co : tempCodeletsList) {
                dataset.addValue(co.getActivation(), co.getName(), "activation");
            }
            try {
                Thread.currentThread().sleep(getRefreshPeriod());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
    }
}

From source file:net.sourceforge.subsonic.controller.UserChartController.java

private JFreeChart createChart(CategoryDataset dataset, HttpServletRequest request) {
    JFreeChart chart = ChartFactory.createBarChart(null, null, null, dataset, PlotOrientation.HORIZONTAL, false,
            false, false);/*from  www . j a  v a  2s .c om*/

    CategoryPlot plot = chart.getCategoryPlot();
    Paint background = new GradientPaint(0, 0, Color.lightGray, 0, IMAGE_MIN_HEIGHT, Color.white);
    plot.setBackgroundPaint(background);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    LogarithmicAxis rangeAxis = new LogarithmicAxis(null);
    rangeAxis.setStrictValuesFlag(false);
    rangeAxis.setAllowNegativesFlag(true);
    plot.setRangeAxis(rangeAxis);

    // Disable bar outlines.
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    // Set up gradient paint for series.
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    renderer.setSeriesPaint(0, gp0);

    // Rotate labels.
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

    // Set theme-specific colors.
    Color bgColor = getBackground(request);
    Color fgColor = getForeground(request);

    chart.setBackgroundPaint(bgColor);

    domainAxis.setTickLabelPaint(fgColor);
    domainAxis.setTickMarkPaint(fgColor);
    domainAxis.setAxisLinePaint(fgColor);

    rangeAxis.setTickLabelPaint(fgColor);
    rangeAxis.setTickMarkPaint(fgColor);
    rangeAxis.setAxisLinePaint(fgColor);

    return chart;
}

From source file:org.ow2.clif.jenkins.chart.QuantileDistributionChart.java

@Override
protected JFreeChart createChart() {
    JFreeChart chart = ChartFactory.createBarChart(getBasicTitle(),
            Messages.QuantileDistributionChart_PercentageOfRequests(),
            Messages.QuantileDistributionChart_ResponseTime(), data, PlotOrientation.VERTICAL, true, true,
            false);//from  ww w . j ava 2  s  .co  m
    chart.getCategoryPlot().setRangeGridlinesVisible(true);
    chart.getCategoryPlot().setDomainGridlinesVisible(true);
    return chart;
}

From source file:org.opennms.netmgt.charts.ChartUtils.java

/**
 * @param chartConfig/*  w ww.j av  a 2  s .c om*/
 * @param baseDataSet
 * @return
 */
private static JFreeChart createBarChart(BarChart chartConfig, DefaultCategoryDataset baseDataSet) {
    PlotOrientation po = (chartConfig.getPlotOrientation() == "horizontal" ? PlotOrientation.HORIZONTAL
            : PlotOrientation.VERTICAL);
    JFreeChart barChart = null;
    if ("3d".equalsIgnoreCase(chartConfig.getVariation())) {
        barChart = ChartFactory.createBarChart3D(chartConfig.getTitle().getValue(),
                chartConfig.getDomainAxisLabel(), chartConfig.getRangeAxisLabel(), baseDataSet, po,
                chartConfig.getShowLegend(), chartConfig.getShowToolTips(), chartConfig.getShowUrls());
    } else {
        barChart = ChartFactory.createBarChart(chartConfig.getTitle().getValue(),
                chartConfig.getDomainAxisLabel(), chartConfig.getRangeAxisLabel(), baseDataSet, po,
                chartConfig.getShowLegend(), chartConfig.getShowToolTips(), chartConfig.getShowUrls());
    }

    // Create a bit more headroom for value labels than is allowed for by the default 0.05 upper margin
    ValueAxis rangeAxis = barChart.getCategoryPlot().getRangeAxis();
    if (rangeAxis.getUpperMargin() < 0.1) {
        rangeAxis.setUpperMargin(0.1);
    }

    return barChart;
}

From source file:ws.moor.bt.gui.charts.DownloadRatePerPeer.java

private JFreeChart createChart() {

    JFreeChart chart = ChartFactory.createBarChart("Top 20 Download Rates", "Remote IP", "KB/s",
            createDataset(), PlotOrientation.VERTICAL, false, false, false);
    chart.setBackgroundPaint(Color.white);

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0));

    return chart;
}

From source file:br.com.OCTur.view.GraficoController.java

private void produtosMaisAntigos() {

    DefaultCategoryDataset dcdDados = new DefaultCategoryDataset();
    for (EntidadeGrafico<Produto> entidadeGrafico : produto) {
        if (entidadeGrafico.getValue() >= slMeta.getValue()) {
            dcdDados.addValue(entidadeGrafico.getValue(), "Dias/Acima do esperado", entidadeGrafico.toString());
        } else {/*  ww w.ja va2s.  co  m*/
            dcdDados.addValue(entidadeGrafico.getValue(), "Dias", entidadeGrafico.toString());
        }
    }
    JFreeChart jFreeChart = ChartFactory.createBarChart(ControlTranducao.traduzirPalavra("PRODUTOSMAISANTIGOS"),
            "", "", dcdDados, PlotOrientation.VERTICAL, false, false, false);
    jFreeChart.getCategoryPlot().getRenderer().setBaseItemLabelGenerator(
            new StandardCategoryItemLabelGenerator("{0}", NumberFormat.getCurrencyInstance()));
    jFreeChart.getCategoryPlot()
            .addRangeMarker(new ValueMarker(slMeta.getValue(), Color.CYAN, new BasicStroke(1.0f)));
    ChartPanel chartPanel = new ChartPanel(jFreeChart);
    snProdutosMaisAntigos.setContent(chartPanel);
}

From source file:net.neurowork.cenatic.centraldir.model.graphs.BarchartGraphCreator.java

@Override
public JFreeChart createGraphChart(String title, String yAxis, Dataset data) {
    PlotOrientation orientation = PlotOrientation.VERTICAL;

    JFreeChart chart = ChartFactory.createBarChart(title, "", // x-axis label
            yAxis, // y-axis label
            (CategoryDataset) data, orientation, false, // legend displayed
            true, // tooltips displayed
            false); // no URLs*/

    CategoryPlot categoryPlot = chart.getCategoryPlot();
    CategoryAxis domainAxis = categoryPlot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    return chart;
}

From source file:UserInterface.AppUsersProfile.DetailAnalysis.DetailAnalysisJPanel.java

public ChartPanel getChartPanel(String vitalSignType) {

    int count = 1;
    DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
    for (VitalSign vitalSign : userAccount.getPatient().getVitalSignHistory().getVitalSignList()) {
        String str = String.valueOf(count);
        if (vitalSignType.equalsIgnoreCase("Blood Pressure")) {
            vitalSignType = "Blood Pressure";
            dataSet.addValue(vitalSign.getBloodPressure(), "Blood Pressure", str);
        } else if (vitalSignType.equalsIgnoreCase("Pulse Rate")) {
            vitalSignType = "Pulse Rate";
            dataSet.addValue(vitalSign.getHeartRate(), "Pulse Rate", str);
        } else if (vitalSignType.equalsIgnoreCase("Respiratory Rate")) {
            vitalSignType = "Respiratory Rate";
            dataSet.addValue(vitalSign.getRespiratoryRate(), "Respiratory Rate", str);
        } else if (vitalSignType.equalsIgnoreCase("Temperature")) {
            vitalSignType = "Temperature";
            dataSet.addValue(vitalSign.getTemperature(), "Temperature", str);
        }/* w w  w .  j a v  a  2 s.c om*/
        count++;
    }
    JFreeChart chartFactory = ChartFactory.createLineChart(vitalSignType + " Chart", "Timestamp", vitalSignType,
            dataSet);
    CategoryPlot plot = chartFactory.getCategoryPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.blue);
    ChartPanel chartPanel = new ChartPanel(chartFactory);
    return chartPanel;
}

From source file:ws.moor.bt.gui.charts.TotalBlocksPerPeer.java

private JFreeChart createChart() {

    JFreeChart chart = ChartFactory.createStackedBarChart("Top 20 Block Peers", "Remote IP", "Blocks",
            createDataset(), PlotOrientation.VERTICAL, true, false, false);
    chart.setBackgroundPaint(Color.white);

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0));

    return chart;
}