Example usage for org.jfree.chart.axis ValueAxis setLowerMargin

List of usage examples for org.jfree.chart.axis ValueAxis setLowerMargin

Introduction

In this page you can find the example usage for org.jfree.chart.axis ValueAxis setLowerMargin.

Prototype

public void setLowerMargin(double margin) 

Source Link

Document

Sets the lower margin for the axis (as a percentage of the axis range) and sends an AxisChangeEvent to all registered listeners.

Usage

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

/**
 * Creates a chart.//  ww  w. j av  a  2  s .  c om
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
protected JFreeChart createChart(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, domainLabel, rangeLabel, dataset,
            !legendPanelOn, // legend
            true, // tool tips
            false // URLs
    );
    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();
    plot.setRenderer(new XYDifferenceRenderer(Color.green, Color.red, false));
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));

    XYItemRenderer renderer = plot.getRenderer();
    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());

    ValueAxis domainAxis = new DateAxis("Time");
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    plot.setDomainAxis(domainAxis);
    plot.setForegroundAlpha(0.5f);

    //setXSummary(dataset) X is time;          
    return chart;

}

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

/**
 * Creates a sample chart.//from   w  ww . ja v a2  s  .com
 * 
 * @param dataset  the dataset for the chart.
 * 
 * @return a sample chart.
 */
protected JFreeChart createChart(CategoryDataset dataset) {

    JFreeChart chart = ChartFactory.createStackedBarChart(chartTitle, // chart title
            domainLabel, // domain axis label
            rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // the plot orientation
            !legendPanelOn, // legend
            false, // tooltips
            false // urls
    );
    CategoryPlot plot = chart.getCategoryPlot();
    CategoryItemRenderer renderer = new ExtendedStackedBarRenderer();
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    plot.setRenderer(renderer);

    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLowerMargin(0.15);
    rangeAxis.setUpperMargin(0.15);

    StackedBarRenderer renderer2 = (StackedBarRenderer) plot.getRenderer();
    renderer2.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());

    setCategorySummary(dataset);
    return chart;

}

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

/**
 * Creates a chart./*ww w.j  a  v a 2 s  . c o m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
protected JFreeChart createChart(XYDataset dataset) {

    JFreeChart chart = ChartFactory.createXYAreaChart(chartTitle, "Domain (X)", "Range (Y)", dataset,
            PlotOrientation.VERTICAL, !legendPanelOn, // legend
            true, // tool tips
            false // URLs
    );

    chart.setBackgroundPaint(Color.white);

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setForegroundAlpha(0.65f);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setTickMarkPaint(Color.black);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);

    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setTickMarkPaint(Color.black);

    /*  XYPointerAnnotation pointer = new XYPointerAnnotation(
    "Test", 5.0, -500.0, 3.0 * Math.PI / 4.0
      );
      pointer.setTipRadius(0.0); 
      pointer.setBaseRadius(35.0); 
      pointer.setFont(new Font("SansSerif", Font.PLAIN, 9)); 
      pointer.setPaint(Color.blue); 
      pointer.setTextAnchor(TextAnchor.HALF_ASCENT_RIGHT); 
      plot.addAnnotation(pointer);*/

    XYItemRenderer renderer = plot.getRenderer();
    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());
    setXSummary(dataset);
    return chart;

}

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

/**
 * Creates a sample chart./*from  w ww  .  java 2s . c  o  m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return a sample chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {

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

    chart.setBackgroundPaint(Color.lightGray);

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setNoDataMessage("NO DATA!");

    final CategoryItemRenderer renderer = new CustomRenderer(new Paint[] { Color.red, Color.blue, Color.green,
            Color.yellow, Color.orange, Color.cyan, Color.magenta, Color.blue });
    //        renderer.setLabelGenerator(new StandardCategoryLabelGenerator());
    renderer.setItemLabelsVisible(true);
    final ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER,
            TextAnchor.CENTER, 45.0);
    renderer.setPositiveItemLabelPosition(p);
    plot.setRenderer(renderer);

    // 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);

    return chart;

}

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

/**
 * Creates a chart./*from   w  w w  . ja va 2 s  .  co  m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
protected JFreeChart createChart(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createXYAreaChart(chartTitle, "Time", "Value", dataset,
            PlotOrientation.VERTICAL, !legendPanelOn, // legend
            true, // tool tips
            false // URLs
    );
    XYPlot plot = chart.getXYPlot();

    ValueAxis domainAxis = new DateAxis("Time");
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    plot.setDomainAxis(domainAxis);
    plot.setForegroundAlpha(0.5f);

    XYItemRenderer renderer = plot.getRenderer();
    renderer.setBaseToolTipGenerator(
            new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                    new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("#,##0.00")));
    renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator());
    // setXSummary(dataset);    X is time
    return chart;
}

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

/**
 * Creates a sample chart.//w ww  .  j  av  a2 s. com
 * 
 * @param dataset  the dataset.
 * 
 * @return a sample chart.
 */
