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:graphs.ResultsGraphs.java

/**
 * Creates a sample chart./*w w w  .  j a va 2 s.c  om*/
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createBarChart("Mashup Language Sentiment Algorithm Performance ", // chart title
            "Performance Metric", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );

    // 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));
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:net.nosleep.superanalyzer.analysis.views.MostPlayedDGView.java

public JFreeChart createChart(String title, String domainLabel, DefaultCategoryDataset dataset) {

    JFreeChart chart = ChartFactory.createBarChart3D(title, // chart title
            domainLabel, // domain axis label
            Misc.getString("SONG_COUNT"), // range axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, // orientation
            false, // include legend
            true, // tooltips?
            false // URLs?
    );/*from w  w  w  . j a  va 2  s  .  c  om*/

    // _artistChart.addSubtitle(HomePanel
    // .createSubtitle("How many songs you have in each genre"));

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

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

    ChartUtilities.applyCurrentTheme(chart);

    Misc.formatChart(plot);
    plot.getDomainAxis().setMaximumCategoryLabelWidthRatio(0.5f);

    CategoryItemRenderer renderer = plot.getRenderer();
    BarRenderer3D barRenderer = (BarRenderer3D) renderer;
    barRenderer.setWallPaint(Color.white);
    barRenderer.setSeriesPaint(0, Theme.getColorSet()[1]);

    return chart;
}

From source file:domainhealth.frontend.graphics.JFreeChartGraphImpl.java

/**
 * Write a PNG image representation of the Graph to the given output 
 * stream//ww  w.j  av  a  2  s .c  o  m
 * 
 * @param out The output stream to write the PNG bytes to
 * @throws IOException Indicates a problem writing to the output stream
 */
public void writeGraphImage(int numServersDisplayed, OutputStream out) throws IOException {
    ValueAxis xAxis = new DateAxis(MonitorProperties.units(DATE_TIME));
    NumberAxis yAxis = new NumberAxis(yAxisUnits);
    yAxis.setAutoRangeIncludesZero(true);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYPlot xyPlotLine = new XYPlot(xySeriesCollection, xAxis, yAxis,
            new StandardXYItemRenderer(StandardXYItemRenderer.LINES));
    JFreeChart chart = new JFreeChart(chartTitle, JFreeChart.DEFAULT_TITLE_FONT, xyPlotLine, true);
    chart.setBackgroundPaint(java.awt.Color.white);
    // Increase size of graph height to accommodate large legends for when many servers in the domain
    int graphAdditionalHeight = GRAPH_INCREMENT_HEIGHT
            * ((int) (numServersDisplayed / GRAPH_INCREMENT_SERVER_RATIO));
    BufferedImage graphImage = chart.createBufferedImage(GRAPH_WIDTH,
            INITIAL_GRAPH_HEIGHT + graphAdditionalHeight,
            new ChartRenderingInfo(new StandardEntityCollection()));
    addNoDataLogoIfEmpty(graphImage);
    ChartUtilities.writeBufferedImageAsPNG(out, graphImage); // Could try extra two PNG related params: encodeAlpha and compression
}

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

/**
 * Creates a sample chart./*from  ww w.  j a v  a 2 s  . 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:com.marvelution.jira.plugins.hudson.charts.BuildResultsRatioChartGenerator.java

/**
 * {@inheritDoc}//from ww w .  j a  v  a2  s .c o  m
 */
