Jump to content
We've recently updated our Privacy Statement, available here ×

njrfrens

Members
  • Posts

    17
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Downloads

Posts posted by njrfrens

  1. Got it... Its quite simple... Just wrote below code in customize method of the Chart Customizer class and it worked :-)


    Code:
    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);

    Post Edited by janardan n at 04/08/09 08:31
  2. below is the code to display GroupedStacked Bar chart using JFreeChart

    Code:
    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;}
  3. I'm displaying a bar chart in my jasper report.

    In the chart, I'm customizing the tooltips with my own expression for each group.

    When I view the report in the JRViewer through IReport, I could see the tooltips properly.

     

    I'm exporting this report as an image and showing it in my webpage using JRGraphics2DExporter.

    That time, I couldn't see the tooltips.

    Below is the code I'm using for exporting the chart as image...

    Code:
    JasperPrint jasperPrint = getJasperPrint();JRGraphics2DExporter exporter = new JRGraphics2DExporter();exporter.setParameter (JRExporterParameter.JASPER_PRINT, jasperPrint);exporter.setParameter (JRGraphics2DExporterParameter.GRAPHICS_2D, pageImage.getGraphics ());				Map imagesMap = new HashMap();HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);session.setAttribute("IMAGES_MAP", imagesMap);exporter.setParameter(JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR, Boolean.FALSE);exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, FacesContext.getCurrentInstance().getExternalContext()+"/images?image=");exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(0));exporter.exportReport ();
  4. I'm generating a bar chart using Jasper Reports. I'm showing that chart as an image in the JSP file.

    There is a click button on the Jsp Page. On click of button, the data used for graph should be exported as a CSV File.

    I'm using below code to export to CSV.

    but it is not exporting the data. Just creating the file with zero bytes.

     

     

    Code:
    JasperPrint jasperPrintJRCsvExporter csvExporter = new JRCsvExporter();csvExporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);csvExporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,"xyz.csv");csvExporter.exportReport();
  5. I'm in need of a report, where I need to display a stacked bar chart along with grouping of items like in the attached image file.

    JFreeChart can do this by using GroupedStackedBarRenderer. Below is the link where it has the description

    http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/renderer/category/GroupedStackedBarRenderer.html

     

    Now, how can I achieve the same in my jrxml?

     




    Post Edited by janardan n at 03/10/09 04:25
  6. I've the requirement of displaying the charts in my web pages(using JSF).

    While looking at jasper, I found 2 approaches

    1. Using JFreeChart and displaying the generated chart as image

    2. Using jasper reports, write jrxml and convert to jasper and then to image and then display it in the web page

    Though, using JFreeChart seems to be the tailor made approach for displaying in web pages,

    I found second approach to be better because,

    a. I need not write code for customized display of charts

    b. For any change in the chart format, I can edit it's jrxml file using iReport IDE

     

    Will there be any additional advantages/disadvanages in going with approach 2 instead of one

    Requesting any suggestions/thoughts on this...

        



    Post Edited by janardan n at 03/03/09 13:03
  7. How can I export the chart output of .jasper result as an image?

    We have exporters like JRHtmlExporter,pdf,xls,xml etc. but couldn't find any exporter for image. Why is it so?

    if not image, atleast can I get the byte array of the result of .jasper? so that I'll convert the byte stream to image...

     

     

×
×
  • Create New...