showing multiple charts together in a report

0
I want to know whether it is possible to display two or more graph details in a single chart. To be more precise, graphs which will share the x-axis but y-axis will be different for both. suppose a bar graph and a line graph have to be displayed in the same chart.

both will have the same x-axis value expression but different y-axis value expressions.
I want know whether it is possible using the features of ireport to design such a jrxml.

Will try to get an image of chart which meets my requirements and upload it asap.

I believe JFreechart API supports it. But what i want to know is whether ireport helps us in designing such a report.

Any help in this regard will be appreciated.

given below is one specific case of using multiple graphs in a single chart. If anybody has coded to achieve something like this please mail it to me.
(i hope the image has been uploaded)

size=386]
Post edited by: anupfrancis, at: 2006/07/27 12:58
anupfrancis's picture
Joined: Jul 25 2006 - 1:02pm
Last seen: 13 years 2 months ago

5 Answers:

0
Yes you can do this, what you need to do is write a customizer class for your chart. So what you have to do is build out the bar chart, then write the customizer class, in the class add in the second axis and the data for that axis, then send back the JFreeChart object and iReport will compile it fine. There is a small amount of information regarding how to hook that up in the manual.

Nate
ntobik's picture
9
Joined: Jul 25 2006 - 12:45am
Last seen: 13 years 2 months ago
0
Thanks for the info you have provided about how to resolve my issue. I already have extended the jrAbstractChartCustomizer class to achieve different coloring for the different bands in the charts. Anyways, i will try out what you have mentioned.

The real issue is that i have to provide a GUI interface as a plugin to allow the user to do this if iReport doesn't already support it.

The reason why it has to be a plugin is that i can't expect a customer to manually write a customizer class when he wants to club together some graphs.

The issue is actually more generic than the specific scenario which i had mentioned before. I had used an example of bar and line graph clubbed together in the same chart. It could be actually any two types of graph
which the user may want to put together.

I don't have the manual right now. Our company is in the process of obtaining a commercial license. So getting a manual could take sometime. So if possible send me the small information regarding how to hook that up in the manual.

Also, please do send me any code samples of how this can be achieved,
if possible.

my email id is anup.francis@gmail.com
Post edited by: anupfrancis, at: 2006/07/27 12:51
anupfrancis's picture
Joined: Jul 25 2006 - 1:02pm
Last seen: 13 years 2 months ago
0
...then write the customizer class, in the class add in the second axis and the data for that axis

hello,
the question is, after I write the customizer class, how do I get the data for the second axis. The whole report is started from the IReport and for me its the only source of data for the report. My cust. class is called from the IReport so how do I get this data for the second axis?

regards
Marcin
don_felixo's picture
Joined: Aug 2 2006 - 10:26pm
Last seen: 13 years 2 months ago
0
Hi
This is Atanu. I am very new in ireport and also in java environment. In the ireport I have designed a template .like this.
please look on attach file
[img size=150]C:\Documents and Settings\Atanu\My Documents\graph.jpeg[/img]
Now I want to plot a line graph on the basis of the each data like t1 t2 ---t5 and lcl, ucl, actual value for each row.
That I have done. Now my problem is that I have to change the color of points of t1 t2 ---t5 on the basis of Lcl and Ucl . If the value of t1 ,or t2 or ----t5 are between Ucl and Lcl the color will be blue. And if it out side of Lcl and Ucl then it will be red..
I want the following figure. Where the upper bold line is Ucl and lower bold line isLcl
[img size=150]C:\Documents and Settings\Atanu\My Documents\data.jpeg[/img]
Actually I have got a information that for that I have to write a customizer class for chart. Also I have write it .

