Solved

How to draw the multiple line in the linechart ?

Posted on 2009-07-06
18
3,492 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

623 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