protected JFreeChart createChart(CategoryDataset dataset) {

    JFreeChart chart = ChartFactory.createStackedBarChart(chartTitle, domainLabel, // domain axis label
            rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, // the plot orientation
            !legendPanelOn, // include legend
            true, // tooltips
            false // urls
    );

    /*  CategoryPlot plot = (CategoryPlot) chart.getPlot();
      StackedBarRenderer renderer = (StackedBarRenderer) plot.getRenderer();
      renderer.setItemLabelsVisible(true);*/

    CategoryPlot plot = chart.getCategoryPlot();
    CategoryItemRenderer renderer = new ExtendedStackedBarRenderer();
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    plot.setRenderer(renderer);

    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLowerMargin(0.15);
    rangeAxis.setUpperMargin(0.15);

    StackedBarRenderer renderer2 = (StackedBarRenderer) plot.getRenderer();
    renderer2.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());

    setCategorySummary(dataset);
    return chart;
}

From source file:graficarordenamiento.Graficador.java

public void crearGrafico() {
    // Creando el Grafico
    chart = ChartFactory.createBarChart("Grfico de barras", null, null, dataset, PlotOrientation.VERTICAL,
            false, false, false);/*  ww  w  .  j  a  va2  s . c om*/

    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.WHITE, 700, 0, Color.BLACK.brighter(), false));
    chart.setBackgroundImageAlpha(0.5f);
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setNoDataMessage("NO DATA!");
    plot.setRangeGridlinePaint(Color.red);
    plot.setBackgroundPaint(new GradientPaint(0, 0, Color.LIGHT_GRAY, 0, 100, Color.darkGray));
    plot.setBackgroundImageAlpha(0.5f);
    //plot.setDomainGridlinesVisible(true);

    BarRenderer rend = (BarRenderer) plot.getRenderer();

    final ItemLabelPosition e = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER,
            TextAnchor.CENTER, 45.0);

    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));

    rend.setSeriesPaint(0, gp0);
    rend.setSeriesPaint(1, gp1);
    rend.setSeriesPaint(2, gp2);
    plot.setRenderer(rend);

    // 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);

    // set up gradient paints for series...

}

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

private void createChart() {

    _chart = ChartFactory.createXYAreaChart(Misc.getString("LIBRARY_GROWTH"), Misc.getString("DATE"),
            Misc.getString("SONGS_IN_LIBRARY"), _dataset, PlotOrientation.VERTICAL, false, // legend
            true, // tool tips
            false // URLs
    );/*from   www .  jav  a 2 s . c  om*/
    XYPlot plot = (XYPlot) _chart.getPlot();
    plot.setDomainPannable(true);
    ValueAxis domainAxis = new DateAxis(Misc.getString("TIME"));
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    plot.setDomainAxis(domainAxis);
    plot.setForegroundAlpha(0.75f);

    XYItemRenderer renderer = plot.getRenderer();
    renderer.setBaseToolTipGenerator(
            new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                    new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("#,##0.00")));

    _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("LIBRARY_GROWTH_SUBTITLE")));

    ChartUtilities.applyCurrentTheme(_chart);
    Misc.formatChart(plot);

    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    renderer.setSeriesPaint(0, Theme.getColorSet()[1]);

}

From source file:com.xilinx.ultrascale.gui.PowerChart.java

