Solved

How to draw the multiple line in the linechart ?

Posted on 2009-07-06
18
3,231 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 26

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 26

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 26

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 26

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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 26

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 26

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 26

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 26

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 26

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

746 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

14 Experts available now in Live!

Get 1:1 Help Now