njrfrens Posted March 12, 2009 Share Posted March 12, 2009 Can any one inform me how to implement grouping while implementing StackedBar Chart using Jasper Reports...Attached is the Sample Chart to be developed.It can be done in JFreeChart by using GroupedStackedBarRenderer.But I want to know how to do the same in Jasper Reports... Link to comment Share on other sites More sharing options...
yashdeep Posted March 19, 2009 Share Posted March 19, 2009 Hi njrfrens!For acheving this u have to set ur series expression for US/Asia etc and Month/Product Combination in Category Expression.This may help u....Pls let me know if u find any other sol. for this.ThanksYash Link to comment Share on other sites More sharing options...
njrfrens Posted April 3, 2009 Author Share Posted April 3, 2009 Hi Can any one please inform me if there is any solution for it...? At least please inform me whether this is feasible or not? Link to comment Share on other sites More sharing options...
yashdeep Posted April 7, 2009 Share Posted April 7, 2009 Hello!Can u tell me the setp-by-step process to acheive Grouping in stacked bar chart (using jFreeChart by "GroupedStackedBarRenderer"), if possible pls give some sample jrxml file. Thanks & Regards,Yash Post Edited by yashdeep sant at 04/07/09 13:05 Link to comment Share on other sites More sharing options...
njrfrens Posted April 7, 2009 Author Share Posted April 7, 2009 below is the code to display GroupedStacked Bar chart using JFreeChartCode:public void generateStackedChart(OutputStream out, Object data) { try { JFreeChart chart = ChartFactory.createStackedBarChart( "Alerts as % of Total Programs", "Alerts", "%", getStackedDataSet(), PlotOrientation.VERTICAL, true, // include legend false, // tooltips false); // urls GroupedStackedBarRenderer renderer = new GroupedStackedBarRenderer(); KeyToGroupMap map = new KeyToGroupMap("G1"); map.mapKeyToGroup("Facility 1(ONE)", "G1"); map.mapKeyToGroup("Facility 2(ONE)", "G1"); map.mapKeyToGroup("Facility 3(ONE)", "G1"); map.mapKeyToGroup("Facility 4(ONE)", "G1"); map.mapKeyToGroup("Facility 1(ALL)", "G2"); map.mapKeyToGroup("Facility 2(ALL)", "G2"); map.mapKeyToGroup("Facility 3(ALL)", "G2"); map.mapKeyToGroup("Facility 4(ALL)", "G2"); renderer.setSeriesToGroupMap(map); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setRenderer(renderer); BufferedImage buffImg = chart.createBufferedImage(500, // width 375, // height BufferedImage.TYPE_INT_RGB, // image type null); ImageIO.write(buffImg, "jpeg", out); } catch (IOException e) { e.printStackTrace(); }}private DefaultCategoryDataset getStackedDataSet() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); // dataset.addValue(1.0, "Row 1", "Column 1"); dataset.addValue(10.0, "Facility 1(ONE)", "Jan 2008"); dataset.addValue(50.0, "Facility 1(ONE)", "Feb 2008"); dataset.addValue(30.0, "Facility 1(ALL)", "Jan 2008"); dataset.addValue(25.0, "Facility 1(ALL)", "Feb 2008"); dataset.addValue(20.0, "Facility 2(ONE)", "Jan 2008"); dataset.addValue(30.0, "Facility 2(ONE)", "Feb 2008"); dataset.addValue(20.0, "Facility 2(ALL)", "Jan 2008"); dataset.addValue(30.0, "Facility 2(ALL)", "Feb 2008"); dataset.addValue(20.0, "Facility 3(ONE)", "Jan 2008"); dataset.addValue(30.0, "Facility 3(ONE)", "Feb 2008"); dataset.addValue(20.0, "Facility 3(ALL)", "Jan 2008"); dataset.addValue(30.0, "Facility 3(ALL)", "Feb 2008"); dataset.addValue(20.0, "Facility 4(ONE)", "Jan 2008"); dataset.addValue(30.0, "Facility 4(ONE)", "Feb 2008"); dataset.addValue(20.0, "Facility 4(ALL)", "Jan 2008"); dataset.addValue(20.0, "Facility 4(ALL)", "Feb 2008"); return dataset;} Link to comment Share on other sites More sharing options...
amitksingh Posted August 14, 2009 Share Posted August 14, 2009 Hi njrfrens,Have you been able to achieve your objective of grouping while implementing StackedBar Chart using Jasper Reports.If yes, can you please explain the solution to me.ThanksAmit Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now