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

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

Introduction

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

Prototype

public void setLowerBound(double min) 

Source Link

Document

Sets the lower bound for the axis range.

Usage

From source file:com.alcatel_lucent.nz.wnmsreport.chart.TimeSeriesChartCustomiser.java

public void customise(JFreeChart chart, JRChart jasperchart) {

    //LineAndShapeRenderer renderer = (LineAndShapeRenderer) chart.getCategoryPlot().getRenderer(); 
    //renderer.setSeriesPaint(1, Color.green); 
    //renderer.setSeriesPaint(4, Color.orange);        

    //chart.setTitle("Customiser has set a new Title"); 

    try {//from   ww w  .j  a v a 2 s .c  o  m

        XYPlot plot = chart.getXYPlot();

        NumberAxis x = (NumberAxis) plot.getDomainAxis();
        //x.setLowerBound(x.getLowerBound()+100);
        x.setUpperBound(x.getUpperBound() + 100);

        NumberAxis y = (NumberAxis) plot.getRangeAxis();
        y.setLowerBound(0);
        y.setUpperBound(100);

    } catch (NullPointerException npe) {
        System.err.println("Error setting chart axis ranges :: " + npe);
    }

}

From source file:net.sf.maltcms.common.charts.ui.XYChartComponentOpenAction.java

@Override
public void actionPerformed(ActionEvent e) {
    Task t = RequestProcessor.getDefault().create(new Runnable() {
        @Override/* ww w  .  ja  v a 2s .c o  m*/
        public void run() {
            final Numeric1DDataset<Point2D> dataset = createDataset();
            final XYChartBuilder builder = new XYChartBuilder();
            XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, true);
            renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
            renderer.setBaseItemLabelsVisible(true);
            renderer.setDefaultEntityRadius(50);
            NumberAxis domain = new NumberAxis("x-axis");
            domain.setLowerBound(-100);
            domain.setUpperBound(1000);
            domain.setLowerMargin(0.1);
            domain.setUpperMargin(0.1);
            domain.setPositiveArrowVisible(true);
            domain.setNegativeArrowVisible(true);
            builder.xy(dataset).renderer(renderer).domainAxis(domain).useBuffer(false).minimumDrawSize(400, 300)
                    .preferredDrawSize(800, 600).plot().chart("Sample plot").createLegend(true);
            invokeLater(new Runnable() {
                @Override
                public void run() {
                    TopComponent tc = WindowManager.getDefault().findTopComponent("navigatorTC");
                    if (tc != null) {
                        tc.open();
                    }
                }
            });
            invokeLater(new Runnable() {

                @Override
                public void run() {
                    XYChartTopComponent<Point2D> xytc = new XYChartTopComponent<>(Point2D.class, dataset,
                            builder);
                    xytc.open();
                    xytc.requestActive();
                }
            });

        }
    });
    RequestProcessor.getDefault().post(t);
}

From source file:com.marvelution.jira.plugins.hudson.charts.BuildResultsRatioChartGenerator.java

/**
 * {@inheritDoc}// ww w.  ja  v a2s.co  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:mrmc.chart.StudyDesignPlot.java

/**
 * Constructs the chart//from ww w. ja v a  2 s .c o  m
 * 
 * @param dataset Representation of x-y data
 * @param title Title of chart
 * @param xaxis Label for x-axis
 * @param yaxis Label for y-axis
 * @return The chart
 */
