Example usage for org.jfree.chart.axis NumberAxis createIntegerTickUnits

List of usage examples for org.jfree.chart.axis NumberAxis createIntegerTickUnits

Introduction

In this page you can find the example usage for org.jfree.chart.axis NumberAxis createIntegerTickUnits.

Prototype

public static TickUnitSource createIntegerTickUnits() 

Source Link

Document

Returns a collection of tick units for integer values.

Usage

From source file:sentimentanalyzer.ChartController.java

public void updateTheIntervalString_counts() {
    NumberAxis domainAxis = (NumberAxis) this.plot_counter.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    domainAxis.setAttributedLabel("Intervals of: " + this.interval + " hours");
}

From source file:vista.DestinosMasConsultados.java

public void iniciarGraficos(CategoryDataset dataset) {
    // create the chart...
    final JFreeChart chart = ChartFactory.createBarChart("Paises mas consultados", // chart title
            "Paises", // domain axis label
            "Cantidad de consultas", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );/*  www . j a va2  s. c om*/

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

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

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

    // set up gradient paints for series...
    final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray);
    final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray);
    final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray);
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

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

    ChartPanel chartFinal = new ChartPanel(chart);
    chartFinal.setSize(new Dimension(600, 400));

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(panelDestinosMasConsultados);
    panelDestinosMasConsultados.setLayout(jPanel1Layout);
    jPanel1Layout
            .setHorizontalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup().addGap(0, 0, 0).addComponent(chartFinal)
                            .addContainerGap(0, Short.MAX_VALUE)));
    jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup().addGap(0, 0, 0).addComponent(chartFinal)
                    .addContainerGap(0, Short.MAX_VALUE)));

}

From source file:com.intel.stl.ui.performance.PerformanceChartsCreator.java

protected JFreeChart getBwHistogramChart(Dataset dataset) {
    JFreeChart chart = ComponentFactory.createXYBarChart(STLConstants.K0053_CAPABILITY.getValue(),
            STLConstants.K0044_NUM_PORTS.getValue(), (IntervalXYDataset) dataset, (XYItemLabelGenerator) null);
    NumberAxis axis = (NumberAxis) chart.getXYPlot().getDomainAxis();
    axis.setTickUnit(new NumberTickUnit(0.2, UIConstants.PERCENTAGE));

    axis = (NumberAxis) chart.getXYPlot().getRangeAxis();
    axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    return chart;
}

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

private static JFreeChart createChart3(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createStackedBarChart("Public Opinion : Torture of Prisoners",
            "Country", "%", categorydataset, PlotOrientation.HORIZONTAL, false, true, false);
    jfreechart.getTitle().setMargin(2D, 0.0D, 0.0D, 0.0D);
    TextTitle texttitle = new TextTitle("Source: http://news.bbc.co.uk/1/hi/world/6063386.stm",
            new Font("Dialog", 0, 11));
    texttitle.setPosition(RectangleEdge.BOTTOM);
    texttitle.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    texttitle.setMargin(0.0D, 0.0D, 4D, 4D);
    jfreechart.addSubtitle(texttitle);// ww w.ja  v  a  2  s .c  om
    TextTitle texttitle1 = new TextTitle("(*) Across 27,000 respondents in 25 countries",
            new Font("Dialog", 0, 11));
    texttitle1.setPosition(RectangleEdge.BOTTOM);
    texttitle1.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    texttitle1.setMargin(4D, 0.0D, 2D, 4D);
    jfreechart.addSubtitle(texttitle1);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    LegendItemCollection legenditemcollection = new LegendItemCollection();
    legenditemcollection.add(new LegendItem("Against all torture", null, null, null,
            new java.awt.geom.Rectangle2D.Double(-6D, -3D, 12D, 6D), Color.green));
    legenditemcollection.add(new LegendItem("Some degree permissible", null, null, null,
            new java.awt.geom.Rectangle2D.Double(-6D, -3D, 12D, 6D), Color.red));
    categoryplot.setFixedLegendItems(legenditemcollection);
    categoryplot.setInsets(new RectangleInsets(5D, 5D, 5D, 20D));
    LegendTitle legendtitle = new LegendTitle(categoryplot);
    legendtitle.setPosition(RectangleEdge.BOTTOM);
    jfreechart.addSubtitle(legendtitle);
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setDomainGridlinePaint(Color.white);
    categoryplot.setDomainGridlinesVisible(true);
    categoryplot.setRangeGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setUpperMargin(0.0D);
    BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setDrawBarOutline(false);
    GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0));
    Color color = new Color(0, 0, 0, 0);
    GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0));
    barrenderer.setSeriesPaint(0, gradientpaint);
    barrenderer.setSeriesPaint(1, color);
    barrenderer.setSeriesPaint(2, gradientpaint1);
    return jfreechart;
}

