1

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

Community
  • 1
  • 1
krisaxena
  • 13
  • 3

2 Answers2

1

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().

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
0

You can override the format by calling setDateFormatOverride() on the plot's axis.

In your case it would look something like this.

DateAxis axis = (DateAxis) plot.getDomainAxis();
axis.setDateFormatOverride(new SimpleDateFormat("DD/MM/YYYY HH:mm:SS"));

See SimpleDateFormat for see more time formats.

kaveman
  • 4,339
  • 25
  • 44
loucru1
  • 13
  • 2