Code:
<br />
import net.sf.jasperreports.engine.*;<br />
import net.sf.jasperreports.view.JasperViewer;<br />
import net.sf.jasperreports.engine.JREmptyDataSource;<br />
import java.util.*;<br />
import java.sql.DriverManager;<br />
import java.sql.Connection;<br />
import java.sql.SQLException;<br />
import net.sf.jasperreports.engine.JRAbstractChartCustomizer;<br />
import javax.sql.*;<br />
import org.jfree.chart.axis.CategoryAxis;<br />
import org.jfree.chart.plot.CategoryPlot;<br />
import org.jfree.chart.renderer.category.*;<br />
import org.jfree.chart.renderer.*;<br />
import org.jfree.chart.ChartRenderingInfo;<br />
import org.jfree.chart.renderer.category.BarRenderer;<br />
import org.jfree.chart.renderer.category.LevelRenderer;<br />
import org.jfree.chart.renderer.category.LayeredBarRenderer;<br />
import java.sql.DriverManager;<br />
import java.sql.SQLException;<br />
import java.sql.Connection;<br />
import java.util.HashMap;<br />
import java.util.Map;<br />
import java.lang.String;<br />
import net.sf.jasperreports.engine.JRException;<br />
import net.sf.jasperreports.engine.JasperExportManager;<br />
import net.sf.jasperreports.view.JasperViewer;<br />
import net.sf.jasperreports.engine.xml.JRXmlLoader;<br />
import net.sf.jasperreports.engine.JasperCompileManager;<br />
import net.sf.jasperreports.engine.JasperFillManager;<br />
import net.sf.jasperreports.engine.JasperPrint;<br />
import net.sf.jasperreports.engine.design.JasperDesign;<br />
import net.sf.jasperreports.engine.JasperReport;<br />
import net.sf.jasperreports.engine.JRChartDataset; <br />
import net.sf.jasperreports.engine.JRChartPlot; <br />
import org.jfree.chart.renderer.category.BarRenderer3D; <br />
import org.jfree.chart.renderer.category.LineAndShapeRenderer;<br />
import org.jfree.chart.axis.CategoryLabelPositions;<br />
<br />
<br />
import org.jfree.chart.renderer.category.LineRenderer3D;<br />
import java.awt.*;<br />
import net.sf.jasperreports.engine.JRChart;<br />
import net.sf.jasperreports.engine.JRChartCustomizer;<br />
import org.jfree.chart.JFreeChart;<br />
import net.sf.jasperreports.engine.*;<br />
import java.awt.Color;<br />
import net.sf.jasperreports.engine.JRChart;<br />
import net.sf.jasperreports.engine.JRChartCustomizer;<br />
<br />
import org.jfree.chart.JFreeChart;<br />
import org.jfree.chart.axis.CategoryAxis;<br />
import org.jfree.chart.axis.CategoryLabelPositions;<br />
import org.jfree.chart.plot.CategoryPlot;<br />
import org.jfree.chart.renderer.category.BarRenderer3D;<br />
import java.lang.Object;<br />
 <br />
<br />
<br />
public class LineChartCustomizer extends JRAbstractChartCustomizer {<br />
<br />
	public void customize(JFreeChart chart, JRChart jasperChart) {<br />
		 <br />
		LineAndShapeRenderer renderer = (LineAndShapeRenderer) chart.getCategoryPlot().getRenderer(); <br />
		<br />
 <br />
        renderer.setSeriesPaint(1, Color.green); <br />
        renderer.setSeriesPaint(4, Color.orange);        <br />
       <br />
		 chart.setTitle("Setting the title "«»); <br />
	}        <br />
	 <br />
<br />
}<br />
</td></tr></tbody></table><br />
Now this customize class ok running successfully  with creating jar files.<br />
Now I want to create a logic to  check the value of t1 t2 t3   t5 with respect to UCL and LCL. How can I fetch data from report.<br />
Or is there any other way to do this.<br />
Is there any way to pass value from iReport to customizer class ?<br />
<br />
What should I do. Please please help me. It’s urget for me.<br />
<br />
Any help would be greatly appreciated. <br />
Thanks in advance.<br />
 [file name=query-37ab101e3a539a71be9c962f72749d92.doc size=49152]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/query-37ab101e3a539a71be9c962f72749d92.doc[/file]<br />
 [file name=query-dbe8d650ab388f1df8827b2cf1b2c701.doc size=49152]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/query-dbe8d650ab388f1df8827b2cf1b2c701.doc[/file]
atanupanda's picture
Joined: Dec 21 2006 - 9:51pm
Last seen: 12 years 9 months ago
0
Hi
This is Atanu. I am very new in ireport and also in java environment. In the ireport I have designed a template .like this.
please look on attach file
[img size=150]C:\Documents and Settings\Atanu\My Documents\graph.jpeg[/img]
Now I want to plot a line graph on the basis of the each data like t1 t2 ---t5 and lcl, ucl, actual value for each row.
That I have done. Now my problem is that I have to change the color of points of t1 t2 ---t5 on the basis of Lcl and Ucl . If the value of t1 ,or t2 or ----t5 are between Ucl and Lcl the color will be blue. And if it out side of Lcl and Ucl then it will be red..
I want the following figure. Where the upper bold line is Ucl and lower bold line isLcl
[img size=150]C:\Documents and Settings\Atanu\My Documents\data.jpeg[/img]
Actually I have got a information that for that I have to write a customizer class for chart. Also I have write it .

