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

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

Introduction

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

Prototype

public void setStandardTickUnits(TickUnitSource source) 

Source Link

Document

Sets the source for obtaining standard tick units for the axis and sends an AxisChangeEvent to all registered listeners.

Usage

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

/**
 * Creates a sample chart./* w w w.ja v  a2 s  .c o m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return A sample chart.
 */
public JFreeChart createChart(CategoryDataset dataset) {

    final JFreeChart chart = ChartFactory.createStackedAreaChart("Stacked Area Chart", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, false);

    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setForegroundAlpha(0.5f);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);

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

    final CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setItemLabelsVisible(true);

    return chart;

}

From source file:org.squale.squaleweb.util.graph.BarMaker.java

/**
 * @return le diagramme JFreeChart//from  w  ww  . j  a  va 2  s .  c om
 */
protected JFreeChart getChart() {
    JFreeChart retChart = super.getChart();
    if (null == retChart) {
        retChart = ChartFactory.createBarChart3D(mTitle, mXLabel, mYLabel, mDataSet, PlotOrientation.VERTICAL,
                false, false, false);

        CategoryPlot plot = retChart.getCategoryPlot();

        // Les valeurs sont des entiers
        final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

        // On effectue une rotation de 90 pour afficher le titre des abscisses  la verticale
        CategoryAxis domainAxis = plot.getDomainAxis();
        domainAxis.setCategoryLabelPositions(
                CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0));
        super.setChart(retChart);
    }
    return retChart;
}

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

/**
 * Creates a chart./*from  ww  w  . jav a2s  .co  m*/
 * 
 * @param dataset  a dataset.
 * 
 * @return A chart based on the supplied dataset.
 */
protected JFreeChart createChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title
            domainLabel, // x axis label
            rangeLabel, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, !legendPanelOn, // include legend
            true, // tooltips
            false // urls
    );

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

    // get a reference to the plot for further customisation...
    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setDrawOutlines(true);
    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

    // change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    setXSummary(dataset);
    return chart;
}

From source file:org.amanzi.awe.charts.builder.CategoryChartBuilder.java

@Override
protected NumberAxis configRangeAxis(IRangeAxis axis) {
    NumberAxis valueAxis = new NumberAxis(axis.getName());
    valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    return valueAxis;
}

From source file:slash.navigation.converter.gui.elevationview.ElevationView.java

private XYPlot createPlot(JFreeChart chart) {
    XYPlot plot = chart.getXYPlot();//from  w  ww . java 2s. co  m
    plot.setForegroundAlpha(0.65F);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    Font font = new JLabel().getFont();
    rangeAxis.setLabelFont(font);

    NumberAxis valueAxis = (NumberAxis) plot.getDomainAxis();
    valueAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    valueAxis.setLowerMargin(0.0);
    valueAxis.setUpperMargin(0.0);
    valueAxis.setLabelFont(font);

    XYItemRenderer renderer = plot.getRenderer();
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{2}m @ {1} Km",
            NumberFormat.getIntegerInstance(), NumberFormat.getIntegerInstance()));
    return plot;
}

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

/**
 * Creates a sample chart.//from   ww w  .j  a  va2s  .co m
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
protected JFreeChart createChart(XYDataset dataset) {

    // create the chart...
    JFreeChart chart = ChartFactory.createPolarChart(chartTitle, dataset, true, false, false);

    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    PolarPlot plot = (PolarPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    if (isDemo) {
        plot.addCornerTextItem("Corner Item 1");
        plot.addCornerTextItem("Corner Item 2");
    }

    plot.setRenderer(new SOCRPolarItemRenderer());
    //PolarItemRenderer renderer = plot.getRenderer();
    //renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

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

    setXSummary(dataset);
    if (legendPanelOn)
        chart.removeLegend();

    return chart;

}

From source file:bc.ui.swing.charts.LineChart.java

public void setModel(LineVisualModel line) {
    XYDataset dataset = createDataset(line);
    JFreeChart chart = ChartFactory.createXYLineChart(line.getTitle(), // chart title
            line.getDomainAxisLabel(), // x axis label
            line.getRangeAxisLabel(), // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );//from   ww  w. j a  v a 2  s.c o m

    chart.setBackgroundPaint(Color.white);

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

    renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);

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

    renderer.setSeriesPaint(0, new Color(153, 215, 255));

    removeAll();
    chartPanel = new ChartPanel(chart);
    add(chartPanel, BorderLayout.CENTER);
}

From source file:sanger.team16.gui.genevar.eqtl.snp.RegionalLinePlot.java

private JFreeChart createChart(String chromosome, int position, int distance, double threshold,
        XYDataset dataset) {//from  w w  w .ja  v  a  2  s  .c  o m
    JFreeChart chart = ChartFactory.createXYLineChart(null, "Position on chromosome " + chromosome + " (bp)",
            "-log10(P)", dataset, PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.lightGray);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setShapesVisible(true);
    //renderer.setShapesFilled(false);   //CHANGED 12/12/11
    // change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    /*       
           XYItemRenderer renderer = plot.getRenderer();  
           int size = dataset.getSeriesCount();
           for (int i=0 ; i<size ; i++) {
    //renderer.setSeriesPaint(i, new Color(255, 0, 0));
    renderer.setSeriesShape(i, ShapeUtilities.createDiamond((float) 3));
    renderer.setBaseSeriesVisibleInLegend(false);
           }
          */
    ValueMarker upperMarker = new ValueMarker(-Math.log10(threshold));
    upperMarker.setPaint(Color.gray);
    float[] f = { 4, 3, 4, 3 };
    upperMarker.setStroke(new BasicStroke(1.0f, 1, 1, 0, f, 1.0f));
    plot.addRangeMarker(upperMarker);

    ValueMarker marker = new ValueMarker(0.0);
    marker.setPaint(Color.lightGray);
    plot.addRangeMarker(marker);

    XYSeries series = new XYSeries("Range");
    series.add(position - distance, -0.05);
    series.add(position + distance, -0.05);
    ((XYSeriesCollection) dataset).addSeries(series);
    renderer.setSeriesVisible(dataset.getSeriesCount() - 1, false, false);

    return chart;
}

From source file:com.intel.stl.ui.monitor.view.TrafficChartsCreator.java

protected JFreeChart getPacketsRateChart(Dataset dataset) {
    JFreeChart chart = ComponentFactory.createXYAreaChart(STLConstants.K0035_TIME.getValue(),
            STLConstants.K0750_PPS.getValue(), (XYDataset) dataset, false);

    NumberAxis rangeAxis = (NumberAxis) chart.getXYPlot().getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(false);
    return chart;
}

From source file:com.intel.stl.ui.monitor.view.TrafficChartsCreator.java

protected JFreeChart getDataRateChart(Dataset dataset) {
    JFreeChart chart = ComponentFactory.createXYAreaChart(STLConstants.K0035_TIME.getValue(),
            STLConstants.K0703_MB_PER_SEC.getValue(), (XYDataset) dataset, false);

    NumberAxis rangeAxis = (NumberAxis) chart.getXYPlot().getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(false);
    return chart;
}