Refresh Date Axis DataTicks

A discussion forum for JFreeChart (a 2D chart library for the Java platform).

Refresh Date Axis DataTicks

Postby Merihim » Wed Apr 27, 2016 3:15 pm

I have a problem to update the DateTicks of the DateAxis correctly. I update my chart every second with timeSeries.addOrUpdate(TimePeriod, Value)Image.
The chart should act like an oscilloscope.

The last label in my picture is 14:08:00.
Now I have 2 problems.
Problem 1:
When the current time is 14:08:30 and 30 seconds later a new minute started, all labels will be updated. (14:02:00 to 14:03:00, 14:05:00 to 14:06:00 and so on)
But I don't want this. I just want a new label every 3 Minutes in this case.

Problem 2:

To avoid Problem 1 I have overriden the method refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) in the DateAxis class.
To get my wanted result, i update the Labels just every 3 Minutes, in this Case at 14:11:01 (The 1 second is just a buffer second). When i do this, the last label is 14:10:00, the second updates to 14:06:00 and so on.

This leads me to Problem 3.
Problem 3:
I thought, Problem 2 isn't really serious, because I easily can update the labels 1 minute later, in this case at 14:12:01. And now the result is exactly what I want.
But, unfortunately the behaviour isn't constant. When the difference between the labels are 5 Minutes, not 3 Minutes like in screenshot 1, the result is different.

Image

The last label now is 14:58:00. To consider Problem 2, I update my labels at 14:58:00 + 5 Minutes (TickUnit) + 1:01 additional Unit (Problem 2 ) -> 15:04:01. Now the last label is 15:04:00, the second 14:59 and so on.
How can i avoid Problem 1 - 3?
Merihim
 
Posts: 5
Joined: Tue Mar 08, 2016 5:57 pm

Return to JFreeChart

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Joshi, Majestic-12 [Bot] and 7 guests