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; }
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0);
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0);
CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
/** * Handle category axis customization * - get customization parameters from parameter list and modify accordingly */ private void handleCategoryAxisCustomization(Map parameters, CategoryAxis axis) { String categoryLabelPosition = "STANDARD"; if (!StringUtils.isEmpty((String) parameters.get("categorylabelposition"))) { categoryLabelPosition = (String) parameters.get("categorylabelposition"); } if (categoryLabelPosition.equalsIgnoreCase("up45")) { axis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); } else if (categoryLabelPosition.equalsIgnoreCase("up90")) { axis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); } else if (categoryLabelPosition.equalsIgnoreCase("down45")) { axis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); } else if (categoryLabelPosition.equalsIgnoreCase("down90")) { axis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90); } }
... XYDataset dataset = createDataset(); JFreeChart chart = createChart(dataset); CategoryAxis categoryAxis = chart.getCategoryPlot().getDomainAxis(); categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); // categoryAxis.setVerticalTickLabels(true); ...
private class ChartCustomizer implements DRIChartCustomizer, Serializable { public void customize(JFreeChart chart, ReportParameters reportParameters) { CategoryAxis domainAxis = chart.getCategoryPlot().getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI/2)); } }
CategoryPlot p = chart.getCategoryPlot(); CategoryAxis axis = p.getDomainAxis(); axis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
static protected void configureLineChart(JFreeChart chart) { CategoryPlot plot = chart.getCategoryPlot(); final DrawingSupplier supplier = new DefaultDrawingSupplier( DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, // Draw a small diamond new Shape[] { new Polygon(new int[] {3, 0, -3, 0}, new int[] {0, 3, 0, -3}, 4) } ); plot.setDomainGridlinePaint(Color.black); plot.setRangeGridlinePaint(Color.black); plot.setDrawingSupplier(supplier); LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(true); renderer.setStroke(new BasicStroke(2.0f)); CategoryAxis axis = plot.getDomainAxis(); axis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90); }
@Override public void customize(JFreeChart chart, ReportParameters reportParameters) { BarRenderer renderer = (BarRenderer) chart.getCategoryPlot().getRenderer(); renderer.setShadowPaint(Color.LIGHT_GRAY); renderer.setShadowVisible(true); CategoryAxis domainAxis = chart.getCategoryPlot().getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); } }
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; }
/** * Returns a CategoryPlot. */ private CategoryPlot getCategoryPlot( CategoryDataset dataSet, CategoryItemRenderer renderer, PlotOrientation orientation, CategoryLabelPositions labelPositions ) { CategoryPlot plot = new CategoryPlot( dataSet, new CategoryAxis(), new NumberAxis(), renderer ); plot.setDatasetRenderingOrder( DatasetRenderingOrder.FORWARD ); plot.setOrientation( orientation ); CategoryAxis xAxis = plot.getDomainAxis(); xAxis.setCategoryLabelPositions( labelPositions ); return plot; }
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; }
private JFreeChart getStackedBarChart( BaseChart chart, CategoryDataset dataSet, boolean horizontal ) { JFreeChart stackedBarChart = ChartFactory.createStackedBarChart( chart.getName(), chart.getDomainAxisLabel(), chart.getRangeAxisLabel(), dataSet, PlotOrientation.VERTICAL, !chart.isHideLegend(), false, false ); setBasicConfig( stackedBarChart, chart ); CategoryPlot plot = (CategoryPlot) stackedBarChart.getPlot(); plot.setOrientation( horizontal ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL ); plot.setRenderer( getStackedBarRenderer() ); CategoryAxis xAxis = plot.getDomainAxis(); xAxis.setCategoryLabelPositions( CategoryLabelPositions.UP_45 ); return stackedBarChart; }
/** * It creates a chart for the given dataset and adds the chart to the panel. * * @param dataset The dataset that will provide the values for the chart. */ private void addChart() { JFreeChart chart = ChartFactory.createStackedBarChart3D( getTitle(), null, "Breakdown" + unitSuffix(), dataset, PlotOrientation.VERTICAL, true, true, false); CategoryAxis domainAxis = chart.getCategoryPlot().getDomainAxis(); domainAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); chart.addProgressListener(locker); CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); renderer.setToolTipGenerator(dataset); mainPanel().add(BorderLayout.CENTER, new ChartPanel(chart)); }
private JFreeChart getStackedAreaChart( BaseChart chart, CategoryDataset dataSet ) { JFreeChart stackedAreaChart = ChartFactory.createStackedAreaChart( chart.getName(), chart.getDomainAxisLabel(), chart.getRangeAxisLabel(), dataSet, PlotOrientation.VERTICAL, !chart.isHideLegend(), false, false ); setBasicConfig( stackedAreaChart, chart ); CategoryPlot plot = (CategoryPlot) stackedAreaChart.getPlot(); plot.setOrientation( PlotOrientation.VERTICAL ); plot.setRenderer( getStackedAreaRenderer() ); CategoryAxis xAxis = plot.getDomainAxis(); xAxis.setCategoryLabelPositions( CategoryLabelPositions.UP_45 ); xAxis.setLabelFont( LABEL_FONT ); return stackedAreaChart; }
/** * Sets properties common to all category graphs of this plug-in. * * @param plot * the chart to set the properties for */ protected void setCategoryPlotProperties(final CategoryPlot plot) { 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); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); setPlotProperties(plot); }
/** * Sets properties common to all category graphs of this plug-in. * * @param plot * the chart to set the properties for */ protected void setCategoryPlotProperties(final CategoryPlot plot) { 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); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); setPlotProperties(plot); }
@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; }
public ChartHelper generateChart() { boolean legend = false; boolean tooltips = false; boolean urls = false; JFreeChart chart = ChartFactory.createStackedBarChart(null, null, yLabel, dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); setStackedBarChartDefaults(chart, i18nBean); CategoryPlot plot = chart.getCategoryPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); TickUnitSource units = NumberAxis.createIntegerTickUnits(); axis.setStandardTickUnits(units); CategoryAxis catAxis = plot.getDomainAxis(); catAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); plot.getRenderer().setSeriesOutlinePaint(1, ChartDefaults.GREEN_DIFF); plot.getRenderer().setSeriesPaint(1, ChartDefaults.GREEN_DIFF); plot.getRenderer().setSeriesOutlinePaint(0, ChartDefaults.RED_DIFF); plot.getRenderer().setSeriesPaint(0, ChartDefaults.RED_DIFF); return new ChartHelper(chart); }