Solved

How to draw the multiple line in the linechart ?

Posted on 2009-07-06
18
3,268 Views
Last Modified: 2012-06-27
I need to draw multiple line into line chart using jasper reports.i am using ireport for design jasper reports and mysql as database.

Now i doubt is how to draw the multiple line in the linechart ?

 

for example:
checking usage of database.

 

mysql
oracle
sybase
postgress

 

Now in the chart show four line in the chart. How to do .?
0
Comment
Question by:rhithoun
  • 9
  • 7
18 Comments
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 24795955
We might be able to help, but it would be best if you posted the code you have now, and explain what you want to change about the Jasper report displayed from it.

You've probably read the Jasper documentation, but this is a short article on creating a multiline line chart in Jasper:
http://java.dzone.com/articles/java-reporting-%E2%80%93-part-4
0
 

Author Comment

by:rhithoun
ID: 24800080
I have list of values in my web page , if select one by one jasper reports must show the line on graph.Its dynamically generate graphs.Please help me how to generate multiple lines dynamically generate.

0
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 24801016
Great.  Post the code you have now, and explain where you want it to behave differently.
0
 

Author Comment

by:rhithoun
ID: 24801693
Thank you reply.
below attach the graph,its showing null on the legend.How to customize the legend here.

Because i have definded 10 lines expression on the jasper reports.if sql returns values its show the line and legend otherwise it won't show, that coloumn return the null values for another coloumns.

But only one color show on the legend part.

Now i need help for how to customize the legend part .
image1.png
0
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 24805464
You have the source code for this report, right?  If I can see your source code, I can help you with the problem.  Please post it, and we can help you.

It's good that you posted a picture.  It makes sense that if you have a null label on the other 8 lines that the software thinks there's only 1 label.

Is it the case that you want 10 labels in the legend, but you only have 3?  You need 10 different labels for them to show up as 10 entries in the legend.

Until we see your code, there isn't a lot more help we can give.
0
 

Author Comment

by:rhithoun
ID: 24807026
Please see the code(jrxml,java) .I need dynamically create series expression,category expression,value expression .so that we can create graph with multiple line.
jrxml.doc
0
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 24810372
I see that you're getting help from Teodor, who developed Jasper Reports, on the Jasper forum -- that's going to be a lot more help than we can give.

The code you supplied has an extremely complex query, with values we can't see.  The main problem is that you don't have data for 8 of your 10 lines, right?

I'd suggest that you create a table in your database with 10 rows and all the columns you want.  Use that to create your Jasper report until it displays the way you want it.

Then you can work through the problems with your sql query until you get the data you expect.

As I said earlier, it looks as if the problem is that you don't have any data for 8 of the 10 lines.  As a result, there's no value for the $F{option10alias} expressions you have in your Jasper Report XML definition, and therefore no value in the legend.
0
 

Author Comment

by:rhithoun
ID: 24810853
Exactly, input values come from database; we dont know how records will come from database for draw the line. We need to create dynamic series expression, category expression, value expression in jasper reports. Then only its possible.

I dont know how to create dynamic expressions on the jasper reports. So that I have defined 10 line default. I could predefined 10 line in the jasper  .

So query always return 10 columns, but which column values come to query, it will return values, other columns are null. If columns values are null then jasper wont display the line on the graph.

I known this wrong way , but I want to do , no details about that &What can I do ..

Please you tell me how handle this situation and how to create dynamic jasper expressions.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 27

Accepted Solution

by:
mrcoffee365 earned 500 total points
ID: 24814956
You should not create the jrxml file with a specification for each line of data.  You create descriptions of how to treat each line of the datasource.

I still think you should create a much simpler version of the report you want to create -- perhaps start with a text display -- to get used to how Jasper Reports work, then try something complicated.

I think you should start by reviewing the Jasper documentation:
http://jasperforge.org/website/jasperreportswebsite/trunk/tutorial.html?group_id=252

Have you seen this documentation for creating reports with Jasper and JFreechart (which is the basis for the charting in Jasper):
https://collaboration.vbi.vt.edu/download/attachments/8618455/A+Tutorial+on+Reporting+in+JAVA+using+JasperReports,+iReport+abd+JFreeChart.pdf

If you insist on creating a line in the jrxml file for each line of data you produce from your query, then you have to generate the jrxml file from your Java code and compile it.  See this documentation on how to do that:
http://www.ibm.com/developerworks/websphere/library/techarticles/0505_olivieri/0505_olivieri.html
0
 

Author Comment

by:rhithoun
ID: 24831870
Please the question.
0
 

Author Comment

by:rhithoun
ID: 24831872
Please the close question.
0
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 24832229
The answers are good and will help the next person who is using Jasper reports.  If the asker does not wish to respond to our requests for information, that does not mean it can be deleted with no points awarded.
0
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 24833435
Accept the most recent post I gave (7/09 11:50 am) as the answer.  Award points accordingly.

If the asker wants to try the techniques recommended, then we can continue working on the problem.  If not, then close it with the answer mentioned above.
0
 

Author Comment

by:rhithoun
ID: 24878584
mrcoffee365,

Thank you for continue the post .Sorry i away from my work.I am using ireport3.0.0.Now how to draw multiple line in the graph.

I hope we have option in the chartdata - > dataset have options like.

increment type,increment group,increment when expression,sub dataset.These can use to draw the multiple line.
but i am not sure...please help with technically....(techniques recommended).


Please ..
0
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 24878953
Have you tried the changes I recommended? I think since this is all new to you, you need to create a simple report, with correct jrxml.  

Create a line report, a simple jrxml file which does not have a specification for each line of data, as I recommended above.  Use test data from a database where there are multiple records from the database.

Once that works, then you can work on using more advanced techniques.

0
 
LVL 27

Expert Comment

by:mrcoffee365
ID: 24909946
rhithoun - if you would like to keep trying on this, just post your changed code.  In particular, create a simpler jrxml -- just a simple line chart -- and create a method to call it which gets a simple list of records from the db to display.  Once you have that working, if you still want more complex displays, we can work on how to generate and compile jrxml based on the data you retrieve from the db.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
split53 challenge 7 79
Basic Java Case or If-Else statement... 3 43
servlet requestdispatcher include and forward differences 1 25
couple of eclipse 5 25
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to implement Singleton Design Pattern in Java.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now