Search code examples
datetimetooltiptime-seriesjfreechart

How to add date in the form of DD/MM/YYYY hh:mm:ss to the X-axis of a TimeSeries graph using jfreechart?


I'm trying to make a graph showing the minimum and maximum CPU Utilization along with the time that the peaks occurred by a particular application for 30 days. The dates are easily obtained on the X-Axis, however, when I zoom in, all tooltips corresponding to the data points are given the time stamp of 12 AM of their corresponding date by default. How can I change this default time to the required time stamp?

Here's a screenshot for your reference:

image

Is there a way to add date AND time to the X-axis in the DD/MM/YYYY HH:mm:SS format?

Thanks in advance for your help!

Kriti


Solution

  • As outlined here, The StandardXYToolTipGenerator uses DateFormat.getInstance() for dates, which is something like MM-dd-yyyy HH:mm:ss in my Locale. Be sure you're adding values having the needed resolution, as shown here using new Second().