List of usage examples for org.jfree.chart.renderer.category BarRenderer3D setSeriesPaint
public void setSeriesPaint(int series, Paint paint)
From source file:org.bench4Q.console.ui.section.S_SummarizeSection.java
/** * @return//from ww w . jav a 2 s . c om * @throws IOException */ public JPanel drawSessionPic() throws IOException { CategoryDataset dataset = getDataSet(); JFreeChart chart = ChartFactory.createBarChart3D("Session", "Session type", "Session number", dataset, PlotOrientation.VERTICAL, true, true, true); CategoryPlot plot = chart.getCategoryPlot(); org.jfree.chart.axis.CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setLowerMargin(0.1); domainAxis.setUpperMargin(0.1); domainAxis.setCategoryLabelPositionOffset(10); domainAxis.setCategoryMargin(0.2); org.jfree.chart.axis.ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setUpperMargin(0.1); org.jfree.chart.renderer.category.BarRenderer3D renderer; renderer = new org.jfree.chart.renderer.category.BarRenderer3D(); renderer.setBaseOutlinePaint(Color.red); renderer.setSeriesPaint(0, new Color(0, 255, 255)); renderer.setSeriesOutlinePaint(0, Color.BLACK); renderer.setSeriesPaint(1, new Color(0, 255, 0)); renderer.setSeriesOutlinePaint(1, Color.red); renderer.setItemMargin(0.1); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setItemLabelFont(new Font("", Font.PLAIN, 12)); renderer.setItemLabelPaint(Color.black); renderer.setItemLabelsVisible(true); plot.setRenderer(renderer); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.setBackgroundPaint(Color.WHITE); return new ChartPanel(chart); }
From source file:com.redhat.thermostat.byteman.chart.swing.SwingBarChart.java
private JFreeChart createChart(Collection<PlotRecord> records) { // data/*from w w w . j a v a 2 s . c o m*/ DefaultCategoryDataset ds = new DefaultCategoryDataset(); for (PlotRecord re : records) { Long label = re.getPeriodStart() + ((re.getPeriodEnd() - re.getPeriodStart()) / 2); ds.addValue(re.getValue(), re.getCategory(), label); } // chart BarRenderer3D br = new StackedBarRenderer3D(cf.rendered3dXOffset, cf.rendered3dYOffset); ZoomablePlot plot = new ZoomablePlot(zm, ds, new CategoryAxis(), new NumberAxis(), br); plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, false); ChartFactory.getChartTheme().apply(chart); // renderer br.setSeriesPaint(0, toColor(cf.seriesPaint0)); br.setSeriesPaint(1, toColor(cf.seriesPaint1)); br.setSeriesPaint(2, toColor(cf.seriesPaint2)); br.setSeriesPaint(3, toColor(cf.seriesPaint3)); br.setSeriesPaint(4, toColor(cf.seriesPaint4)); br.setSeriesPaint(5, toColor(cf.seriesPaint5)); br.setWallPaint(toColor(cf.wallPaint)); br.setBaseItemLabelsVisible(cf.baseItemLabelsVisible); br.setShadowVisible(cf.shadowVisible); br.setItemMargin(cf.itemMargin); // plot plot.setBackgroundPaint(toColor(cf.backgroundPaint)); plot.setBackgroundImageAlpha((float) cf.backgroundImageAlpha); plot.setDomainGridlinesVisible(cf.domainGridlinesVisible); plot.setRangeGridlinePaint(toColor(cf.rangeGridlinePaint)); // plot.getRangeAxis().setRange(new Range(ds.getMin(), ds.getMax() * 1.1)); plot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.getRangeAxis().setLabel(cf.rangeAxisLabel); colorAxis(plot.getRangeAxis()); colorAxis(plot.getDomainAxis()); plot.getDomainAxis().setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(Math.PI * cf.domainAxisLabelAngle)); plot.getDomainAxis().setLowerMargin(cf.domainAxisLowerMargin); plot.getDomainAxis().setUpperMargin(cf.domainAxisUpperMargin); plot.getDomainAxis().setLabel(cf.domainAxisLabel); plot.setOutlineVisible(cf.outlineVisible); return chart; }
From source file:GroupProject.OriginalChartUI.java
/** * The method to draw bar chart/*w w w . j a va 2s .c o m*/ * @param barChartData the data used in the bar chart * @param XTitle the measurement of X axis * @param YTitle the measurement of Y axis */ public void draw3DBarChart(Map<String, Float> barChartData, String XTitle, String YTitle) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); String title = XTitle + " VS " + YTitle; ArrayList<String> keyArrayList = new ArrayList<>(); ArrayList<Float> valueArrayList = new ArrayList<>(); Set set = barChartData.keySet(); int i = 1; for (Map.Entry<String, Float> data : barChartData.entrySet()) { String key = data.getKey(); Float value = data.getValue(); keyArrayList.add(key); valueArrayList.add(value); dataset.setValue(value, "1", key); } JFreeChart chart = ChartFactory.createBarChart3D(title, "", "", dataset, PlotOrientation.VERTICAL, false, false, false); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(new java.awt.Color(255, 255, 255)); plot.setRangeGridlinePaint(Color.GRAY); BarRenderer3D barRender = (BarRenderer3D) plot.getRenderer(); barRender.setSeriesPaint(0, Color.decode("#9DC3E6")); ChartPanel chartPanel = new ChartPanel(chart); chartDisplayPanel.removeAll(); chartDisplayPanel.add(chartPanel, BorderLayout.CENTER); chartDisplayPanel.validate(); }
From source file:org.hxzon.demo.jfreechart.CategoryDatasetDemo2.java
private static JFreeChart createBarChart3D(CategoryDataset dataset) { CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel); ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel); BarRenderer3D renderer = new BarRenderer3D(); if (tooltips) { renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); }/* www .ja v a 2 s . com*/ if (urls) { renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator()); } CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); plot.setOrientation(orientation); if (orientation == PlotOrientation.HORIZONTAL) { // change rendering order to ensure that bar overlapping is the // right way around plot.setRowRenderingOrder(SortOrder.DESCENDING); plot.setColumnRenderingOrder(SortOrder.DESCENDING); } plot.setForegroundAlpha(0.75f); JFreeChart chart = new JFreeChart("Bar Chart 3D Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); plot.setForegroundAlpha(0.5f); valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0)); 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); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); return chart; }
From source file:net.sf.fspdfs.chartthemes.spring.EyeCandySixtiesChartTheme.java
protected JFreeChart createBar3DChart() throws JRException { JFreeChart jfreeChart = super.createBar3DChart(); CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot(); BarRenderer3D barRenderer3D = (BarRenderer3D) categoryPlot.getRenderer(); barRenderer3D = new GradientBarRenderer3D(barRenderer3D); categoryPlot.setRenderer(barRenderer3D); barRenderer3D.setItemMargin(0);/*from w w w .j av a2s .c o m*/ barRenderer3D.setWallPaint(ChartThemesConstants.TRANSPARENT_PAINT); //categoryPlot.setOrientation(PlotOrientation.HORIZONTAL); barRenderer3D.setItemMargin(0); CategoryDataset categoryDataset = categoryPlot.getDataset(); if (categoryDataset != null) { for (int i = 0; i < categoryDataset.getRowCount(); i++) { barRenderer3D.setSeriesPaint(i, (Paint) ChartThemesConstants.EYE_CANDY_SIXTIES_GRADIENT_PAINTS.get(i)); } } return jfreeChart; }
From source file:net.sf.jasperreports.chartthemes.spring.EyeCandySixtiesChartTheme.java
@Override protected JFreeChart createBar3DChart() throws JRException { JFreeChart jfreeChart = super.createBar3DChart(); CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot(); BarRenderer3D barRenderer3D = (BarRenderer3D) categoryPlot.getRenderer(); barRenderer3D = new GradientBarRenderer3D(barRenderer3D); categoryPlot.setRenderer(barRenderer3D); barRenderer3D.setItemMargin(0);/* ww w .j a va 2s . c o m*/ barRenderer3D.setWallPaint(ChartThemesConstants.TRANSPARENT_PAINT); //categoryPlot.setOrientation(PlotOrientation.HORIZONTAL); barRenderer3D.setItemMargin(0); CategoryDataset categoryDataset = categoryPlot.getDataset(); if (categoryDataset != null) { for (int i = 0; i < categoryDataset.getRowCount(); i++) { barRenderer3D.setSeriesPaint(i, ChartThemesConstants.EYE_CANDY_SIXTIES_GRADIENT_PAINTS.get(i)); } } return jfreeChart; }