Code:
<br />
import net.sf.jasperreports.engine.*;<br />
import net.sf.jasperreports.view.JasperViewer;<br />
import net.sf.jasperreports.engine.JREmptyDataSource;<br />
import java.util.*;<br />
import java.sql.DriverManager;<br />
import java.sql.Connection;<br />
import java.sql.SQLException;<br />
import net.sf.jasperreports.engine.JRAbstractChartCustomizer;<br />
import javax.sql.*;<br />
import org.jfree.chart.axis.CategoryAxis;<br />
import org.jfree.chart.plot.CategoryPlot;<br />
import org.jfree.chart.renderer.category.*;<br />
import org.jfree.chart.renderer.*;<br />
import org.jfree.chart.ChartRenderingInfo;<br />
import org.jfree.chart.renderer.category.BarRenderer;<br />
import org.jfree.chart.renderer.category.LevelRenderer;<br />
import org.jfree.chart.renderer.category.LayeredBarRenderer;<br />
import java.sql.DriverManager;<br />
import java.sql.SQLException;<br />
import java.sql.Connection;<br />
import java.util.HashMap;<br />
import java.util.Map;<br />
import java.lang.String;<br />
import net.sf.jasperreports.engine.JRException;<br />
import net.sf.jasperreports.engine.JasperExportManager;<br />
import net.sf.jasperreports.view.JasperViewer;<br />
import net.sf.jasperreports.engine.xml.JRXmlLoader;<br />
import net.sf.jasperreports.engine.JasperCompileManager;<br />
import net.sf.jasperreports.engine.JasperFillManager;<br />
import net.sf.jasperreports.engine.JasperPrint;<br />
import net.sf.jasperreports.engine.design.JasperDesign;<br />
import net.sf.jasperreports.engine.JasperReport;<br />
import net.sf.jasperreports.engine.JRChartDataset; <br />
import net.sf.jasperreports.engine.JRChartPlot; <br />
import org.jfree.chart.renderer.category.BarRenderer3D; <br />
import org.jfree.chart.renderer.category.LineAndShapeRenderer;<br />
import org.jfree.chart.axis.CategoryLabelPositions;<br />
<br />
<br />
import org.jfree.chart.renderer.category.LineRenderer3D;<br />
import java.awt.*;<br />
import net.sf.jasperreports.engine.JRChart;<br />
import net.sf.jasperreports.engine.JRChartCustomizer;<br />
import org.jfree.chart.JFreeChart;<br />
import net.sf.jasperreports.engine.*;<br />
import java.awt.Color;<br />
import net.sf.jasperreports.engine.JRChart;<br />
import net.sf.jasperreports.engine.JRChartCustomizer;<br />
<br />
import org.jfree.chart.JFreeChart;<br />
import org.jfree.chart.axis.CategoryAxis;<br />
import org.jfree.chart.axis.CategoryLabelPositions;<br />
import org.jfree.chart.plot.CategoryPlot;<br />
import org.jfree.chart.renderer.category.BarRenderer3D;<br />
import java.lang.Object;<br />
 <br />
<br />
<br />
public class LineChartCustomizer extends JRAbstractChartCustomizer {<br />
<br />
	public void customize(JFreeChart chart, JRChart jasperChart) {<br />
		 <br />
		LineAndShapeRenderer renderer = (LineAndShapeRenderer) chart.getCategoryPlot().getRenderer(); <br />
		<br />
 <br />
        renderer.setSeriesPaint(1, Color.green); <br />
        renderer.setSeriesPaint(4, Color.orange);        <br />
       <br />
		 chart.setTitle("Setting the title "«»); <br />
	}        <br />
	 <br />
<br />
}<br />
</td></tr></tbody></table><br />
Now this customize class ok running successfully  with creating jar files.<br />
Now I want to create a logic to  check the value of t1 t2 t3   t5 with respect to UCL and LCL. How can I fetch data from report.<br />
Or is there any other way to do this.<br />
Is there any way to pass value from iReport to customizer class ?<br />
<br />
What should I do. Please please help me. It’s urget for me.<br />
<br />
Any help would be greatly appreciated. <br />
Thanks in advance.<br />
 [file name=query-37ab101e3a539a71be9c962f72749d92.doc size=49152]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/query-37ab101e3a539a71be9c962f72749d92.doc[/file]<br />
 [file name=query-17c75ceafc23f4185621a5dfb15f6fdf.doc size=49152]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/query-17c75ceafc23f4185621a5dfb15f6fdf.doc[/file]
atanupanda's picture
Joined: Dec 21 2006 - 9:51pm
Last seen: 12 years 9 months ago
Feedback
randomness