protected CategoryAxis configureDomainAxis(CategoryPlot plot) { final CategoryAxis domainAxis = new NoOverlapCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); domainAxis.setLabelFont(CHART_FONT); domainAxis.setTickLabelFont(CHART_FONT); return domainAxis; }
private CategoryPlot createBarChartPlot(DefaultCategoryDataset dataset, String yAxisLabel, NumberFormat yAxisNumberFormat) { CategoryAxis xAxis = new CategoryAxis("Data"); xAxis.setCategoryMargin(0.40); NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setNumberFormatOverride(yAxisNumberFormat); BarRenderer renderer = createBarChartRenderer(yAxisNumberFormat); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); return plot; }
domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0);
domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0);
{ CategoryMarker marker = new CategoryMarker("Category 2"); marker.setLabel("Band X"); marker.setLabelAnchor(RectangleAnchor.TOP); marker.setLabelTextAnchor(TextAnchor.TOP_CENTER); marker.setLabelOffsetType(LengthAdjustmentType.CONTRACT); plot.addDomainMarker(marker, Layer.BACKGROUND); } { CategoryMarker marker = new CategoryMarker("Category 3"); plot.addDomainMarker(marker, Layer.BACKGROUND); } renderer.setItemMargin(0.0); CategoryAxis axis = plot.getDomainAxis(); axis.setCategoryMargin(0); }
CategoryPlot p = chart.getCategoryPlot(); CategoryAxis axis = p.getDomainAxis(); axis.setLowerMargin(0.1); axis.setUpperMargin(0.1); axis.setCategoryMargin(0.1); BarRenderer renderer = (BarRenderer) p.getRenderer(); renderer.setItemMargin(0.1);
protected CategoryAxis configureDomainAxis(CategoryPlot plot) { final CategoryAxis domainAxis = new NoOverlapCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); domainAxis.setLabelFont(CHART_FONT); domainAxis.setTickLabelFont(CHART_FONT); return domainAxis; }
public static void customizeCategoryAxis(CategoryAxis axis, ChartParams params, String prefix) { customizeAxis(axis, params, prefix); if (params.get(prefix + ChartParams.CATEGORY_AXIS_CATEGORY_MARGIN_SUFFIX) != null) { axis.setCategoryMargin(params.getDouble(prefix + ChartParams.CATEGORY_AXIS_CATEGORY_MARGIN_SUFFIX) .doubleValue()); } if (params.get(prefix + ChartParams.CATEGORY_AXIS_LABEL_POSITIONS_SUFFIX) != null) { axis.setCategoryLabelPositions(params.getCategoryLabelPositions(prefix + ChartParams.CATEGORY_AXIS_LABEL_POSITIONS_SUFFIX)); } if (params.get(prefix + ChartParams.CATEGORY_AXIS_LABEL_POSITION_OFFSET_SUFFIX) != null) { axis.setCategoryLabelPositionOffset(params.getInteger( prefix + ChartParams.CATEGORY_AXIS_LABEL_POSITION_OFFSET_SUFFIX).intValue()); } if (params.get(prefix + ChartParams.CATEGORY_AXIS_MAXIMUM_LABEL_LINES_SUFFIX) != null) { axis.setMaximumCategoryLabelLines(params.getInteger( prefix + ChartParams.CATEGORY_AXIS_MAXIMUM_LABEL_LINES_SUFFIX).intValue()); } if (params.get(prefix + ChartParams.CATEGORY_AXIS_MAXIMUM_LABEL_WIDTH_RATIO_SUFFIX) != null) { axis.setMaximumCategoryLabelWidthRatio(params.getFloat( prefix + ChartParams.CATEGORY_AXIS_MAXIMUM_LABEL_WIDTH_RATIO_SUFFIX).floatValue()); } }
/** * Creates a stacked area graph from the specified data set. * * @param dataset * the values to display * @return the created graph */ public JFreeChart createAreaChart(final CategoryDataset dataset) { JFreeChart chart = ChartFactory.createStackedAreaChart( null, // chart title null, // unused "count", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); setCategoryPlotProperties(chart.getCategoryPlot()); chart.getCategoryPlot().getDomainAxis().setCategoryMargin(0.0); return chart; }
/** * Creates a stacked area graph from the specified data set. * * @param dataset * the values to display * @param yAxisLabel * label of the range axis, i.e. y axis * @return the created graph */ public JFreeChart createAreaChart(final CategoryDataset dataset, final String yAxisLabel) { JFreeChart chart = ChartFactory.createStackedAreaChart( null, // chart title null, // unused yAxisLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); setCategoryPlotProperties(chart.getCategoryPlot()); chart.getCategoryPlot().getDomainAxis().setCategoryMargin(0.0); return chart; }
public static JFreeChart createStatisticalBarChart(CategoryDataset dataset) { final CategoryAxis xAxis = new CategoryAxis("Type"); xAxis.setLowerMargin(0.01d); // percentage of space before first bar xAxis.setUpperMargin(0.01d); // percentage of space after last bar xAxis.setCategoryMargin(0.3d); // percentage of space between // categories xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); final LogarithmicAxis yAxis = new LogarithmicAxis("Time (s)");//new NumberAxis("Value"); yAxis.setAutoRange(true); //yAxis.setAutoRangeMinimumSize(/size); yAxis.setLowerBound(0.0001); yAxis.setMinorTickMarksVisible(true); yAxis.setAutoRangeIncludesZero(false); yAxis.setStrictValuesFlag(false); // define the plot final CategoryItemRenderer renderer = new StatisticalBarRenderer(); final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); final JFreeChart chart = new JFreeChart("Performance Comparison", new Font("Helvetica", Font.BOLD, 14), plot, true); return chart; }
/** * Creates a new BarChart with the specified category-labels. * * @param title * @param xAxisLabel * @param yAxisLabel * @param categories */ public StackedBarChart(final String title, final String xAxisLabel, final String yAxisLabel, final String[] categories) { super(title, xAxisLabel, yAxisLabel); this.dataset = new DefaultCategoryDataset(); this.chart = createChart(title, xAxisLabel, yAxisLabel, this.dataset); this.plot = this.chart.getCategoryPlot(); this.categories = categories.clone(); addDefaultFormatting(); // leave a gap of 20% between categories (groups of bars) final CategoryAxis axis1 = this.plot.getDomainAxis(); axis1.setCategoryMargin(0.20); // leave a gap of 10% between individual bars within one category BarRenderer renderer = (BarRenderer)this.plot.getRenderer(); renderer.setItemMargin(0.10); }
public static JFreeChart createStackedBarChart(String title, List<List<Double>> bars, List<String> zoneLabels, String xLabel, String yLabel, ColorTheme theme) { DefaultCategoryDataset ds = new DefaultCategoryDataset(); Integer barId = 0; int maxStack = 0; for (List<Double> bar : bars) { int i = 0; maxStack = Math.max(maxStack, bar.size()); for (double value : bar) { ds.addValue(value, zoneLabels.get(i), barId); i++; } barId++; } JFreeChart chart = ChartFactory.createStackedBarChart(title, xLabel, yLabel, ds, PlotOrientation.VERTICAL, true, false, false); formatColorTheme(chart, theme); formatBars(chart); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.getDomainAxis().setCategoryMargin(0); plot.getDomainAxis().setLowerMargin(0); plot.getDomainAxis().setUpperMargin(0); Color[] colors = generateJetSpectrum(maxStack); for (int i = 0; i < maxStack; i++) { plot.getRenderer().setSeriesPaint(i, colors[i]); plot.getRenderer().setSeriesOutlinePaint(i, Color.white); } return chart; }
/** * Creates a new BarChart with the specified category-labels. * * @param title * @param xAxisLabel * @param yAxisLabel * @param categories */ public BarChart(final String title, final String xAxisLabel, final String yAxisLabel, final String[] categories) { super(title, xAxisLabel, yAxisLabel); this.dataset = new DefaultCategoryDataset(); this.chart = createChart(title, xAxisLabel, yAxisLabel, this.dataset); this.plot = this.chart.getCategoryPlot(); this.categories = categories.clone(); addDefaultFormatting(); // leave a gap of 20% between categories (groups of bars) final CategoryAxis axis1 = this.plot.getDomainAxis(); axis1.setCategoryMargin(0.20); // leave a gap of 10% between individual bars within one category BarRenderer renderer = (BarRenderer)this.plot.getRenderer(); renderer.setItemMargin(0.10); }
@Override protected Plot getPlot(ChartParameters params) { DefaultCategoryDataset dataset = createDataset(params); CategoryAxis domainAxis = new CategoryAxis(); domainAxis.setCategoryMargin(0.0); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setNumberFormatOverride(NumberFormat.getIntegerInstance(params.getLocale())); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); AreaRenderer renderer = new AreaRenderer(); CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer); plot.setForegroundAlpha(0.5f); plot.setDomainGridlinesVisible(true); configureColors(dataset, plot, params.getValues(PARAM_COLORS, ",")); return plot; }
protected JFreeChart createGraph() { final CategoryDataset dataset = createDataSet().build(); final JFreeChart chart = ChartFactory.createLineChart( _graphTitle, // title "Build Number #", // category axis label _unit, // value axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint( Color.white ); final CategoryPlot plot = chart.getCategoryPlot(); 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 LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setBaseStroke( new BasicStroke( 3.0f ) ); ColorPalette.apply( renderer ); return chart; } }
@Override protected JFreeChart createGraph() { DefaultCategoryDataset dataset = createDataset(); JFreeChart chart = ChartFactory.createStackedBarChart(getTitle(), getXAxisTitle(), getYAxisTitle(), dataset, PlotOrientation.VERTICAL, true, true, false); final CategoryPlot plot = chart.getCategoryPlot(); int index = dataset.getRowIndex(NO_FAILURE); if (index >= 0) { plot.getRenderer().setSeriesVisibleInLegend(index, false); } CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setCategoryMargin(0); final NumberAxis rangeAxis = (NumberAxis)plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); plot.setDomainAxis(domainAxis);
domainAxis.setCategoryMargin(0.0);
domainAxis.setCategoryMargin(0.0);