@Override
public ChartHelper generateChart() {
    final Map<Integer, Build> buildMap = new HashMap<Integer, Build>();
    final CategoryTableXYDataset dataSet = new CategoryTableXYDataset();
    for (Build build : builds) {
        buildMap.put(Integer.valueOf(build.getBuildNumber()), build);
        dataSet.add(Double.valueOf(build.getBuildNumber()), Double.valueOf(build.getDuration()),
                getI18n().getText("hudson.charts.duration"));
    }
    final JFreeChart chart = ChartFactory.createXYBarChart("", "", false,
            getI18n().getText("hudson.charts.duration"), dataSet, PlotOrientation.VERTICAL, false, false,
            false);
    chart.setBackgroundPaint(Color.WHITE);
    chart.setBorderVisible(false);
    final BuildResultRenderer renderer = new BuildResultRenderer(server, buildMap);
    renderer.setBaseItemLabelFont(ChartDefaults.defaultFont);
    renderer.setBaseItemLabelsVisible(false);
    renderer.setMargin(0.0D);
    renderer.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER));
    renderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
    renderer.setBaseToolTipGenerator(renderer);
    renderer.setURLGenerator(renderer);
    final XYPlot xyPlot = chart.getXYPlot();
    xyPlot.setAxisOffset(new RectangleInsets(1.0D, 1.0D, 1.0D, 1.0D));
    xyPlot.setRenderer(renderer);
    final NumberAxis domainAxis = new NumberAxis();
    domainAxis.setLowerBound(Collections.min(buildMap.keySet()));
    domainAxis.setUpperBound(Collections.max(buildMap.keySet()));
    final TickUnitSource ticks = NumberAxis.createIntegerTickUnits();
    domainAxis.setStandardTickUnits(ticks);
    xyPlot.setDomainAxis(domainAxis);
    final DateAxis rangeAxis = new DateAxis();
    final DurationFormat durationFormat = new DurationFormat();
    rangeAxis.setDateFormatOverride(durationFormat);
    rangeAxis.setLabel(getI18n().getText("hudson.charts.duration"));
    xyPlot.setRangeAxis(rangeAxis);
    ChartUtil.setupPlot(xyPlot);
    return new ChartHelper(chart);
}

From source file:j2se.jfreechart.barchart.BarChartDemo2.java

/**
 * Creates a chart./*from   w ww .j  av a  2s  . com*/
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {

    final JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo 2", // chart title
            "Category", // domain axis label
            "Score (%)", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, false);

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

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

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

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

    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

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

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

    final JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo 2", // chart title
            "Category", // domain axis label
            "Score (%)", // range axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, // orientation
            true, // include legend
            true, false);

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

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

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

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

    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:org.jfree.expdemo.SelectionDemo5Category.java

private static JFreeChart createChart(CategoryDataset dataset, DatasetSelectionExtension ext) {

    // create the chart...
    JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo 1", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );//from w  w w.j  ava2s . co  m

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setDomainGridlinesVisible(true);
    plot.setRangeCrosshairVisible(true);
    plot.setRangeCrosshairPaint(Color.blue);

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

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

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

    renderer.setLegendItemToolTipGenerator(new StandardCategorySeriesLabelGenerator("Tooltip: {0}"));

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

    //add selection specific rendering
    IRSUtilities.setSelectedItemPaint(renderer, ext, Color.WHITE);

    //register plot as selection change listener
    ext.addSelectionChangeListener(plot);

    return chart;

}

From source file:net.nosleep.superanalyzer.analysis.views.MostPlayedAAView.java

public JFreeChart createChart(String title, String domainLabel, DefaultCategoryDataset dataset) {
    JFreeChart chart = ChartFactory.createBarChart3D(title, // chart title
            domainLabel, // domain axis label
            Misc.getString("SONG_COUNT"), // range axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, // orientation
            false, // include legend
            true, // tooltips?
            false // URLs?
    );/*from w  ww. ja  v  a2  s.c om*/

    // _artistChart.addSubtitle(HomePanel
    // .createSubtitle("How many songs you have in each genre"));

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

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

    ChartUtilities.applyCurrentTheme(chart);

    Misc.formatChart(plot);
    plot.getDomainAxis().setMaximumCategoryLabelWidthRatio(0.5f);

    CategoryItemRenderer renderer = plot.getRenderer();
    BarRenderer3D barRenderer = (BarRenderer3D) renderer;
    barRenderer.setWallPaint(Color.white);
    barRenderer.setSeriesPaint(0, Theme.getColorSet()[1]);

    return chart;
}

From source file:fitmon.Chart.java

/**
 * Creates a sample chart.//from w  w w. ja  va2s.c  o m
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );

    // 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));
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}