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

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

Introduction

In this page you can find the example usage for org.jfree.chart.axis DateAxis 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:org.jfree.chart.demo.StackedBarChartDemo6.java

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createStackedBarChart("Stacked Bar Chart Demo 6", "Category", "Value",
            categorydataset, PlotOrientation.HORIZONTAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setRangeGridlinePaint(Color.white);
    StackedBarRenderer stackedbarrenderer = (StackedBarRenderer) categoryplot.getRenderer();
    stackedbarrenderer.setDrawBarOutline(false);
    long l = System.currentTimeMillis();
    stackedbarrenderer.setBase(l);//  w  ww  .j  av  a2s .com
    DateAxis dateaxis = new DateAxis("Date");
    dateaxis.setLowerMargin(0.0D);
    categoryplot.setRangeAxis(dateaxis);
    return jfreechart;
}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Difference Chart Demo 1", "Time", "Value",
            xydataset, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    XYDifferenceRenderer xydifferencerenderer = new XYDifferenceRenderer(Color.green, Color.red, false);
    xydifferencerenderer.setRoundXCoordinates(true);
    xyplot.setDomainCrosshairLockedOnData(true);
    xyplot.setRangeCrosshairLockedOnData(true);
    xyplot.setDomainCrosshairVisible(true);
    xyplot.setRangeCrosshairVisible(true);
    xyplot.setRenderer(xydifferencerenderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    DateAxis dateaxis = new DateAxis("Time");
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);//from   w  w w .ja  v a2s  . c o m
    xyplot.setDomainAxis(dateaxis);
    xyplot.setForegroundAlpha(0.5F);
    return jfreechart;
}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart chart = ChartFactory.createXYLineChart("DeviationRenderer - Demo 3", "X", "Y", xydataset,
            PlotOrientation.VERTICAL, false, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    ////  w  ww . j a  v  a 2 s  . com
    DeviationRenderer renderer = new DeviationRenderer(false, false);
    renderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1));
    renderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1));
    renderer.setSeriesStroke(1, new BasicStroke(3F, 1, 1));
    renderer.setSeriesFillPaint(0, Color.red);
    renderer.setSeriesFillPaint(1, Color.orange);
    renderer.setSeriesFillPaint(2, Color.green);
    plot.setRenderer(renderer);
    //
    DateAxis domainAxis = new DateAxis("Date");
    domainAxis.setLowerMargin(0.0D);
    domainAxis.setUpperMargin(0.0D);
    plot.setDomainAxis(domainAxis);
    NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis();
    valueAxis.setRange(-40D, 40D);
    valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    ChartUtilities.applyCurrentTheme(chart);
    return chart;
}

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

private static JFreeChart createChart(TableXYDataset tablexydataset) {
    JFreeChart jfreechart = ChartFactory.createStackedXYAreaChart("Stacked XY Area Chart Demo 3", "X Value",
            "Y Value", tablexydataset, PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    DateAxis dateaxis = new DateAxis("Date");
    xyplot.setDomainAxis(dateaxis);/*from  w  ww. java2s .com*/
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    StackedXYAreaRenderer2 stackedxyarearenderer2 = (StackedXYAreaRenderer2) xyplot.getRenderer();
    stackedxyarearenderer2.setRoundXCoordinates(true);
    return jfreechart;
}

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

private static JFreeChart createChart(XYZDataset xyzdataset) {
    DateAxis dateaxis = new DateAxis("Date");
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);//from   w w  w  . ja  va 2s  .c o m
    dateaxis.setInverted(true);
    NumberAxis numberaxis = new NumberAxis("Hour");
    numberaxis.setUpperMargin(0.0D);
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYBlockRenderer xyblockrenderer = new XYBlockRenderer();
    xyblockrenderer.setBlockWidth(86400000D);
    xyblockrenderer.setBlockAnchor(RectangleAnchor.BOTTOM_LEFT);
    LookupPaintScale lookuppaintscale = new LookupPaintScale(0.5D, 4.5D, Color.white);
    lookuppaintscale.add(0.5D, Color.red);
    lookuppaintscale.add(1.5D, Color.green);
    lookuppaintscale.add(2.5D, Color.blue);
    lookuppaintscale.add(3.5D, Color.yellow);
    xyblockrenderer.setPaintScale(lookuppaintscale);
    XYPlot xyplot = new XYPlot(xyzdataset, dateaxis, numberaxis, xyblockrenderer);
    xyplot.setOrientation(PlotOrientation.HORIZONTAL);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    JFreeChart jfreechart = new JFreeChart("XYBlockChartDemo2", xyplot);
    jfreechart.removeLegend();
    jfreechart.setBackgroundPaint(Color.white);
    SymbolAxis symbolaxis = new SymbolAxis(null,
            new String[] { "", "Unavailable", "Free", "Group 1", "Group 2" });
    symbolaxis.setRange(0.5D, 4.5D);
    symbolaxis.setPlot(new PiePlot());
    symbolaxis.setGridBandsVisible(false);
    PaintScaleLegend paintscalelegend = new PaintScaleLegend(lookuppaintscale, symbolaxis);
    paintscalelegend.setMargin(new RectangleInsets(3D, 10D, 3D, 10D));
    paintscalelegend.setPosition(RectangleEdge.BOTTOM);
    paintscalelegend.setAxisOffset(5D);
    jfreechart.addSubtitle(paintscalelegend);
    return jfreechart;
}

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

