Solved

Dynamic Real-Time chart with JAVA

Posted on 2006-11-24
8
1,313 Views
Last Modified: 2012-08-13
Hi,

I need to create a line chart that needs to show real-time data. So, the data is supposed to be updated in real-time basis and I need to movement of the chart to be visible everytime a new data is added. I tried JFreeChart, though it is quite easy to use and I managed to draw the chart. But, it is not real-time.

Let say I have process that loops 100 times. Each loop will take about 30 seconds to return a value. Then I plot this value to the dataset of the chart. But I couldn't see the chart moving as more values were added. It just showed blank screen until the 100th loop, then it showed all the values at one go. For JFreeChart, everytime we added new value, the entire chart is redrawn again from scratch, it is not really suitable for real-time charting.

Does anybody have a better recommendation or solution on this?


Regards,
rospcc
0
Comment
Question by:rospcc
[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
  • 3
  • 2
8 Comments
 
LVL 16

Accepted Solution

by:
suprapto45 earned 250 total points
ID: 18008682
In my opinion,

Either you reload your chart in specified time (30 seconds) using scheduler such as Quartz or using Trigger in your DB (assuming that your DB supports Trigger) to execute your Servlet or etc or another thing is to use AJAX but would be complex.

Just my thoughts

David
0
 
LVL 14

Expert Comment

by:hoomanv
ID: 18009055
> the entire chart is redrawn again from scratch
That doesn't reduce performance if you update the chart once per second
Simulating a completely real time projection will put the cpu under pressure and is not recommended at all
0
 

Author Comment

by:rospcc
ID: 18013442
Sorry, I forgot to mention that the application is just purely java and swing. There is no servlet, jsp or ajax needed. Probably it will help you guys to have a clearly picture of what I'm trying to do. I'm writing an optimisation program using genetic algorithms (GA) to solve a tsp and load distribution problem. So, everytime the GA method is called, it will return a value, what we call "Fitness Value". This value has to be displayed on a chart. The looping normally ranges from 500 to unlimited times till it returns the best solution or no more improvement. I want the chart to show the value started from loop 1 till the end.

At first, I drew the chart in a JPanel. Then, everytime GA returned the value, I updated the chart dataset. But my problem with this is the chart couldn't be seen until the last looping. It the chart can only be seen when the process ended, then I might as well just stored the fitness values in a container. When it is completed, I plot the chart with the entire container.

I'm aware that it will reduce the performance. The chart is just an extra feature. The main concern on the performance is on the GA section.


Cheers,
rospcc
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:hoomanv
ID: 18013482
What about updating the chart at regular time intervals ? Say once per second. So it would have enough time to generate the next frame.
0
 

Author Comment

by:rospcc
ID: 18024969
Updating the chart at regular time intervals? Does this mean that if I set the interval to be 1 minute and the GA function returns 3 values in 1 minute, the chart will be updated 3 values at a time? Can't we make it looks like those in stock market?

Will it work if we use the actionListener to listen for the dataset changes and update the dataset under actionPerformed?


rospcc
0
 
LVL 14

Assisted Solution

by:hoomanv
hoomanv earned 250 total points
ID: 18029865
The values may arrive all at once or they may arrive at long intervals
So its all up to you, whether the arrival rate is high or low you should make the refresh rate manageable by user
Even Its good to let the user disable the auto-refresh and he would refresh it manually whenever desired

> update the dataset under actionPerformed
This would raise the problem where a lot of changes are arriving at once and the chart gets regenerated for each new value, so it'll cease to function on high rate circumstances. Therefore its highly recommended that you don't hurriedly redraw the graph after each new value has come, because there could be incoming values that may arrive soon. Just waiting to collect more updates and output them all together is more efficient
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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

695 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