private JFreeChart createChart(final DefaultXYDataset dataset, String title, String xaxis, String yaxis) {
    final JFreeChart chart = ChartFactory.createScatterPlot(title, xaxis, yaxis, dataset,
            PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyplot = (XYPlot) chart.getPlot();
    NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis();
    ;

    rangeAxis.setLowerBound(-.5);

    rangeAxis.setTickUnit(new NumberTickUnit(1));
    XYItemRenderer renderer = xyplot.getRenderer();
    Rectangle square = new Rectangle(5, 5);
    renderer.setSeriesShape(0, square);
    renderer.setSeriesShape(1, square);
    renderer.setSeriesPaint(0, Color.white);
    renderer.setSeriesPaint(1, Color.black);
    return chart;

}

From source file:pwm.visualizer.MDPPolicyPanel.java

private JFreeChart createChart() {
    NumberAxis nutritionAxis = new NumberAxis("Calories/Day");
    nutritionAxis.setLowerBound(0);
    nutritionAxis.setUpperBound(5000);/* ww w .  j ava 2  s.  c  o m*/
    nutritionAxis.setAutoRange(false);
    //      
    CategoryPlot categoryplot = new CategoryPlot(nutritionDataSet, new CategoryAxis("Weight(KG)"),
            nutritionAxis, new BarRenderer());
    CategoryAxis xaxis = categoryplot.getDomainAxis();
    xaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);

    LegendItemCollection legend = new LegendItemCollection();
    LegendItem nutritionLegend = new LegendItem("Calories/Day");
    LegendItem exerciseLegend = new LegendItem("Physical Activity Level");
    nutritionLegend.setFillPaint(Color.BLUE);
    exerciseLegend.setFillPaint(Color.RED);

    legend.add(nutritionLegend);
    legend.add(exerciseLegend);

    categoryplot.setFixedLegendItems(legend);
    JFreeChart jfreechart = new JFreeChart("Policy Visualizer", categoryplot);
    categoryplot.setDataset(1, exerciseDataSet);
    categoryplot.mapDatasetToRangeAxis(1, 1);

    NumberAxis exerciseAxis = new NumberAxis("Physical Activity Level");
    exerciseAxis.setLowerBound(0);
    exerciseAxis.setUpperBound(3.0);
    exerciseAxis.setAutoRange(false);

    categoryplot.setRangeAxis(1, exerciseAxis);
    BarRenderer barrenderer1 = new BarRenderer();
    categoryplot.setRenderer(1, barrenderer1);

    //        BarRenderer stackedbarrenderer = (BarRenderer)categoryplot.getRenderer();
    //        stackedbarrenderer.setDrawBarOutline(true);
    //        stackedbarrenderer.setBaseItemLabelsVisible(false);
    //        stackedbarrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());

    ChartUtilities.applyCurrentTheme(jfreechart);

    return jfreechart;

}

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

/**
 * A demonstration application showing a bubble chart using matrix series.
 *
 * @param title the frame title.//from w w  w.j a va  2  s.  c o  m
 */
public BubblyBubblesDemo(final String title) {
    super(title);

    this.series = createInitialSeries();

    final MatrixSeriesCollection dataset = new MatrixSeriesCollection(this.series);

    final JFreeChart chart = ChartFactory.createBubbleChart(TITLE, "X", "Y", dataset, PlotOrientation.VERTICAL,
            true, true, false);

    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));

    final XYPlot plot = chart.getXYPlot();
    plot.setForegroundAlpha(0.5f);

    final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setLowerBound(-0.5);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();

    // rangeAxis.setInverted(true);  // uncoment to reproduce a bug in jFreeChart
    rangeAxis.setLowerBound(-0.5);

    final ChartPanel chartPanel = new ChartPanel(chart);
    //        chartPanel.setVerticalZoom(true);
    //      chartPanel.setHorizontalZoom(true);
    setContentPane(chartPanel);
}

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

/**
 * A demonstration application showing a bubble chart using matrix series.
 *
 * @param title the frame title.//from   w w  w.ja  v a2s  .  co m
 */
public BubblyBubblesDemo2(final String title) {
    super(title);

    this.series = createInitialSeries();

    final MatrixSeriesCollection dataset = new MatrixSeriesCollection(this.series);

    final JFreeChart chart = ChartFactory.createBubbleChart(TITLE, "X", "Y", dataset, PlotOrientation.VERTICAL,
            true, true, false);

    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.yellow));

    final XYPlot plot = chart.getXYPlot();
    plot.setForegroundAlpha(0.5f);

    final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setLowerBound(-0.5);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();

    rangeAxis.setLowerBound(-0.5);

    final ChartPanel chartPanel = new ChartPanel(chart);
    //        chartPanel.setVerticalZoom(true);
    //      chartPanel.setHorizontalZoom(true);
    setContentPane(chartPanel);
}

From source file:com.marvelution.jira.plugins.hudson.charts.BuildTestResultsRatioChartGenerator.java

/**
 * {@inheritDoc}//w  w  w  .  j a va  2  s . c  om
 */
