1

In my application i want to display current time in X axis of JFreechart. But it starts with 00:00:00 . But actually i want like 06:15:30PM

I am setting timebase like this,

    final DynamicTimeSeriesCollection dataset =  new DynamicTimeSeriesCollection(1, 2 * 60, new Second());
    dataset.setTimeBase(new Second(0, 0, 0, 1, 1, 2011));

And setting DomainAxis like this,

    final XYPlot plot = Chart.getXYPlot();
    ValueAxis domain = plot.getDomainAxis();
    domain.setAutoRange(true);

My output is,

enter image description here

A.Mohamed Bilal
  • 115
  • 1
  • 13
  • @trashgod, i am using the following code to genetare. but it will also start from 12:00:00 AM. Code is, **DateAxis axis = (DateAxis) Plot.getDomainAxis(); axis.setFixedAutoRange(60000); axis.setDateFormatOverride(new SimpleDateFormat("hh:mm:ss a"));** – A.Mohamed Bilal Jan 31 '14 at 05:13

1 Answers1

0
    Date date = new Date();
    Dataset.setTimeBase(new Second(date));

By using the above statements I resolved the problem.

Aniket Kulkarni
  • 12,825
  • 9
  • 67
  • 90
A.Mohamed Bilal
  • 115
  • 1
  • 13
  • hm not sure why I got wrong current time with this method though. EX: Current time : 1:33 AM -> It displays 1:49 Any solutions? – Forrest Mar 21 '17 at 15:33