Solved

Dynamic Real-Time chart with JAVA

Posted on 2006-11-24
8
1,307 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
array6 challenfge 6 65
network + 7 73
mapAB Challlenge 35 89
firstChar challenge 13 86
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…
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…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

744 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

11 Experts available now in Live!

Get 1:1 Help Now