private static JFreeChart createChart(TableXYDataset tablexydataset) {
    DateAxis dateaxis = new DateAxis("Year");
    dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    dateaxis.setLowerMargin(0.01D);
    dateaxis.setUpperMargin(0.01D);/*from www. j a va  2 s .  c  o  m*/
    NumberAxis numberaxis = new NumberAxis("Tonnes");
    numberaxis.setNumberFormatOverride(new DecimalFormat("0.0%"));
    StackedXYBarRenderer stackedxybarrenderer = new StackedXYBarRenderer(0.29999999999999999D);
    stackedxybarrenderer.setRenderAsPercentages(true);
    GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, new Color(64, 0, 0), 0.0F, 0.0F, Color.red);
    GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, new Color(0, 64, 0), 0.0F, 0.0F, Color.green);
    stackedxybarrenderer.setSeriesPaint(0, gradientpaint);
    stackedxybarrenderer.setSeriesPaint(1, gradientpaint1);
    stackedxybarrenderer.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));
    stackedxybarrenderer.setDrawBarOutline(false);
    stackedxybarrenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0} : {1} = {2} tonnes",
            new SimpleDateFormat("yyyy"), new DecimalFormat("#,##0")));
    XYPlot xyplot = new XYPlot(tablexydataset, dateaxis, numberaxis, stackedxybarrenderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    JFreeChart jfreechart = new JFreeChart("Waste Management", xyplot);
    jfreechart.setBackgroundPaint(Color.white);
    jfreechart.addSubtitle(new TextTitle("St Albans City and District Council"));
    return jfreechart;
}

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

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("XYDrawableAnnotationDemo1", null, "$ million",
            xydataset, true, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setDomainPannable(true);/*from  ww  w  .  j a v a 2 s.com*/
    xyplot.setRangePannable(true);
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setLowerMargin(0.20000000000000001D);
    dateaxis.setUpperMargin(0.20000000000000001D);
    dateaxis.setStandardTickUnits(createStandardDateTickUnits());
    NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setLowerMargin(0.20000000000000001D);
    numberaxis.setUpperMargin(0.20000000000000001D);
    XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer();
    xylineandshaperenderer.setBaseShapesVisible(true);
    xylineandshaperenderer.setBaseLinesVisible(true);
    xylineandshaperenderer.setSeriesShape(0, new java.awt.geom.Ellipse2D.Double(-5D, -5D, 10D, 10D));
    xylineandshaperenderer.setSeriesShape(1, new java.awt.geom.Ellipse2D.Double(-5D, -5D, 10D, 10D));
    xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(3F));
    xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(3F, 1, 1, 5F, new float[] { 10F, 5F }, 0.0F));
    xylineandshaperenderer.setSeriesFillPaint(0, Color.white);
    xylineandshaperenderer.setSeriesFillPaint(1, Color.white);
    xylineandshaperenderer.setUseFillPaint(true);
    xylineandshaperenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    xylineandshaperenderer.setDefaultEntityRadius(6);
    xylineandshaperenderer.addAnnotation(new XYDrawableAnnotation((new Month(4, 2005)).getFirstMillisecond(),
            600D, 180D, 100D, 3D, createPieChart()));
    xylineandshaperenderer.addAnnotation(new XYDrawableAnnotation((new Month(9, 2007)).getFirstMillisecond(),
            1250D, 120D, 100D, 2D, createBarChart()));
    xyplot.setRenderer(xylineandshaperenderer);
    return jfreechart;
}

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

