0

How to set time interval for Domain axis in TimeSeriesChart? Now i have domain axis with labels which looks something like: 22.00 23.00, 00.00, 1.00, 2.00, etc.

How can I set them like: 11 feb, 12 feb etc. I should have posibility to see all hourse only if I zoom chart.

Edit: Now I solve it with the help of SimpleDateFormat.

DateAxis dateAxis = (DateAxis) plot.getDomainAxis();
DateFormatSymbols dfs = DateFormatSymbols.getInstance(); // default locale
dateAxis.setDateFormatOverride(new SimpleDateFormat("dd-MMM-HH:mm", dfs));

Chart displayed :

enter image description here

Edit: The question is still open: Is it possible to set something like grouping by day for domain axis?

Edit: More information:) I try to get some data for last week period, but if data in database only for 1 or 2 days, chart will look like this: enter image description here

as you can see timline on domain axis store information from 00.00(actualy start time is 23.xx) till 10.00, and it's no good, because user should see day which data belongs. In this case I create TimeSeries and fill it like :

TimeSeries ts=new TimeSeries(name);
ts.addOrUpdate(new Hour(date), value);

If I fill ts like

ts.addOrUpdate(new Day(date), value);

then chart didn't show any data

enter image description here

Quistion is how to make chart group data (maybe with the help of zoom ) by days, like in the following chart?

enter image description here

Volad
  • 75
  • 13

1 Answers1

1

If you add any RegularTimePeriod to a TimeSeries, the corresponding axis will use the inferred period as a guide to formatting. A related example that uses Day may be found here.

Addendum: See also this related answer concerning DateTickUnit.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • Thank you for response. I have already try it , but in this case some charts which store info for hours was empty. for example I have 0 data item at 0.00, 1 at 7.00 and 0 again at 2.00 data added with regular time period Hour, in this case chart displayed like triangle, and this is ok... but when i Use Day RegularTimePeriod -chart empty, and domain axis contains dates 23:59:59:999 and 00:00:00:000 – Volad Feb 17 '12 at 20:50
  • Please edit your question to include an [sscce](http://sscce.org/) that exhibits the problem you describe. – trashgod Feb 17 '12 at 21:00
  • Yes I have, in this case hours is missing even if I zoom in chart. I suppose the best way is to set date format. Anyway seems like customer approve it :). But I left question unsolved – Volad Feb 18 '12 at 18:45