Jump to content
Changes to the Jaspersoft community edition download ×

Customize chart class


samueel01

Recommended Posts

I'm trying to customize a bar chart. I have implemented a JRChartCustomizer with this snipet code:

 

 

Code:
import org.jfree.chart.JFreeChart;
import org.jfree.chart.renderer.category.BarRenderer;
import net.sf.jasperreports.engine.JRChart;
import net.sf.jasperreports.engine.JRChartCustomizer;


public class BarChartCustomizer implements JRChartCustomizer {

public void customize(JFreeChart chart, JRChart jasperChart) {

BarRenderer renderer = (BarRenderer) chart.getCategoryPlot().getRenderer();

renderer.setMaxBarWidth (0.1);

}

}

 

 

But when I execute the report the following error occurs:

 

Code:
[code]Filling report... Error filling print... net.sf.jasperreports.engine.JRRuntimeException: BarChartCustomizer at net.sf.jasperreports.engine.fill.JRFillChart.<init>(JRFillChart.java:253) at net.sf.jasperreports.engine.fill.JRFillObjectFactory.getChart(JRFillObjectFactory.java:464) at net.sf.jasperreports.engine.base.JRBaseChart.getCopy(JRBaseChart.java:430) at net.sf.jasperreports.engine.fill.JRFillElementGroup.<init>(JRFillElementGroup.java:87) at net.sf.jasperreports.engine.fill.JRFillBand.<init>(JRFillBand.java:113) at net.sf.jasperreports.engine.fill.JRFillObjectFactory.getBand(JRFillObjectFactory.java:287) at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:579) at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:93) at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:75) at net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:113) at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:83) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:428) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:344) at it.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:604) at java.lang.Thread.run(Unknown Source) Print not filled. Try to use an EmptyDataSource...!

 

By the web application, the error is the same.

 

Please everyone, what should I do???

Link to comment
Share on other sites

  • Replies 8
  • Created
  • Last Reply

Top Posters In This Topic

When occurs this error, I was using the following verions:

iReport: 0.5.1

JasperReports: 1.0.1

 

But now I updated the both to the current version:

 

iReport: 1.2.7

JasperReports: 1.2.7

 

And now the erro is the following:

 

Code:
  Filling report... 
Locale: português (Brasil)
Time zone: default
Error filling print... null
java.lang.NullPointerException at net.sf.jasperreports.charts.fill.JRFillCategoryDataset.customIncrement(JRFillCategoryDataset.java:141) at net.sf.jasperreports.engine.fill.JRFillElementDataset.increment(JRFillElementDataset.java:169) at net.sf.jasperreports.engine.fill.JRCalculator.calculateVariables(JRCalculator.java:154) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:621) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:228) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:758) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:685) at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:517) at it.businesslogic.ireport.IReportCompiler.run(IReportCompiler.java:723) at java.lang.Thread.run(Unknown Source)
Print not filled. Try to use an EmptyDataSource...!

 

Thank you teodord

Link to comment
Share on other sites

  • 2 months later...

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

size=150]C:Documents and SettingsAtanuMy Documentsgraph.jpeg

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

size=150]C:Documents and SettingsAtanuMy Documentsdata.jpeg

Actually I have got a information that for that I have to write a customizer class for chart. Also I have write it .

 

Code:

Now this customize class ok running successfully with creating jar files.

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.

Or is there any other way to do this.

Is there any way to pass value from iReport to customizer class ?

 

What should I do. Please please help me. It’s urget for me.

 

Any help would be greatly appreciated.

Thanks in advance.

[file name=query-37ab101e3a539a71be9c962f72749d92.doc size=49152]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/query-37ab101e3a539a71be9c962f72749d92.doc[/file]

[file name=query-fb338eeb5e30d8780bac5da0498daec7.doc size=49152]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/query-fb338eeb5e30d8780bac5da0498daec7.doc[/file] size=159]http://www.jasperforge.org/components/com_joomlaboard/uploaded/images/graph-12dd39873f3c8a326f1a9a691a7e8d11.JPG

Link to comment
Share on other sites

Don't lost your time with Customize class parameter on iReport, It's seems not function correctly!

 

I generated my Customize class and defined the settings on code after that I exported the graphic for image and ploted on Image area on iReport template.

 

This link will help you:

http://members.lycos.co.uk/oderin/tutorials/JavaReporting/JavaReportingTutorial.htm

 

 

And this one will help you to customize:

http://www.java2s.com/Code/Java/Chart/JFreeChartBarChartDemo1.htm

 

 

I hope I have helped you!

Link to comment
Share on other sites

Hi

Very very thanks for ur reply.

i have got a lot of information from ur reply and links.

But the things is that I have to use ireport software for jasper report.And here I am seeing that it is java programm from where charts are generating. i have to do it fetching data from database using ireport.

Actaually can you please tell me how can I get value of each coloumn for each row in customizer class. Actually I am drawing chart for each row.

I want to check value of t1 t2 t3 t4 t5 with actual value and UCL and LCL. Depending on that I will change color in customizer class and it will effect to ireport.

I am also attaching my xml file and the picture what I want.

 

If you don't understand what I am trying to do please inform me.Its urgent.

Again thank u for ur help.

thanks

 

Atanu [file name=new_dashboard.xml size=15458]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/new_dashboard.xml%5B/file] size=159]http://www.jasperforge.org/components/com_joomlaboard/uploaded/images/graph-bb81c364023c743c7ef721708f1a5952.JPG

Post edited by: atanupanda, at: 2007/02/07 08:16

Link to comment
Share on other sites

  • 2 weeks later...

Hi

 

I have a problem with adding some date values. Here below what i have tried.

 

I have created a variable 'parse' with class type java.text.SimpleDateFormat and variable expression new SimpleDateFormat("HH:mm a MMM dd, yy") .

 

Then i created a variable 'dat' with class type java.util.Date and varible expression $V{parse}.parse($F{LAST_COMPUTED}) where $F{LAST_COMPUTED} is a field value (it's a string as example '12:30 am Jan 2nd, 07').

Now i can get this string as a date type varible in $V{dat}.

 

Now i want to add/subtruct some day/month/year/week or hour/minute/second with this $V{dat} varible and want to store in another varible .

That i can't do.Please help me on that. Actually in java, using calender class(using add() and set() method) i can do it. But i want to calculate it in iReport(i am using Ver. 1.3.0).

 

Also in iReport I created another variavle 'calender'with class type java.util.Calendar and value expression Calendar.getInstance(). I know that it shows the current datetime value.. Actually i thought that using calender i can do it . But i am in vein.

If any one can't under stand my requirement please reply.

Please help me to short out this problem.

 

Thanks in advance.

Link to comment
Share on other sites

  • 5 months later...

To access the values for the report this is taken from the Wiki documents

 

A chart can have an associated customizer class to perform customizations that are not directly supported by JRXML. The customizer class should implement net.sf.jasperreports.engine.JRChartCustomizer. At fill time, the customize() method of this class will be called before the chart is rendered.

If values of report parameters, variables or fields are needed in the customization, the customizer implementation should extend
net.sf.jasperreports.engine.JRAbstractChartCustomizer to gain access to such values.

 

So try to extend the second class instead to gain access to the values.

 

Thanks,

Jamie

Link to comment
Share on other sites

Thanks for your help.

I have a new problem. I want to display some dynamic field value on top of a image. I have tried to put image and field value on same place and send the image back. but still i can't get my desired out put. Please give some idea to resolve the problem

 

 

Thanks a lot.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...