@Override
public ChartHelper generateChart() {
    buildMap = new HashMap<Integer, Build>();
    final CategoryTableXYDataset dataset = new CategoryTableXYDataset();
    for (Build build : builds) {
        final TestResult results = build.getTestResult();
        double percentagePass = 0.0D, percentageFail = 0.0D, percentageSkipped = 0.0D;
        if (results != null && results.getTotal() > 0) {
            percentagePass = Double.valueOf(results.getPassed()) / Double.valueOf(results.getTotal()) * 100.0D;
            percentageFail = Double.valueOf(results.getFailed()) / Double.valueOf(results.getTotal()) * 100.0D;
            percentageSkipped = Double.valueOf(results.getSkipped()) / Double.valueOf(results.getTotal())
                    * 100.0D;
        }
        dataset.add(Double.valueOf(build.getBuildNumber()), percentagePass, seriesNames[0]);
        dataset.add(Double.valueOf(build.getBuildNumber()), percentageFail, seriesNames[1]);
        dataset.add(Double.valueOf(build.getBuildNumber()), percentageSkipped, seriesNames[2]);
        buildMap.put(Integer.valueOf(build.getBuildNumber()), build);
    }
    final JFreeChart chart = ChartFactory.createStackedXYAreaChart("", "",
            getI18n().getText("hudson.charts.tests"), dataset, PlotOrientation.VERTICAL, false, false, false);
    chart.setBackgroundPaint(Color.WHITE);
    chart.setBorderVisible(false);
    XYPlot xyPlot = chart.getXYPlot();
    xyPlot.setDataset(1, dataset);
    if (dataset.getItemCount() > 0) {
        XYLineAndShapeRenderer shapeRenderer = new XYLineAndShapeRenderer(false, true);
        shapeRenderer.setSeriesShapesVisible(1, false);
        shapeRenderer.setSeriesLinesVisible(1, false);
        shapeRenderer.setSeriesShapesVisible(2, false);
        shapeRenderer.setSeriesLinesVisible(2, false);
        shapeRenderer.setSeriesShape(0, new Ellipse2D.Double(-3.0D, -3.0D, 6.0D, 6.0D));
        shapeRenderer.setSeriesPaint(0, GREEN_PAINT);
        shapeRenderer.setSeriesShapesFilled(0, true);
        shapeRenderer.setBaseToolTipGenerator(this);
        shapeRenderer.setBaseItemLabelFont(ChartDefaults.defaultFont);
        shapeRenderer.setBaseItemLabelsVisible(false);
        xyPlot.setRenderer(0, shapeRenderer);
        StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
        renderer.setSeriesPaint(0, GREEN_PAINT);
        renderer.setSeriesPaint(1, RED_PAINT);
        renderer.setSeriesPaint(2, YELLOW_PAINT);
        renderer.setBaseItemLabelFont(ChartDefaults.defaultFont);
        renderer.setBaseItemLabelsVisible(false);
        xyPlot.setRenderer(1, renderer);
        renderer.setBaseToolTipGenerator(this);
    }
    ValueAxis rangeAxis = xyPlot.getRangeAxis();
    rangeAxis.setLowerBound(0.0D);
    rangeAxis.setUpperBound(100.0D);
    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);
    ChartUtil.setupPlot(xyPlot);
    return new ChartHelper(chart);
}

From source file:com.thalesgroup.hudson.plugins.klocwork.graph.KloTrendGraph.java

@Override
protected JFreeChart createGraph() {
    final JFreeChart chart = ChartFactory.createLineChart(null, // chart title
            null, // unused
            yLabel, // range axis label
            categoryDataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );//from   www . java  2  s  .co  m

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

    final LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.RIGHT);

    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = chart.getCategoryPlot();

    // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);

    CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
    plot.setDomainAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.setCategoryMargin(0.0);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLowerBound(0);
    rangeAxis.setAutoRange(true);

    final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseStroke(new BasicStroke(2.0f));
    ColorPalette.apply(renderer);

    // crop extra space around the graph
    plot.setInsets(new RectangleInsets(5.0, 0, 0, 5.0));

    return chart;
}

From source file:cheuk.licenseheaderchecker.resource.DataGraph.java

/**
* Creates a trend graph/*from  ww w. j a va2  s. co m*/
*
* @return the JFreeChart graph object
*/
protected JFreeChart createGraph() {

    final JFreeChart chart = ChartFactory.createLineChart(null, // chart title
            null, // unused
            yLabel, // range axis label
            categoryDataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips
            false // urls
    );

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

    //final LegendTitle legend = chart.getLegend();
    //legend.setPosition(RectangleEdge.RIGHT);

    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = chart.getCategoryPlot();

    // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);

    CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
    plot.setDomainAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.setCategoryMargin(0.0);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLowerBound(0);
    //        rangeAxis.setAutoRange(true);

    final StackedAreaRenderer renderer = new StackedAreaRenderer2();
    plot.setRenderer(renderer);
    //renderer.setBaseStroke(new BasicStroke(2.0f));
    //ColorPalette.apply(renderer);
    plot.setRenderer(renderer);
    renderer.setSeriesPaint(2, RED);
    renderer.setSeriesPaint(1, GRAY);
    renderer.setSeriesPaint(0, YELLOW);

    // crop extra space around the graph
    plot.setInsets(new RectangleInsets(5.0, 0, 0, 5.0));

    return chart;
}