Refine search
private BarRenderer createBarChartRenderer(NumberFormat numberFormat) { BarRenderer renderer = new BarRenderer(); ItemLabelPosition positiveItemLabelPosition = new ItemLabelPosition( ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER); renderer.setBasePositiveItemLabelPosition(positiveItemLabelPosition); ItemLabelPosition negativeItemLabelPosition = new ItemLabelPosition( ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER); renderer.setBaseNegativeItemLabelPosition(negativeItemLabelPosition); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator( StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, numberFormat)); renderer.setBaseItemLabelsVisible(true); return renderer; }
CategoryPlot categoryPlot = chart.getCategoryPlot(); BarRenderer br = (BarRenderer) categoryPlot.getRenderer(); br.setMaximumBarWidth(.35); // set maximum width to 35% of chart
chart.setAntiAlias(antiAlias); chart.setBorderVisible(borderVisible); chart.setBorderPaint(Color.lightGray); CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); String urlExpression = chartDefinition.getUrlExpression(); if(!StringUtils.isBlank(urlExpression)) { BarRenderer barRenderer = (BarRenderer)renderer; barRenderer.setDrawBarOutline(true); barRenderer.setShadowVisible(false); barRenderer.setBarPainter(new StandardBarPainter()); plot.setBackgroundPaint(transparentColor); plot.setOutlinePaint(transparentColor); CategoryAxis categoryAxis = plot.getDomainAxis(); categoryAxis.setAxisLinePaint(Color.BLACK); categoryAxis.setLabelFont(axisFont); categoryAxis.setAxisLineVisible(true);
chart.setBackgroundPaint(Color.white); final CategoryPlot plot = chart.getCategoryPlot(); 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); plot.setRangeAxis(1, axis2); final BarRenderer renderer2 = new BarRenderer(); Color color = new Color(0xC0, 0xC0, 0xC0, 128); renderer2.setSeriesPaint(0, color); plot.setRenderer(1, renderer2); return chart;
false // URLs? ); CategoryPlot plot = this.chart_.getCategoryPlot(); plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); BarRenderer renderer = new BarRenderer(); renderer.setSeriesOutlinePaint(0, Color.black); renderer.setSeriesOutlinePaint(1, Color.black); renderer.setSeriesPaint(0, Color.getHSBColor((float) 0.62, (float) 0.56, (float) 0.93)); renderer.setSeriesPaint(1, Color.getHSBColor((float) 0.1, (float) 0.79, (float) 0.89)); renderer.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator()); renderer.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator()); renderer.setItemMargin(0.0); renderer.setShadowVisible(false); renderer.setBarPainter( new StandardBarPainter() ); this.chart_.setBackgroundPaint(Color.getHSBColor((float) 0.0, (float) 0.0, (float) 0.93)); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.gray); plot.setRangeGridlinesVisible(true); final CategoryAxis axis1 = plot.getDomainAxis(); axis1.setCategoryMargin(0.25); // leave a gap of 25% between categories
chart.setBackgroundPaint(Color.white); chart.removeLegend(); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(0.8f); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.white); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); br.setBaseToolTipGenerator(new CategoryToolTipGenerator() br.setBaseItemURLGenerator(new CategoryURLGenerator() br.setItemMargin(0.0); br.setMinimumBarLength(5); br.setBase(br.findRangeBounds(dataset).getUpperBound() / 100); plot.setRenderer(br);
chart.setBackgroundPaint (parseColor (statsManager.getChartBackgroundColor ())); chart.setPadding (new RectangleInsets (10, 5, 5, 5)); chart.setBorderVisible (true); chart.setBorderPaint (parseColor ("#cccccc")); plot.setForegroundAlpha (0.7f); plot.setAxisOffset (new RectangleInsets (5.0, 5.0, 5.0, 5.0)); plot.setBackgroundPaint (Color.lightGray); plot.setDomainGridlinesVisible (false); plot.setRangeGridlinesVisible (true); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setVisible(false); domainAxis.setUpperMargin (0); domainAxis.setLowerMargin (0); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); = new StandardCategoryItemLabelGenerator("{1}", NumberFormat.getInstance(new ResourceLoader().getLocale())); renderer.setBaseItemLabelGenerator(generator); renderer.setBaseItemLabelFont(new Font("SansSerif", Font.PLAIN, 9)); renderer.setBaseItemLabelsVisible(true); renderer.setItemMargin (0); renderer.setSeriesPaint (0, Color.BLUE); BufferedImage img = chart.createBufferedImage (width, height);
public static void applyStyles(final JFreeChart chart) { final TextTitle title = chart.getTitle(); if (title != null) { title.setFont(WidgetUtils.FONT_HEADER1); for (int i = 0; i < chart.getSubtitleCount(); i++) { final Title subtitle = chart.getSubtitle(i); if (subtitle instanceof TextTitle) { ((TextTitle) subtitle).setFont(WidgetUtils.FONT_NORMAL); final int columnCount = categoryPlot.getDataset().getColumnCount(); if (columnCount > 1) { categoryPlot.setDomainGridlinesVisible(true); } else { categoryPlot.setDomainGridlinesVisible(false); categoryPlot.setDomainGridlinePaint(WidgetUtils.BG_COLOR_DARK); categoryPlot.setDomainGridlinePosition(CategoryAnchor.END); categoryPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.getRangeAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); barRenderer.setShadowPaint(WidgetUtils.BG_COLOR_BRIGHT); barRenderer.setBarPainter(new StandardBarPainter());
else chart = ChartFactory.createBarChart(null, null, null, dataset, PlotOrientation.VERTICAL, true, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setForegroundAlpha(transparency); chart.setBackgroundPaint(parseColor(M_sm.getChartBackgroundColor())); plot.getDomainAxis().setMaximumCategoryLabelLines(50); plot.getDomainAxis().setMaximumCategoryLabelWidthRatio(1.0f); plot.getDomainAxis().setTickLabelFont(new Font("SansSerif", Font.PLAIN, 8)); plot.getDomainAxis().setCategoryMargin(0.05); BarRenderer barrenderer = (BarRenderer) plot.getRenderer(); barrenderer.setDrawBarOutline(true); if(smallFontInDomainAxis && !canUseNormalFontSize(width)) barrenderer.setItemMargin(0.05); else barrenderer.setItemMargin(0.10); plot.getRangeAxis().setUpperMargin(0.2); barrenderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator() { private static final long serialVersionUID = 1L; barrenderer.setItemLabelFont(new Font("SansSerif", Font.PLAIN, 8)); barrenderer.setItemLabelsVisible(true);
plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); 0.0f, 0.0f, Color.lightGray ); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0) );
chart.setBackgroundPaint(Color.WHITE); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(new Color(221, 223, 238)); plot.setRangeGridlinePaint(Color.white); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, new Color(231, 175, 61)); renderer.setSeriesPaint(1, Color.green); renderer.setDrawBarOutline(false); renderer.setShadowVisible(false); chart.setBackgroundPaint(Color.WHITE); chart.getTitle().setPaint(Color.blue); CategoryPlot p = chart.getCategoryPlot();
public static JFreeChart doCreateSummarizerChart(CategoryDataset dataset, String yAxis, String chartTitle) { final JFreeChart chart = ChartFactory.createBarChart(chartTitle, // chart // title null, // unused yAxis, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips true // urls ); chart.setBackgroundPaint(Color.WHITE); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.BLACK); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setBaseStroke(new BasicStroke(4.0f)); renderer.setItemMargin(0); renderer.setMaximumBarWidth(0.05); return chart; }
final CategoryPlot plot = chart.getCategoryPlot(); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); BarRenderer renderer=new BarRenderer(); renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setMaximumBarWidth(0.10); ); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1);
chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0)); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions( Math.PI / 6.0));
CategoryAxis domainAxis = new CategoryAxis(); domainAxis.setTickLabelsVisible(false); domainAxis.setTickMarksVisible(false); domainAxis.setAxisLineVisible(true); domainAxis.setVisible(true); renderer = new BarRenderer3D(); else { renderer = new BarRenderer(); ((BarRenderer) renderer) .setBarPainter(new StandardBarPainter()); ((BarRenderer) renderer).setShadowVisible(false); CategoryPlot plot = new CategoryPlot(); plot.setDataset(dataset); plot.setDomainAxis(domainAxis); plot.setDomainGridlinesVisible(false); plot.setDomainCrosshairVisible(false); JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false); chart.setBorderVisible(true); image = chart.createBufferedImage(width, targMax);
CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setAxisOffset(new RectangleInsets(1.0, 1.0, 1.0, 1.0)); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setBarPainter(new StandardBarPainter()); renderer.setShadowVisible(false); renderer.setBaseItemLabelFont(ChartDefaults.defaultFont); renderer.setBaseItemLabelsVisible(false); renderer.setItemMargin(0.2); renderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER)); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setBaseItemLabelPaint(ChartDefaults.axisLabelColor); renderer.setBaseToolTipGenerator(generator); renderer.setDrawBarOutline(false); for (int j = 0; j < ChartDefaults.darkColors.length; j++) renderer.setSeriesPaint(j, ChartDefaults.darkColors[j]);
"BarChart using JFreeChart", "Student sample", "Marks sample", dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.yellow); chart.getTitle().setPaint(Color.blue); CategoryPlot plot = chart.getCategoryPlot(); BarRenderer br = (BarRenderer) plot.getRenderer(); br.setItemMargin(0); CategoryAxis domain = plot.getDomainAxis(); domain.setLowerMargin(0.25); domain.setUpperMargin(0.25);
PlotOrientation.HORIZONTAL, false, false, false); CategoryPlot plot = chart.getCategoryPlot(); plot.setOutlineVisible(false); plot.setBackgroundPaint(null); plot.setNoDataMessage("No data"); plot.setInsets(new RectangleInsets(UnitType.ABSOLUTE, 0, 20, 0, 20)); if (aMaxValue > 0) { plot.getRangeAxis().setVisible(false); plot.getDomainAxis().setVisible(false); BarRenderer renderer = new BarRenderer(); renderer.setBarPainter(new StandardBarPainter()); renderer.setShadowVisible(false); renderer.setSeriesPaint(0, Color.BLUE); chart.getCategoryPlot().setRenderer(renderer);
barRenderer = new BarRenderer(); lineRenderer = new LineAndShapeRenderer(); barRenderer.setPositiveItemLabelPosition( position1 ); lineRenderer.setPositiveItemLabelPosition( position1 ); ItemLabelPosition position2 = new ItemLabelPosition( ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER_RIGHT ); barRenderer.setNegativeItemLabelPosition( position2 ); lineRenderer.setNegativeItemLabelPosition( position2 ); } else if ( orientation == PlotOrientation.VERTICAL ) { ItemLabelPosition position1 = new ItemLabelPosition( ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER ); barRenderer.setPositiveItemLabelPosition( position1 ); lineRenderer.setPositiveItemLabelPosition( position1 ); ItemLabelPosition position2 = new ItemLabelPosition( ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER ); barRenderer.setNegativeItemLabelPosition( position2 ); lineRenderer.setNegativeItemLabelPosition( position2 ); barRenderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator() ); lineRenderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator() ); barRenderer.setBaseItemURLGenerator( new StandardCategoryURLGenerator() ); lineRenderer.setBaseItemURLGenerator( new StandardCategoryURLGenerator() ); barRenderer.setMaximumBarWidth( chartDefinition.getMaxBarWidth().doubleValue() ); CategoryPlot plot = new CategoryPlot( barsDataset, catAxis, barsAxis, barRenderer ); plot.setRenderer( 1, lineRenderer );
CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot(); boolean isShowTickLabels = barPlot.getShowTickLabels() == null ? true : barPlot.getShowTickLabels().booleanValue(); categoryPlot.getDomainAxis().setTickMarksVisible(isShowTickMarks); categoryPlot.getDomainAxis().setTickLabelsVisible(isShowTickLabels); BarRenderer categoryRenderer = (BarRenderer)categoryPlot.getRenderer(); boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels().booleanValue(); categoryRenderer.setBaseItemLabelsVisible( isShowLabels ); if(isShowLabels) categoryRenderer.setBaseItemLabelFont(JRFontUtil.getAwtFont(font, getLocale())); if(itemLabel != null) categoryRenderer.setBaseItemLabelPaint(itemLabel.getColor()); categoryRenderer.setBaseItemLabelPaint(getChart().getForecolor()); categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator()); categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator()); categoryRenderer.setBaseItemLabelPaint(getChart().getForecolor()); categoryRenderer.setShadowVisible(false);