); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); 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());
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; }
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; }
plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); plot.getDomainAxis().setCategoryMargin(0.0f); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(Math.PI /5.0) ); try{ chart.draw(g2, new Rectangle2D.Double(0, 0, width, height)); g2.dispose(); }catch(Exception ex){ex.printStackTrace();} return img;
CategoryPlot plot = chart.getCategoryPlot(); plot.getDomainAxis().setUpperMargin(0); plot.getDomainAxis().setLowerMargin(0); plot.getRangeAxis().setUpperMargin(0); plot.getRangeAxis().setLowerMargin(0); plot.getRangeAxis().setVisible(false); plot.getDomainAxis().setVisible(false); plot.setRangeGridlinesVisible(false); plot.setDomainGridlinesVisible(false); chart.getPlot().setOutlineVisible(false); chart.getPlot().setBackgroundPaint(backgroundColor); chart.setBackgroundPaint(backgroundColor); } else {
); final LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); 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(-((double) dataset.getColumnCount() / 10.0)); ValueAxis axis = new NumberAxis(); plot.setDataset(1, workspaceDataset); LineAndShapeRenderer renderer = new LineAndShapeRenderer();
chart.setBackgroundPaint(Color.white); final LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setForegroundAlpha(0.85F); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.darkGray); 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());
CategoryPlot plot = chart.getCategoryPlot(); plot.getDomainAxis().setUpperMargin(0); plot.getDomainAxis().setLowerMargin(0); plot.addRangeMarker(new ValueMarker(currentReferenceLine.getValue(), currentReferenceLine.getLineColor(), new BasicStroke(currentReferenceLine.getLineWidth()))); plot.getRangeAxis().setRange(minValue, maxValue); plot.getRangeAxis().setVisible(false); plot.getDomainAxis().setVisible(false); plot.getDomainAxis().setUpperMargin(0); plot.getDomainAxis().setLowerMargin(0); plot.getDomainAxis().setVisible(false); CategoryPlot plot = new CategoryPlot(boxPlotDataset, new CategoryAxis(), new NumberAxis(), renderer); plot.getDomainAxis().setUpperMargin(0); plot.getDomainAxis().setLowerMargin(0); plot.getDomainAxis().setVisible(false); plot.getDomainAxis().setUpperMargin(0); plot.getDomainAxis().setLowerMargin(0); plot.getDomainAxis().setVisible(false);
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)) { plot.setBackgroundPaint(transparentColor); plot.setOutlinePaint(transparentColor); CategoryAxis categoryAxis = plot.getDomainAxis(); categoryAxis.setAxisLinePaint(Color.BLACK); categoryAxis.setLabelFont(axisFont); categoryAxis.setAxisLineVisible(true); CategoryLabelPositions positions = new CategoryLabelPositions(pos, pos, pos, pos); categoryAxis.setCategoryLabelPositions(positions); categoryAxis.setMaximumCategoryLabelWidthRatio(6.0f); height = 333; } else { categoryAxis.setMaximumCategoryLabelWidthRatio(0.4f);
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())); chart.setPadding(new RectangleInsets(10,5,5,5)); chart.setBorderVisible(true); chart.setBorderPaint(parseColor("#cccccc")); plot.getDomainAxis().setMaximumCategoryLabelLines(50); plot.getDomainAxis().setMaximumCategoryLabelWidthRatio(1.0f); plot.getDomainAxis().setTickLabelFont(new Font("SansSerif", Font.PLAIN, 8)); plot.getDomainAxis().setCategoryMargin(0.05); plot.getRangeAxis().setUpperMargin(0.2); barrenderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator() { private static final long serialVersionUID = 1L;
private byte[] generateBoxAndWhiskerChart (BoxAndWhiskerCategoryDataset dataset, int width, int height) { JFreeChart chart = ChartFactory.createBoxAndWhiskerChart (null, null, null, dataset, false); // set background chart.setBackgroundPaint (parseColor (statsManager.getChartBackgroundColor ())); // set chart border chart.setPadding (new RectangleInsets (10, 5, 5, 5)); chart.setBorderVisible (true); chart.setBorderPaint (parseColor ("#cccccc")); // set anti alias chart.setAntiAlias (true); CategoryPlot plot = (CategoryPlot) chart.getPlot (); plot.setDomainGridlinePaint (Color.white); plot.setDomainGridlinesVisible (true); plot.setRangeGridlinePaint (Color.white); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis (); rangeAxis.setStandardTickUnits (NumberAxis.createIntegerTickUnits ()); CategoryAxis domainAxis = (CategoryAxis) plot.getDomainAxis (); domainAxis.setLowerMargin (0.0); domainAxis.setUpperMargin (0.0); BufferedImage img = chart.createBufferedImage (width, height); final ByteArrayOutputStream out = new ByteArrayOutputStream(); try{ ImageIO.write(img, "png", out); }catch(IOException e){ log.warn("Error occurred while generating SiteStats chart image data", e); } return out.toByteArray(); }
false // URLs? ); CategoryPlot plot = this.chart_.getCategoryPlot(); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(1, dataset1); plot.mapDatasetToRangeAxis(1, 1); plot.setRenderer(0, renderer); final CategoryAxis axis1 = new CategoryAxis("Hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); plot.setDomainAxis(axis1); final ValueAxis axis2 = new NumberAxis("Mean bias [veh/h]"); plot.setRangeAxis(1, axis2); final ValueAxis axis3 = plot.getRangeAxis(0); axis3.setRange(0.0, 100.0);
CategoryPlot plot = chart.getCategoryPlot(); plot.getRangeAxis().setRange(minValue, maxValue * 1.02); plot.getDomainAxis().setUpperMargin(0); plot.getDomainAxis().setLowerMargin(0); plot.getRangeAxis().setUpperMargin(0); plot.getRangeAxis().setLowerMargin(0); plot.setOutlineVisible(false); plot.getRangeAxis().setVisible(false); plot.getDomainAxis().setVisible(false); plot.setRangeGridlinesVisible(false); plot.setBackgroundPaint(plotBackgroundColor); chartPanel.setBackground(plotBackgroundColor); chart.setBackgroundPaint(plotBackgroundColor); } else { plot.setBackgroundPaint(new Color(bg.getRed(), bg.getGreen(), bg.getBlue())); chartPanel.setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue())); chart.setBackgroundPaint(new Color(bg.getRed(), bg.getGreen(), bg.getBlue())); this.setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue()));
CategoryAxis domainAxis = new CategoryAxis(); domainAxis.setTickLabelsVisible(false); domainAxis.setTickMarksVisible(false); domainAxis.setAxisLineVisible(true); domainAxis.setVisible(true); ValueAxis rangeAxis = new NumberAxis(); rangeAxis.setTickLabelsVisible(true); rangeAxis.setTickMarksVisible(false); rangeAxis.setAxisLineVisible(true); rangeAxis.setNegativeArrowVisible(false); rangeAxis.setPositiveArrowVisible(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);
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); categoryPlot.setDrawingSupplier(new DCDrawingSupplier()); xyPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL); xyPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); xyPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL);
NumberAxis numberAxis = new NumberAxis("count"); numberAxis.setAutoRange(true); numberAxis.setAutoRangeIncludesZero(false); CategoryAxis domainAxis = new CategoryAxis(); domainAxis.setCategoryMargin(0.0); CategoryPlot plot = new CategoryPlot(dataSet, domainAxis, numberAxis, new LineAndShapeRenderer(true, false)); plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, hasLegend); if (hasLegend) { chart.getLegend().setItemFont(LEGEND_FONT); chart.setBackgroundPaint(Color.white);
chart.setBackgroundPaint(Color.white); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(new Color(0xEE, 0xEE, 0xFF)); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(1, lineDataset); plot.mapDatasetToRangeAxis(1, 1); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); final ValueAxis axis2 = new NumberAxis("# executions"); axis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.setRangeAxis(1, axis2);
/** * 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; }
Plot plot = (Plot) jfchart.getPlot(); float alpha = (float)(((float)chart.getFgAlpha()) / 255); plot.setForegroundAlpha(alpha); jfchart.setBackgroundPaint(new Color(paneRGB[0], paneRGB[1], paneRGB[2], chart.getPaneAlpha())); jfchart.getTitle().setFont(tfont); cplot.setRangeGridlinePaint(new Color(0xc0, 0xc0, 0xc0)); final Font xtkfont = chart.getXAxisTickFont(); if (xlbfont != null) { cplot.getDomainAxis().setLabelFont(xlbfont); cplot.getDomainAxis().setTickLabelFont(xtkfont); final Font ytkfont = chart.getYAxisTickFont(); if (ylbfont != null) { cplot.getRangeAxis().setLabelFont(ylbfont); cplot.getRangeAxis().setTickLabelFont(ytkfont); final Font xtkfont = chart.getXAxisTickFont(); if (xlbfont != null) { xyplot.getDomainAxis().setLabelFont(xlbfont);