We help IT Professionals succeed at work.

How to draw the multiple line in the linechart ?

rhithoun
rhithoun asked
on
Medium Priority
4,490 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 .?
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2007

Commented:
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

Author

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.

CERTIFIED EXPERT
Top Expert 2007

Commented:
Great.  Post the code you have now, and explain where you want it to behave differently.

Author

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
CERTIFIED EXPERT
Top Expert 2007

Commented:
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.

Author

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
CERTIFIED EXPERT
Top Expert 2007

Commented:
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.

Author

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.
CERTIFIED EXPERT
Top Expert 2007
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Please the question.

Author

Commented:
Please the close question.
CERTIFIED EXPERT
Top Expert 2007

Commented:
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.
CERTIFIED EXPERT
Top Expert 2007

Commented:
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.

Author

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 ..
CERTIFIED EXPERT
Top Expert 2007

Commented:
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.

CERTIFIED EXPERT
Top Expert 2007

Commented:
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.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.