List of usage examples for org.jfree.chart.renderer.category StackedBarRenderer setShadowVisible
public void setShadowVisible(boolean visible)
From source file:org.fhaes.fhrecorder.view.ColorBarGraph.java
/** * Creates the chart with the data from the given data set. * /*from w ww . j a v a 2 s. c om*/ * @param dataset the data to plot. * @return the chart. */ private static JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createStackedBarChart("", "", "", dataset, PlotOrientation.VERTICAL, false, true, false); StackedBarRenderer renderer = new StackedBarRenderer(true); renderer.setShadowVisible(false); renderer.setBarPainter(new StandardBarPainter()); // Remove shine renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); CategoryPlot plot = chart.getCategoryPlot(); plot.setRenderer(renderer); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(new Color(192, 192, 192)); plot.getDomainAxis().setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.getDomainAxis().setVisible(false); plot.getRangeAxis().setVisible(false); plot.getDomainAxis().setLowerMargin(.025); plot.getDomainAxis().setUpperMargin(.025); chart.setBackgroundPaint(new Color(214, 217, 233, 30)); return chart; }
From source file:org.fhaes.fhrecorder.util.ColorBar.java
/** * Creates a chart when given a data set. * /*from www . j a va 2 s . com*/ * @param dataset to be plotted. * @return the created chart. */ private static JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createStackedBarChart("", "", "", dataset, PlotOrientation.HORIZONTAL, false, true, false); chart.setPadding(RectangleInsets.ZERO_INSETS); chart.setBorderVisible(false); StackedBarRenderer renderer = new StackedBarRenderer(); renderer.setBarPainter(new StandardBarPainter()); // Remove shine renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); renderer.setShadowVisible(false); CategoryPlot plot = chart.getCategoryPlot(); plot.setRenderer(renderer); // plot.setBackgroundAlpha(0.0f); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); plot.getRangeAxis().setVisible(false); plot.getRangeAxis().setLowerMargin(0); plot.getRangeAxis().setUpperMargin(0); plot.getDomainAxis().setVisible(false); plot.getDomainAxis().setLowerMargin(0); plot.getDomainAxis().setUpperMargin(0); return chart; }
From source file:edu.jhuapl.graphs.jfreechart.JFreeChartStackedBarGraphSource.java
@Override public JFreeChart createChart(String title, String xLabel, String yLabel, CategoryDataset dataset, boolean legend, boolean graphToolTip) { PlotOrientation orientation = getParam(PLOT_ORIENTATION, PlotOrientation.class, DEFAULT_PLOT_ORIENTATION); JFreeChart result = ChartFactory.createBarChart(title, xLabel, yLabel, dataset, orientation, legend, graphToolTip, false);// ww w. jav a 2 s. c o m StackedBarRenderer renderer = new CategoryStackedBarGraphRenderer(data); renderer.setShadowVisible(false); renderer.setBarPainter(new CategoryGraphBarPainter(data)); result.getCategoryPlot().setRenderer(renderer); return result; }
From source file:org.talend.dataprofiler.chart.util.TopChartFactory.java
/** * DOC xqliu Comment method "createStackedBarChart". * /*from ww w. j a v a2 s .c o m*/ * @param title * @param domainAxisLabel * @param rangeAxisLabel * @param dataset * @param orientation * @param legend * @param tooltips * @param urls * @return */ public static JFreeChart createStackedBarChart(String title, String domainAxisLabel, String rangeAxisLabel, CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { // ADD msjian TDQ-5112 2012-4-10: after upgrate to jfreechart-1.0.12.jar, change the default chart wallPaint ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); // TDQ-5112~ final JFreeChart chart = ChartFactory.createStackedBarChart(title, domainAxisLabel, rangeAxisLabel, dataset, orientation, legend, tooltips, urls); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setRangeGridlinesVisible(true); StackedBarRenderer sbr = (StackedBarRenderer) plot.getRenderer(); sbr.setBaseItemLabelsVisible(true); sbr.setRenderAsPercentages(true); sbr.setBaseItemLabelGenerator(new DQRuleItemLabelGenerator("{3}", NumberFormat.getIntegerInstance())); //$NON-NLS-1$ sbr.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); // ADD xqliu 2010-03-10 feature 10834 // sbr.setBaseToolTipGenerator(new DQRuleToolTipGenerator(ChartDecorator.NEW_TOOL_TIP_FORMAT_STRING, // NumberFormat // .getInstance())); // ~10834 // ADD TDQ-5251 msjian 2012-7-31: do not display the shadow sbr.setShadowVisible(false); // TDQ-5251~ NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setNumberFormatOverride(NumberFormat.getPercentInstance()); axis.setUpperMargin(0.05f); axis.setLowerMargin(0.01f); return chart; }
From source file:com.swordlord.gozer.components.fop.graph.GFopStackedBarChart.java
public GFopStackedBarChart(IGozerFrameExtension gfe, GStackedBarChart chart) { super(gfe);/* w w w .j av a2s. c om*/ DataBindingMember dbMemberRowKey = chart.getDataBindingMemberRowKey(); DataBindingMember dbMemberColKey = chart.getDataBindingMemberColKey(); DataBindingMember dbMemberValue = chart.getDataBindingMemberValue(); DataBindingManager dbManager = chart.getDataBindingManager(); DefaultCategoryDataset dcd = new DefaultCategoryDataset(); List<DataRowBase> rowTests = dbManager.getRows(dbMemberValue); for (int j = 0; j < rowTests.size(); j++) { DataRowBase row = rowTests.get(j); String strKey = row.getPropertyAsStringForce(dbMemberRowKey.getRelativePathWithField()); dcd.setValue(row.getPropertyAsInt(dbMemberValue.getRelativePathWithField()), strKey, row.getPropertyAsStringForce(dbMemberColKey.getRelativePathWithField())); } JFreeChart fc = ChartFactory.createStackedBarChart(chart.getTitle(), chart.getCategoryAxisLabel(), chart.getValueAxisLabel(), dcd, chart.getOrientation(), chart.getLegend(), false, false); // Do this in a more static way! StackedBarRenderer.setDefaultBarPainter(new StandardBarPainter()); //chart.setBackgroundPaint(Color.white); if (chart.getSubTitle() != null) { fc.addSubtitle(new TextTitle(chart.getSubTitle())); } CategoryPlot plot = fc.getCategoryPlot(); plot.setBackgroundPaint(Color.white); plot.setDrawingSupplier(chart.getDrawingSupplier()); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setVisible(chart.getCategoryAxisVisible()); ValueAxis valueAxis = plot.getRangeAxis(); valueAxis.setVisible(chart.getValueAxisVisible()); /* //CategoryItemRenderer renderer = (CategoryItemRenderer) plot.getRenderer(); for (int j = 0; j < rowKey.length; j++) { renderer.setSeriesItemLabelGenerator(j, new LabelGenerator(j, rowKey[j])); renderer.setSeriesItemLabelsVisible(j, true); } */ StackedBarRenderer renderer = new StackedBarRenderer(); for (int j = 0; j < dcd.getRowCount(); j++) { renderer.setSeriesItemLabelGenerator(j, new StandardCategoryItemLabelGenerator()); renderer.setSeriesItemLabelsVisible(j, true); } //renderer.setLegendItemLabelGenerator(new LabelGenerator()); renderer.setShadowVisible(false); plot.setRenderer(renderer); _image = new ChartImage("chart", fc, chart.getWidth(800), chart.getHeight(800)); }
From source file:com.swordlord.gozer.components.wicket.graph.GWStackedBarChartPanel.java
public GWStackedBarChartPanel(String id, IModel<?> model, GStackedBarChart child) { super(id, model); gchart = child;//from w w w. j ava 2 s .co m DataBindingMember dbMemberRowKey = child.getDataBindingMemberRowKey(); DataBindingMember dbMemberTargetId = child.getDataBindingMemberTargetId(); DataBindingMember dbMemberColKey = child.getDataBindingMemberColKey(); DataBindingMember dbMemberValue = child.getDataBindingMemberValue(); DataBindingManager dbManager = child.getDataBindingManager(); DefaultCategoryDataset dcd = new DefaultCategoryDataset(); List<DataRowBase> rows = dbManager.getRows(dbMemberValue); // if the graph has some ordering info in the format of "<field> ASCENDING,<field2> DESCENDING" if (child.hasOrdering()) { List<Ordering> ordering = child.formatOrdering(child.getOrdering()); OrderingEx.orderList(rows, ordering); } for (int j = 0; j < rows.size(); j++) { DataRowBase row = rows.get(j); String strKey = row.getPropertyAsStringForce(dbMemberRowKey.getRelativePathWithField()); dcd.setValue(row.getPropertyAsInt(dbMemberValue.getRelativePathWithField()), strKey, row.getPropertyAsStringForce(dbMemberColKey.getRelativePathWithField())); if (dbMemberTargetId != null) { _target.put(strKey, row.getPropertyAsStringForce(dbMemberTargetId.getDataBindingFieldName())); } } JFreeChart chart = ChartFactory.createStackedBarChart(child.getTitle(), child.getCategoryAxisLabel(), child.getValueAxisLabel(), dcd, child.getOrientation(), child.getLegend(), false, false); // Do this in a more static way! StackedBarRenderer.setDefaultBarPainter(new StandardBarPainter()); //chart.setBackgroundPaint(Color.white); if (child.getSubTitle() != null) { chart.addSubtitle(new TextTitle(child.getSubTitle())); } CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.white); plot.setDrawingSupplier(child.getDrawingSupplier()); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setVisible(child.getCategoryAxisVisible()); ValueAxis valueAxis = plot.getRangeAxis(); valueAxis.setVisible(child.getValueAxisVisible()); /* //CategoryItemRenderer renderer = (CategoryItemRenderer) plot.getRenderer(); for (int j = 0; j < rowKey.length; j++) { renderer.setSeriesItemLabelGenerator(j, new LabelGenerator(j, rowKey[j])); renderer.setSeriesItemLabelsVisible(j, true); } */ StackedBarRenderer renderer = new StackedBarRenderer(); for (int j = 0; j < dcd.getRowCount(); j++) { renderer.setSeriesItemLabelGenerator(j, new StandardCategoryItemLabelGenerator()); renderer.setSeriesItemLabelsVisible(j, true); } //renderer.setLegendItemLabelGenerator(new LabelGenerator()); renderer.setShadowVisible(false); plot.setRenderer(renderer); ChartImage image = new ChartImage("chart", chart, child.getWidth(800), child.getHeight(800)); String mapName = child.getCaption(); add(image); DynamicImageMap imageMap = constructImageMap(image, mapName); if (!child.isClickable()) { imageMap.setVisible(false); } else { image.add(new AttributeModifier("usemap", new Model<String>("#" + mapName))); } add(imageMap); }
From source file:de.mpg.mpdl.inge.pubman.web.statistic_charts.StatisticChartServlet.java
/** * Creates the statistic chart./*from w w w.ja va 2 s . c om*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(CategoryDataset dataset) { // create the chart JFreeChart chart = ChartFactory.createStackedBarChart(null, // chart title "", // domain axis label "", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend false, // tooltips? false // URLs? ); // set the background color for the chart chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(new Color(0xf5, 0xf5, 0xf5)); plot.setDomainGridlinePaint(Color.gray); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.gray); // set the range axis to display integers only final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLowerBound(0); // disable bar outlines... StackedBarRenderer renderer = (StackedBarRenderer) plot.getRenderer(); renderer.setBarPainter(new StandardBarPainter()); renderer.setDrawBarOutline(false); // set up gradient paints for series /* * 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.red, 0.0f, 0.0f, new Color(64, * 0, 0)); */ Color series1Color = new Color(0xfa, 0x80, 0x72); Color series2Color = new Color(0x64, 0x95, 0xed); renderer.setSeriesPaint(1, series1Color); renderer.setSeriesPaint(0, series2Color); // remove shadow renderer.setShadowVisible(false); // // Labels in bars /* * renderer.setSeriesItemLabelsVisible(0, true); renderer.setSeriesItemLabelGenerator(0, new * StandardCategoryItemLabelGenerator()); renderer.setSeriesItemLabelPaint(0, Color.white); * renderer.setSeriesItemLabelsVisible(1, true); renderer.setSeriesItemLabelGenerator(1, new * StandardCategoryItemLabelGenerator()); renderer.setSeriesItemLabelPaint(1, Color.white); */ // setCategorySummary(dataset); // rotate labels on x-axis CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); return chart; }
From source file:de.mpg.escidoc.pubman.statistic_charts.StatisticChartServlet.java
/** * Creates the statistic chart.// w w w.j av a 2 s . c o m * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(CategoryDataset dataset) { // create the chart JFreeChart chart = ChartFactory.createStackedBarChart(null, // chart title "", // domain axis label "", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend false, // tooltips? false // URLs? ); // set the background color for the chart chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(new Color(0xf5, 0xf5, 0xf5)); plot.setDomainGridlinePaint(Color.gray); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.gray); // set the range axis to display integers only final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLowerBound(0); // disable bar outlines... StackedBarRenderer renderer = (StackedBarRenderer) plot.getRenderer(); renderer.setBarPainter(new StandardBarPainter()); renderer.setDrawBarOutline(false); // set up gradient paints for series /* 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.red, 0.0f, 0.0f, new Color(64, 0, 0)); */ Color series1Color = new Color(0xfa, 0x80, 0x72); Color series2Color = new Color(0x64, 0x95, 0xed); renderer.setSeriesPaint(1, series1Color); renderer.setSeriesPaint(0, series2Color); //remove shadow renderer.setShadowVisible(false); // //Labels in bars /* renderer.setSeriesItemLabelsVisible(0, true); renderer.setSeriesItemLabelGenerator(0, new StandardCategoryItemLabelGenerator()); renderer.setSeriesItemLabelPaint(0, Color.white); renderer.setSeriesItemLabelsVisible(1, true); renderer.setSeriesItemLabelGenerator(1, new StandardCategoryItemLabelGenerator()); renderer.setSeriesItemLabelPaint(1, Color.white); */ //setCategorySummary(dataset); //rotate labels on x-axis CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); return chart; }
From source file:com.itemanalysis.jmetrik.graph.barchart.BarChartPanel.java
public void setGraph() throws IllegalArgumentException { boolean hasGroupingVariable = false; if (command.getFreeOption("groupvar").hasValue()) { hasGroupingVariable = true;/*from w w w . j av a 2s . c om*/ } String name = command.getFreeOption("variable").getString(); String xLabel = name; DefaultCategoryDataset dataset = new DefaultCategoryDataset(); String yLabel = ""; if (command.getSelectOneOption("yaxis").isValueSelected("freq")) { yLabel = "Frequency"; } else { yLabel = "Percentage"; } if (command.getSelectOneOption("layout").isValueSelected("stacked")) { chart = ChartFactory.createStackedBarChart(command.getFreeOption("title").getString(), xLabel, yLabel, dataset, chartOrientation, hasGroupingVariable, //only show legend if has grouping variable true, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); StackedBarRenderer renderer = (StackedBarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); } else if (command.getSelectOneOption("view").isValueSelected("3D")) { chart = ChartFactory.createBarChart3D(command.getFreeOption("title").getString(), xLabel, yLabel, dataset, chartOrientation, hasGroupingVariable, //only show legend if has grouping variable true, false); } else { chart = ChartFactory.createBarChart(command.getFreeOption("title").getString(), xLabel, yLabel, dataset, chartOrientation, hasGroupingVariable, //only show legend if has grouping variable true, false); } String sub = ""; if (command.getFreeOption("subtitle").getString() != null) { sub = command.getFreeOption("subtitle").getString(); } TextTitle subtitle1 = new TextTitle(sub); chart.addSubtitle(subtitle1); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setDomainGridlinesVisible(true); if (command.getSelectOneOption("layout").isValueSelected("layered")) { LayeredBarRenderer renderer = new LayeredBarRenderer(); // renderer.setDrawBarOutline(false); plot.setRenderer(renderer); plot.setRowRenderingOrder(SortOrder.DESCENDING); } chart.setPadding(new RectangleInsets(20.0, 5.0, 20.0, 5.0)); ChartPanel panel = new ChartPanel(chart); panel.getPopupMenu().addSeparator(); this.addJpgMenuItem(BarChartPanel.this, panel.getPopupMenu()); panel.setPreferredSize(new Dimension(width, height)); plot.setBackgroundPaint(Color.WHITE); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); // plot.setForegroundAlpha(0.80f); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(true); renderer.setShadowVisible(false); this.setBackground(Color.WHITE); this.add(panel); }