From source file:org.agmip.ui.afsirs.frames.GraphOutput.java

public void addWeather() {
    int nyr = utils.getNYR();
    XYSeries etSeries = new XYSeries("ET");
    double[][] ET = utils.getET();
    for (int i = 0; i < 10/*ET.length*/; i++) {
        for (int j = 0; j < 10/*ET[0].length*/; j++) {
            etSeries.add(i * ET[0].length + j, ET[i][j]);
        }//from  ww  w .j  a  v  a  2  s.  c  om
    }

    XYSeries rainSeries = new XYSeries("RAIN");
    double[][] RAIN = utils.getRain();
    for (int i = 0; i < 10/*RAIN.length*/; i++) {
        for (int j = 0; j < 10/*RAIN[0].length*/; j++) {
            rainSeries.add(i * RAIN[0].length + j, RAIN[i][j]);
        }
    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(etSeries);
    dataset.addSeries(rainSeries);

    JFreeChart chart = ChartFactory.createXYLineChart("Weather Data", "Days", "Inches",
            dataset/*,
                   PlotOrientation.VERTICAL, true, true, false*/);
    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.GRAY);
    plot.setDomainGridlinePaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.white);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesShapesVisible(1, false);
    plot.setRenderer(renderer);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    ChartPanel panel = new ChartPanel(chart);
    jTabbedPane1.addTab("Weather", panel);

}

From source file:br.usp.icmc.gazetteer.SemanticSearchTest.Grafico.java

public ChartPanel interpolado(int index) {

    // create the chart...  
    JFreeChart graf = ChartFactory.createXYLineChart("Interpolado", // chart title  
            "Recall", // x axis label  
            "Precision", // y axis label  
            createDatasetInterpoled(index), // data  
            PlotOrientation.VERTICAL, true, // include legend  
            true, // tooltips  
            false // urls  
    );/*from w w  w.  ja  v  a  2 s  .  c  o  m*/

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...  
    graf.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...  
    XYPlot plot = (XYPlot) graf.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setShapesVisible(false);

    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false);
    plot.setRenderer(1, renderer2);

    // change the auto tick unit selection to integer units only...  
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // OPTIONAL CUSTOMISATION COMPLETED.  

    ChartPanel myChartPanel = new ChartPanel(graf, true);
    return myChartPanel;
}

From source file:com.opensourcestrategies.crmsfa.reports.JFreeCrmsfaCharts.java

/**
 * Open Cases snapshot.  Description at http://www.opentaps.org/docs/index.php/CRMSFA_Dashboard
 * Note that this counts all the cases in the system for now.
 *//*  ww w  .j  a  va  2s. com*/
public static String createOpenCasesChart(Delegator delegator, Locale locale)
        throws GenericEntityException, IOException {
    Map uiLabelMap = UtilMessage.getUiLabels(locale);

    // create the dataset
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    // get all case statuses that are not "closed" (this is dynamic because statuses may be added at run time)
    List<GenericValue> statuses = ReportHelper.findCasesStagesForDashboardReporting(delegator);

    // Report number of cases for each status
    for (GenericValue status : statuses) {
        String statusId = status.getString("statusId");
        long count = delegator.findCountByCondition("CustRequest",
                EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, statusId), null);
        dataset.addValue(count, "", (String) status.get("description", locale));
    }

    // set up the chart
    JFreeChart chart = ChartFactory.createBarChart((String) uiLabelMap.get("CrmOpenCases"), // chart title
            null, // domain axis label
            null, // range axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, // orientation
            false, // include legend
            true, // tooltips
            false // urls
    );
    chart.setBackgroundPaint(Color.white);
    chart.setBorderVisible(true);
    chart.setPadding(new RectangleInsets(5.0, 5.0, 5.0, 5.0));

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    // get the bar renderer to put effects on the bars
    final BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false); // disable bar outlines

    // set up gradient paint on bar
    final GradientPaint gp = new GradientPaint(0.0f, 0.0f, new Color(246, 227, 206), 0.0f, 0.0f,
            new Color(204, 153, 102));
    renderer.setSeriesPaint(0, gp);

    // change the auto tick unit selection to integer units only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // tilt the category labels so they fit
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

    // save as a png and return the file name
    return ServletUtilities.saveChartAsPNG(chart, 360, 300, null);
}

