List of usage examples for org.jfree.chart.axis CategoryAxis setLowerMargin
public void setLowerMargin(double margin)
From source file:hudson.plugins.robot.graph.RobotGraph.java
/** * Creates a Robot trend graph/*from w w w .j a va 2 s . c o m*/ * @return the JFreeChart graph object */ protected JFreeChart createGraph() { final JFreeChart chart = ChartFactory.createStackedAreaChart(null, null, yLabel, categoryDataset, PlotOrientation.VERTICAL, true, true, false); final LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setForegroundAlpha(0.7f); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.darkGray); final CategoryAxis domainAxis = new ShiftedCategoryAxis(xLabel); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); plot.setDomainAxis(domainAxis); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); if (binaryData) { rangeAxis.setUpperBound(1); } else if (upperBound != 0) { rangeAxis.setUpperBound(upperBound); } else { rangeAxis.setAutoRange(true); } rangeAxis.setLowerBound(lowerBound); Font font = new Font("Dialog", Font.PLAIN, fontSize); plot.getDomainAxis().setLabelFont(font); plot.getDomainAxis().setTickLabelFont(font); plot.getRangeAxis().setLabelFont(font); plot.getRangeAxis().setTickLabelFont(font); legend.setItemFont(font); final CategoryItemRenderer renderer = plot.getRenderer(); for (int i = 0; i < colors.length; i++) { renderer.setSeriesPaint(i, colors[i]); } plot.setInsets(new RectangleInsets(15.0, 0, 0, 5.0)); return chart; }
From source file:hudson.plugins.testlink.TestLinkGraph.java
/** * Creates TestLink trend graph.// w ww . ja va 2 s. c o m * * @return the JFreeChart graph object. */ protected JFreeChart createGraph() { final JFreeChart chart = ChartFactory.createLineChart(null, null, yLabel, categoryDataset, PlotOrientation.VERTICAL, true, true, false); final LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setForegroundAlpha(0.8f); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.darkGray); final CategoryAxis domainAxis = new ShiftedCategoryAxis(xLabel); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); plot.setDomainAxis(domainAxis); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRange(true); rangeAxis.setAutoRangeMinimumSize(5); rangeAxis.setLowerBound(0); final CategoryItemRenderer renderer = plot.getRenderer(); renderer.setSeriesStroke(0, new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.CAP_BUTT, 1.0f, new float[] { 1.0f, 1.0f }, 0.0f)); renderer.setSeriesPaint(0, new Color(35, 20, 89)); renderer.setSeriesStroke(1, new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.CAP_BUTT, 1.0f, new float[] { 1.0f, 1.0f }, 0.0f)); renderer.setSeriesPaint(1, new Color(0, 145, 0)); renderer.setSeriesStroke(2, new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.CAP_BUTT, 1.0f, new float[] { 1.0f, 1.0f }, 0.0f)); renderer.setSeriesPaint(2, new Color(207, 69, 21)); renderer.setSeriesStroke(3, new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.CAP_BUTT, 1.0f, new float[] { 1.0f, 1.0f }, 0.0f)); renderer.setSeriesPaint(3, Color.orange); plot.setInsets(new RectangleInsets(5.0, 0, 0, 5.0)); return chart; }
From source file:org.javarebel.chart.generator.ChartGenerator.java
protected void configureAxis(CategoryAxis axis, DefaultAxisConfig config) { axis.setCategoryLabelPositions(config.getLabelPosition()); axis.setLabelFont(config.getLabelFont()); axis.setTickLabelFont(config.getTickLabelFont()); axis.setLowerMargin(config.getLowerMargin()); axis.setUpperMargin(config.getUpperMargin()); axis.setCategoryMargin(config.getCategoryMargin()); }
From source file:org.bench4Q.console.ui.section.E_ErrorSection.java
private JPanel printErrorPic() throws IOException { CategoryDataset dataset = getDataSet(); JFreeChart chart = ChartFactory.createBarChart3D("Error", "Error type", "Error number", dataset, PlotOrientation.VERTICAL, true, true, true); CategoryPlot plot = chart.getCategoryPlot(); org.jfree.chart.axis.CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setLowerMargin(0.1); domainAxis.setUpperMargin(0.1);/*w ww . j ava 2 s. c o m*/ domainAxis.setCategoryLabelPositionOffset(10); domainAxis.setCategoryMargin(0.2); domainAxis.setCategoryLabelPositionOffset(10); org.jfree.chart.axis.ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setUpperMargin(0.1); org.jfree.chart.renderer.category.BarRenderer3D renderer; renderer = new org.jfree.chart.renderer.category.BarRenderer3D(); renderer.setBaseOutlinePaint(Color.red); renderer.setSeriesPaint(0, new Color(0, 255, 255)); renderer.setSeriesOutlinePaint(0, Color.BLACK); renderer.setSeriesPaint(1, new Color(0, 255, 0)); renderer.setSeriesOutlinePaint(1, Color.red); renderer.setItemMargin(0.1); renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setItemLabelFont(new Font("", Font.BOLD, 12)); renderer.setItemLabelPaint(Color.black); renderer.setItemLabelsVisible(true); plot.setRenderer(renderer); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.setBackgroundPaint(Color.WHITE); return new ChartPanel(chart); }
From source file:com.thalesgroup.hudson.plugins.cppcheck.graph.CppcheckGraph.java
/** * Creates a Cppcheck trend graph//from ww w .j a va 2s . c o 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 true, // 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 LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setBaseStroke(new BasicStroke(2.0f)); applyColorPalette(renderer); // crop extra space around the graph plot.setInsets(new RectangleInsets(5.0, 0, 0, 5.0)); return chart; }
From source file:org.bench4Q.console.ui.section.S_LengthSection.java
/** * @return/*from ww w.j a va2 s. c o m*/ * @throws IOException */ public JPanel drawSessionPic() throws IOException { CategoryDataset dataset = getDataSet(); JFreeChart chart = ChartFactory.createBarChart3D("Session", "Session type", "Session number", dataset, PlotOrientation.VERTICAL, true, true, true); CategoryPlot plot = chart.getCategoryPlot(); org.jfree.chart.axis.CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setLowerMargin(0.1); domainAxis.setUpperMargin(0.1); domainAxis.setCategoryLabelPositionOffset(10); domainAxis.setCategoryMargin(0.2); org.jfree.chart.axis.ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setUpperMargin(0.1); org.jfree.chart.renderer.category.BarRenderer3D renderer; renderer = new org.jfree.chart.renderer.category.BarRenderer3D(); renderer.setBaseOutlinePaint(Color.red); renderer.setSeriesPaint(0, new Color(0, 255, 255)); renderer.setSeriesOutlinePaint(0, Color.BLACK); renderer.setSeriesPaint(1, new Color(0, 255, 0)); renderer.setSeriesOutlinePaint(1, Color.red); renderer.setItemMargin(0.1); renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setItemLabelFont(new Font("", Font.BOLD, 12)); renderer.setItemLabelPaint(Color.black); renderer.setItemLabelsVisible(true); plot.setRenderer(renderer); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.setBackgroundPaint(Color.WHITE); return new ChartPanel(chart); }
From source file:hudson.plugins.codeviation.MetricsAction.java
private JFreeChart createChart(CategoryDataset dataset, int maxVal) { final JFreeChart chart = ChartFactory.createLineChart(null, // chart title null, // unused "count", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls );/*from w w w. jav a2 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.setUpperBound(maxVal); rangeAxis.setLowerBound(0); final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setStroke(new BasicStroke(4.0f)); // crop extra space around the graph plot.setInsets(new RectangleInsets(5.0, 0, 0, 5.0)); return chart; }
From source file:org.bench4Q.console.ui.section.S_SummarizeSection.java
/** * @return/*from w w w . jav a2 s . c o m*/ * @throws IOException */ public JPanel drawSessionPic() throws IOException { CategoryDataset dataset = getDataSet(); JFreeChart chart = ChartFactory.createBarChart3D("Session", "Session type", "Session number", dataset, PlotOrientation.VERTICAL, true, true, true); CategoryPlot plot = chart.getCategoryPlot(); org.jfree.chart.axis.CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setLowerMargin(0.1); domainAxis.setUpperMargin(0.1); domainAxis.setCategoryLabelPositionOffset(10); domainAxis.setCategoryMargin(0.2); org.jfree.chart.axis.ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setUpperMargin(0.1); org.jfree.chart.renderer.category.BarRenderer3D renderer; renderer = new org.jfree.chart.renderer.category.BarRenderer3D(); renderer.setBaseOutlinePaint(Color.red); renderer.setSeriesPaint(0, new Color(0, 255, 255)); renderer.setSeriesOutlinePaint(0, Color.BLACK); renderer.setSeriesPaint(1, new Color(0, 255, 0)); renderer.setSeriesOutlinePaint(1, Color.red); renderer.setItemMargin(0.1); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setItemLabelFont(new Font("", Font.PLAIN, 12)); renderer.setItemLabelPaint(Color.black); renderer.setItemLabelsVisible(true); plot.setRenderer(renderer); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.setBackgroundPaint(Color.WHITE); return new ChartPanel(chart); }
From source file:org.ow2.clif.jenkins.ClifProjectAction.java
private JFreeChart createActionErrorGraph(ClifGraphParam params) { DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> errorsDS = new DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel>(); List<AbstractBuild> builds = new ArrayList<AbstractBuild>(getProject().getBuilds()); Collections.sort(builds);/* w w w . j av a 2 s. c o m*/ for (Run<?, ?> currentBuild : builds) { Result buildResult = currentBuild.getResult(); if (buildResult != null && buildResult.isBetterOrEqualTo(Result.SUCCESS)) { ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel(currentBuild); ClifBuildAction clifBuildAction = currentBuild.getAction(ClifBuildAction.class); if (clifBuildAction == null) { continue; } ClifReport clifReport = clifBuildAction.getReport(); if (clifReport == null) { continue; } TestPlan tp = clifReport.getTestplan(params.getTestPlan()); if (tp == null) { continue; } if (tp.getAggregatedMeasures() != null) { Measure m = tp.getAggregatedMeasure(params.getLabel()); if (m == null) { continue; } errorsDS.add(m.errorPercent() * 100, Messages.ProjectAction_Errors(), label); } } } final CategoryAxis xAxis = new CategoryAxis(Messages.ProjectAction_BuildAxis()); xAxis.setLowerMargin(0.01); xAxis.setUpperMargin(0.01); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); xAxis.setMaximumCategoryLabelLines(3); final ValueAxis errorsAxis = new NumberAxis(Messages.ProjectAction_ErrorAxis()); errorsAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); errorsAxis.setUpperMargin(0.1); final LineAndShapeRenderer errorRenderer = new LineAndShapeRenderer(); errorRenderer.setItemMargin(0.0); final CategoryPlot plot = new CategoryPlot(errorsDS.build(), xAxis, errorsAxis, errorRenderer); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(0.8f); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); JFreeChart chart = new JFreeChart(Messages.ProjectAction_PercentageOfErrors(), plot); chart.setBackgroundPaint(Color.WHITE); return chart; }
From source file:com.intel.stl.ui.common.view.ComponentFactory.java
public static JFreeChart createBarChart(String xAxisLabel, String yAxisLabel, CategoryDataset dataset) { if (dataset == null) { throw new IllegalArgumentException("No dataset."); }/*from w ww . java2 s .c om*/ JFreeChart jfreechart = ChartFactory.createBarChart(null, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot categoryplot = jfreechart.getCategoryPlot(); categoryplot.setBackgroundPaint(null); categoryplot.setOutlinePaint(null); categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); categoryplot.setRangePannable(true); categoryplot.setRangeGridlinePaint(UIConstants.INTEL_DARK_GRAY); categoryplot.getRangeAxis().setLabelFont(UIConstants.H5_FONT); categoryplot.getDomainAxis().setLabelFont(UIConstants.H5_FONT); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setBarPainter(new StandardBarPainter()); barrenderer.setBaseItemLabelsVisible(true); barrenderer.setShadowVisible(false); barrenderer.setSeriesPaint(0, UIConstants.INTEL_BLUE); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setCategoryMargin(0.02D); categoryaxis.setUpperMargin(0.01D); categoryaxis.setLowerMargin(0.01D); // categoryaxis.setAxisLineVisible(false); categoryaxis.setMaximumCategoryLabelWidthRatio(0.95F); NumberAxis axis = (NumberAxis) categoryplot.getRangeAxis(); axis.setRangeType(RangeType.POSITIVE); return jfreechart; }