private static JFreeChart createChart(IntervalXYDataset intervalxydataset) {
    JFreeChart jfreechart = ChartFactory.createXYBarChart("State Executions - USA", "Year", true,
            "Number of People", intervalxydataset, PlotOrientation.VERTICAL, true, false, false);
    jfreechart.addSubtitle(new TextTitle("Source: http://www.amnestyusa.org/abolish/listbyyear.do",
            new Font("Dialog", 2, 10)));
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    XYItemRenderer xyitemrenderer = xyplot.getRenderer();
    StandardXYToolTipGenerator standardxytooltipgenerator = new StandardXYToolTipGenerator("{1} = {2}",
            new SimpleDateFormat("yyyy"), new DecimalFormat("0"));
    xyitemrenderer.setBaseToolTipGenerator(standardxytooltipgenerator);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setRangeGridlinePaint(Color.white);
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    dateaxis.setLowerMargin(0.01D);
    dateaxis.setUpperMargin(0.01D);/*from   w  w  w  .j  av a2  s  . c  o  m*/
    return jfreechart;
}

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

private static JFreeChart createChart(IntervalXYDataset intervalxydataset) {
    JFreeChart jfreechart = ChartFactory.createXYBarChart("US Budget Deficit", "Year", true, "$ Billion",
            intervalxydataset, PlotOrientation.VERTICAL, false, false, false);
    TextTitle texttitle = new TextTitle("Source: http://www.cbo.gov/showdoc.cfm?index=1821&sequence=0#table12");
    texttitle.setFont(new Font("Dialog", 0, 8));
    texttitle.setPosition(RectangleEdge.BOTTOM);
    texttitle.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    jfreechart.addSubtitle(texttitle);//from   w ww  . j av  a  2 s.c om
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    XYItemRenderer xyitemrenderer = xyplot.getRenderer();
    StandardXYToolTipGenerator standardxytooltipgenerator = new StandardXYToolTipGenerator("{1} = {2}",
            new SimpleDateFormat("yyyy"), new DecimalFormat("0"));
    xyitemrenderer.setBaseToolTipGenerator(standardxytooltipgenerator);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setRangeGridlinePaint(Color.white);
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    dateaxis.setLowerMargin(0.01D);
    dateaxis.setUpperMargin(0.01D);
    return jfreechart;
}

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

private static JFreeChart createChart(TableXYDataset tablexydataset) {
    DateAxis dateaxis = new DateAxis("Date");
    dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    dateaxis.setLowerMargin(0.01D);
    dateaxis.setUpperMargin(0.01D);/*from  ww w  .  ja  v a2 s  .c  o  m*/
    NumberAxis numberaxis = new NumberAxis("Count");
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setUpperMargin(0.10000000000000001D);
    StackedXYBarRenderer stackedxybarrenderer = new StackedXYBarRenderer(0.14999999999999999D);
    stackedxybarrenderer.setDrawBarOutline(false);
    stackedxybarrenderer.setBaseItemLabelsVisible(true);
    stackedxybarrenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
    stackedxybarrenderer.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER));
    stackedxybarrenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0} : {1} = {2}",
            new SimpleDateFormat("yyyy"), new DecimalFormat("0")));
    XYPlot xyplot = new XYPlot(tablexydataset, dateaxis, numberaxis, stackedxybarrenderer);
    JFreeChart jfreechart = new JFreeChart("Holes-In-One / Double Eagles", xyplot);
    jfreechart.removeLegend();
    jfreechart.addSubtitle(new TextTitle("PGA Tour, 1983 to 2003"));
    TextTitle texttitle = new TextTitle(
            "http://www.golfdigest.com/majors/masters/index.ssf?/majors/masters/gw20040402albatross.html",
            new Font("Dialog", 0, 8));
    jfreechart.addSubtitle(texttitle);
    jfreechart.setTextAntiAlias(RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT);
    LegendTitle legendtitle = new LegendTitle(xyplot);
    legendtitle.setBackgroundPaint(Color.white);
    legendtitle.setFrame(new BlockBorder());
    legendtitle.setPosition(RectangleEdge.BOTTOM);
    jfreechart.addSubtitle(legendtitle);
    return jfreechart;
}