How to draw the multiple line in the linechart ?

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 .?
rhithounAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
mrcoffee365Connect With a Mentor Commented:
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
 
mrcoffee365Commented:
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
 
rhithounAuthor Commented:
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
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
mrcoffee365Commented:
Great.  Post the code you have now, and explain where you want it to behave differently.
0
 
rhithounAuthor Commented:
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
 
mrcoffee365Commented:
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
 
rhithounAuthor Commented:
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
 
mrcoffee365Commented:
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
 
rhithounAuthor Commented:
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
 
rhithounAuthor Commented:
Please the question.
0
 
rhithounAuthor Commented:
Please the close question.
0
 
mrcoffee365Commented:
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
 
mrcoffee365Commented:
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
 
rhithounAuthor Commented:
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
 
mrcoffee365Commented:
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
 
mrcoffee365Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.