Solved

Dynamic Real-Time chart with JAVA

Posted on 2006-11-24
8
1,308 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
  • 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSum5 challenge 5 68
topping2 challenge 13 80
ArrayIndexOutOfBoundException 9 66
maven project error 5 48
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
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 …

914 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

18 Experts available now in Live!

Get 1:1 Help Now