From source file:jmemorize.gui.swing.panels.DeckChartPanel.java

private JFreeChart createChart() {
    m_dataset = createDefaultDataSet();//from ww w . j a  v  a2 s. co  m

    JFreeChart chart = ChartFactory.createStackedBarChart3D(null, // chart title
            null, // domain axis label
            Localization.get("DeckChart.CARDS"), // range axis label //$NON-NLS-1$
            m_dataset, // data
            PlotOrientation.VERTICAL, // the plot orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    // setup legend
    // TODO we used to do this for the old jfreechar version, but it's not clear why.
    // can we get rid of it?
    LegendTitle legend = chart.getLegend();
    //        legend.setsetRenderingOrder(LegendRenderingOrder.REVERSE);
    legend.setItemFont(legend.getItemFont().deriveFont(11f));

    // setup plot
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    TickUnitSource tickUnits = NumberAxis.createIntegerTickUnits();
    plot.getRangeAxis().setStandardTickUnits(tickUnits); //CHECK use locale
    plot.setForegroundAlpha(0.99f);

    // setup renderer
    m_barRenderer = new MyBarRenderer();
    m_barRenderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    m_barRenderer.setItemLabelsVisible(true);
    m_barRenderer
            .setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
    plot.setRenderer(m_barRenderer);
    setSeriesPaint();

    return chart;
}

From source file:userinterface.graph.PrismLogarithmicAxis.java

/**
 * Creates a new <code>LogAxis</code> with the given label.
 * /*from   w ww .  j  a v  a  2  s .  c  o m*/
 * @param label  the axis label (<code>null</code> permitted).
 */
public PrismLogarithmicAxis(String label) {
    super(label, NumberAxis.createIntegerTickUnits());
    setDefaultAutoRange(new Range(0.01, 1.0));
    this.tickUnit = new NumberTickUnit(1.0);
    this.minorTickCount = 10;
    this.setTickMarksVisible(false);
    this.baseAndExponentFormatOverride = true;
}

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

private JFreeChart createChartBar(CategoryDataset dataset) {
    JFreeChart chart = ChartFactory.createBarChart("Votacion", "Opciones", "Total de votos", dataset,
            PlotOrientation.VERTICAL, true, true, true);
    try {//  w  ww.  j  a v  a 2  s  .c  o m

        chart.addSubtitle(new TextTitle(ac.getPreguntas().getJSONObject(pox).getString("pregunta")));
        chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.white));
        CategoryPlot plot = chart.getCategoryPlot();
        org.jfree.chart.axis.CategoryAxis axis = plot.getDomainAxis();
        axis.setCategoryLabelPositions(
                CategoryLabelPositions.createUpRotationLabelPositions(0.39269908169872414D));
        //            final CategoryItemRenderer itemRenderer = new CustomRenderer(
        //                    new Paint[] {Color.green, Color.red, Color.blue, Color.yellow, Color.magenta, Color.cyan, Color.pink, Color.lightGray}
        //            );
        ////        itemRenderer.setBaseItemLabelsVisible(true);
        ////        BarRenderer barRenderer = (BarRenderer)itemRenderer;
        ////        barRenderer.setItemMargin(0.2D);
        ////        plot.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, new java.awt.Color(147, 60, 45)));
        ////        //        StandardCategoryToolTipGenerator toolTipGenerator = new StandardCategoryToolTipGenerator("{0}: {2} %", new DecimalFormat("0"));
        //            //
        //            plot.setNoDataMessage("SIN DATOS!");
        //            
        //            
        ////        renderer.setLabelGenerator(new StandardCategoryLabelGenerator());
        //            itemRenderer.setItemLabelsVisible(true);
        //            final ItemLabelPosition p = new ItemLabelPosition(
        //                    ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, 45.0
        //            );
        //            itemRenderer.setPositiveItemLabelPosition(p);
        //            plot.setRenderer(itemRenderer);

        // change the margin at the top of the range axis...
        final ValueAxis rangeAxis = plot.getRangeAxis();
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        rangeAxis.setLowerMargin(0.15);
        rangeAxis.setUpperMargin(0.15);

    } catch (JSONException ex) {
        Logger.getLogger(Datos.class.getName()).log(Level.SEVERE, null, ex);
    }
    return chart;
}