List of usage examples for org.jfree.chart.axis CategoryAxis setLowerMargin
public void setLowerMargin(double margin)
From source file:org.evosuite.jenkins.plot.Plot.java
@Override protected JFreeChart createGraph() { final JFreeChart chart = ChartFactory.createLineChart(null, "Build Number #", this.yLabel, this.dataset, PlotOrientation.VERTICAL, true, true, true); chart.setBackgroundPaint(Color.WHITE); CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryAxis domainAxis = new CategoryAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0);/*w ww.ja va 2s .c om*/ domainAxis.setCategoryMargin(0.0); plot.setDomainAxis(domainAxis); plot.setBackgroundPaint(Color.WHITE); ValueAxis yAxis = plot.getRangeAxis(); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); //yAxis.setRange(0.0, 100.0); URLAndTooltipRenderer urlRenderer = new URLAndTooltipRenderer(this.project.getProject()); ColorPalette.apply(urlRenderer); plot.setRenderer(urlRenderer); return chart; }
From source file:org.jfree.chart.demo.LayeredBarChartDemo1.java
/** * Creates a chart for the specified dataset. * //ww w. jav a2s . com * @param dataset the dataset. * * @return a chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final CategoryAxis categoryAxis = new CategoryAxis("Category"); //categoryAxis.setMaxCategoryLabelWidthRatio(10.0f); final ValueAxis valueAxis = new NumberAxis("Score (%)"); final CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, new LayeredBarRenderer()); plot.setOrientation(PlotOrientation.HORIZONTAL); final JFreeChart chart = new JFreeChart("Layered Bar Chart", JFreeChart.DEFAULT_TITLE_FONT, plot, true); // set the background color for the chart... chart.setBackgroundPaint(Color.lightGray); final LayeredBarRenderer renderer = (LayeredBarRenderer) plot.getRenderer(); // we can set each series bar width individually or let the renderer manage a standard view. // the width is set in percentage, where 1.0 is the maximum (100%). renderer.setSeriesBarWidth(0, 1.0); renderer.setSeriesBarWidth(1, 0.7); renderer.setSeriesBarWidth(2, 0.4); renderer.setItemMargin(0.01); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryMargin(0.25); domainAxis.setUpperMargin(0.05); domainAxis.setLowerMargin(0.05); return chart; }
From source file:com.choicemaker.cm.modelmaker.gui.panels.StatisticsHistogramPanel.java
private void buildPanel() { final PlotOrientation orientation = PlotOrientation.VERTICAL; data = new HistoCategoryDataset(SERIES, getNumBins()); histogram = ChartFactory.createBarChart( ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.histogram.cm.accuracy"), ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.histogram.cm.matchprob"), ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.histogram.cm.numpairs"), data, orientation, true, true, true); histogram.setBackgroundPaint(getBackground()); CategoryPlot plot = (CategoryPlot) histogram.getPlot(); plot.setForegroundAlpha(0.9f);// w w w . jav a 2 s.c om // HorizontalCategoryAxis axis = (HorizontalCategoryAxis) plot.getDomainAxis(); CategoryAxis axis = plot.getDomainAxis(); axis.setLowerMargin(0.02); axis.setUpperMargin(0.02); axis.setCategoryMargin(0.2); // axis.setVerticalCategoryLabels(true); CategoryItemRenderer renderer = plot.getRenderer(); whSeriesPaint = new Paint[3]; for (int i = 0; i < whSeriesPaint.length; ++i) { // whSeriesPaint[i] = renderer.getSeriesPaint(0, i); whSeriesPaint[i] = renderer.getSeriesPaint(i); } wohSeriesPaint = new Paint[2]; wohSeriesPaint[0] = whSeriesPaint[0]; wohSeriesPaint[1] = whSeriesPaint[2]; // plot.setRangeAxis(new VerticalLogarithmicAxis()); histoPanel = new HistoChartPanel(histogram, false, false, false, true, true, parent.getModelMaker()); // histoPanel.setEnabled(false); binWidthLabel = new JLabel( ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.histogram.binwidth")); binWidthField = new JTextField(Float.toString(binWidth), 4); binWidthField.setMinimumSize(new Dimension(50, 20)); }
From source file:edu.ucla.stat.SOCR.chart.demo.StatisticalLineChartDemo2.java
/** * Creates a sample chart./*w w w.j ava 2 s .c om*/ * * @param dataset a dataset. * * @return The chart. */ protected JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createLineChart(chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation !legendPanelOn, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setUpperMargin(0.0); domainAxis.setLowerMargin(0.0); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); // customise the renderer... StatisticalLineAndShapeRenderer renderer = new StatisticalLineAndShapeRenderer(true, false); renderer.setLegendItemLabelGenerator( new SOCRCategoryCellLabelGenerator(dataset, values_storage, SERIES_COUNT, CATEGORY_COUNT)); plot.setRenderer(renderer); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:org.perfrepo.web.controller.reports.testgroup.TestGroupChartBean.java
public void drawChart(OutputStream out, Object data) throws IOException { if (data instanceof ChartData) { ChartData chartData = (ChartData) data; JFreeChart chart = ChartFactory.createBarChart(chartData.getTitle(), "Test", "%", processDataSet(chartData), PlotOrientation.HORIZONTAL, false, true, false); chart.addSubtitle(new TextTitle("Comparison", new Font("Dialog", Font.ITALIC, 10))); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); CustomRenderer renderer = new CustomRenderer(); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); renderer.setBaseItemLabelGenerator( new StandardCategoryItemLabelGenerator("{2}%", NumberFormat.getInstance())); renderer.setBaseItemLabelsVisible(true); renderer.setDrawBarOutline(false); renderer.setMaximumBarWidth(1d / (chartData.getTests().length + 4.0)); plot.setRenderer(renderer);/*from w w w . j a va 2 s . c o m*/ CategoryAxis categoryAxis = plot.getDomainAxis(); categoryAxis.setCategoryMargin(0.1); categoryAxis.setUpperMargin(0.1); categoryAxis.setLowerMargin(0.1); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setUpperMargin(0.10); BufferedImage buffImg = chart.createBufferedImage(640, chartData.getTests().length * 100 + 100); ImageIO.write(buffImg, "gif", out); } }
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 w w w.ja va2 s . c om*/ // 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:com.seniorproject.augmentedreality.test.AreaChartDemo.java
/** * Creates a chart.//from w ww . j a v a2 s . co m * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createAreaChart("Area Chart", // 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... // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setAnchor(StandardLegend.SOUTH); chart.setBackgroundPaint(Color.white); final TextTitle subtitle = new TextTitle("An area chart demonstration. We use this " + "subtitle as an example of what happens when you get a really long title or " + "subtitle."); subtitle.setFont(new Font("SansSerif", Font.PLAIN, 12)); subtitle.setPosition(RectangleEdge.TOP); // subtitle.setSpacer(new Spacer(Spacer.RELATIVE, 0.05, 0.05, 0.05, 0.05)); subtitle.setVerticalAlignment(VerticalAlignment.BOTTOM); chart.addSubtitle(subtitle); final CategoryPlot plot = chart.getCategoryPlot(); plot.setForegroundAlpha(0.5f); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.addCategoryLabelToolTip("Type 1", "The first type."); domainAxis.addCategoryLabelToolTip("Type 2", "The second type."); domainAxis.addCategoryLabelToolTip("Type 3", "The third type."); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLabelAngle(0 * Math.PI / 2.0); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:org.jfree.chart.demo.ImageMapDemo5.java
/** * Creates a chart.//from w w w .j av a 2s. co m * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createAreaChart("Area Chart", // 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... // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setAnchor(StandardLegend.SOUTH); chart.setBackgroundPaint(Color.white); final TextTitle subtitle = new TextTitle("An area chart demonstration. We use this subtitle " + " as an example of what happens when you get a really long title or subtitle."); subtitle.setFont(new Font("SansSerif", Font.PLAIN, 12)); subtitle.setPosition(RectangleEdge.TOP); // subtitle.setSpacer(new Spacer(Spacer.RELATIVE, 0.05, 0.05, 0.05, 0.05)); subtitle.setVerticalAlignment(VerticalAlignment.BOTTOM); chart.addSubtitle(subtitle); final CategoryPlot plot = chart.getCategoryPlot(); plot.setForegroundAlpha(0.5f); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLabelAngle(0 * Math.PI / 2.0); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:cheuk.licenseheaderchecker.resource.DataGraph.java
/** * Creates a trend graph/*from w ww. j ava 2 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; }
From source file:org.jenkinsci.plugins.autozoil.graph.AutozoilGraph.java
/** * Creates a Autozoil trend graph/* ww w . j av a 2 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 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)); ColorPalette.apply(renderer); // crop extra space around the graph plot.setInsets(new RectangleInsets(5.0, 0, 0, 5.0)); return chart; }