private void makeChart() {
    dataset = new DefaultCategoryDataset();
    chart = ChartFactory.createBarChart("", "Time Interval", "", dataset, PlotOrientation.HORIZONTAL, true,
            true, false);/*from ww  w .ja va  2 s.  c om*/

    TextTitle ttitle = new TextTitle(title, new Font(title, Font.BOLD, 15));
    ttitle.setPaint(Color.WHITE);
    chart.setTitle(ttitle);
    chart.setBackgroundPaint(bg);

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);

    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    ValueAxis axis = plot.getRangeAxis();
    //        axis.setUpperBound(6);
    axis.setAutoRange(true);
    axis.setLowerMargin(0);
    axis.setUpperMargin(.40);
    //        TickUnits tickUnits = new TickUnits();
    //        tickUnits.add(new NumberTickUnit(1));
    //        axis.setStandardTickUnits(tickUnits);
    //        axis.setLowerBound(0.0);
    axis.setTickLabelPaint(new Color(185, 185, 185));

    CategoryAxis caxis = plot.getDomainAxis();
    caxis.setTickLabelPaint(new Color(185, 185, 185));
    caxis.setLabelPaint(new Color(185, 185, 185));

    renderer.setItemMargin(0);
    renderer.setSeriesPaint(0, new Color(0x2e, 0x90, 0x18));//(0x17, 0x7b, 0x7c));
    renderer.setSeriesPaint(1, new Color(0x12, 0x45, 0x73));//(0xa2, 0x45, 0x73)
    renderer.setSeriesPaint(2, new Color(0xff, 0x80, 0x40));
    renderer.setSeriesPaint(3, new Color(0x6f, 0x2c, 0x85));
    renderer.setBaseToolTipGenerator(
            new StandardCategoryToolTipGenerator("{0}:{2}", new DecimalFormat("0.000")));
    addDummy();
}

From source file:com.sonyericsson.jenkins.plugins.bfa.graphs.TimeSeriesChart.java

@Override
protected JFreeChart createGraph() {
    TimeTableXYDataset dataset = createDataset();
    ValueAxis xAxis = new DateAxis();
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);//  w ww  . jav a2s.c  o m
    Calendar lowerBound = getLowerGraphBound();
    xAxis.setRange(lowerBound.getTimeInMillis(), Calendar.getInstance().getTimeInMillis());

    NumberAxis yAxis = new NumberAxis(Y_AXIS_LABEL);
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    StackedXYBarRenderer renderer = new StackedXYBarRenderer();
    renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {
        @Override
        public String generateToolTip(XYDataset dataset, int series, int item) {
            String seriesKey = dataset.getSeriesKey(series).toString();
            StringBuilder sb = new StringBuilder();

            if (seriesKey.equals(GRAPH_OTHERS)) {
                long timeInMillis = dataset.getX(series, item).longValue();
                Date time = new Date(timeInMillis);

                TimePeriod period = null;
                if (intervalSize == Calendar.DATE) {
                    period = new Day(time);
                } else if (intervalSize == Calendar.HOUR_OF_DAY) {
                    period = new Hour(time);
                } else if (intervalSize == Calendar.MONTH) {
                    period = new Month(time);
                }
                List<FailureCauseTimeInterval> excludedDataList = excludedDataForPeriod.get(period);
                if (excludedDataList != null) {
                    Collections.sort(excludedDataList, new Comparator<FailureCauseTimeInterval>() {

                        @Override
                        public int compare(FailureCauseTimeInterval o1, FailureCauseTimeInterval o2) {
                            return o2.getNumber() - o1.getNumber();
                        }
                    });
                    for (FailureCauseTimeInterval excludedData : excludedDataList) {
                        sb.append(excludedData).append(" \n");
                    }
                }
            } else {
                int number = dataset.getY(series, item).intValue();
                sb.append(seriesKey).append(": ").append(number);
            }
            return sb.toString();
        }
    });

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(PlotOrientation.VERTICAL);

    plot.setRangeAxis(yAxis);

    JFreeChart chart = new JFreeChart(graphTitle, JFreeChart.DEFAULT_TITLE_FONT, plot, true);

    return chart;
}