Display days in TimeSeriesChart
Asked Answered
C

2

1

How can I display the names of the days ("Sunday, Monday....") on the time axis, instead of just the date ?

Causey answered 7/4, 2011 at 15:39 Comment(0)
L
1

You can use setDateFormatOverride(), as shown here.

Addendum:

isn't there a way to change only the top level?

ChartPanel has methods related to the zoom state. You should be able to set the date format as desired either by overriding the chartChanged() method or in response to user input, as suggested in this example.

Linnie answered 7/4, 2011 at 15:57 Comment(1)
After using setDateFormatOverride() the axis is always labeled after the SimpleDateFormat i gave it, on every zoom level ; isn´t there a way to change only the top level ? In other words, top level "EEE, dd.MM.yyyy" and further down "HH:mm".Causey
D
1

Yes:

DateAxis xAxis = (DateAxis) plot.getDomainAxis();
xAxis.setTickUnit(new DateTickUnit(
      DateTickUnit.DAY,
      1,
      new SimpleDateFormat("EEE", Locale.DE)));
Disharmonious answered 7/4, 2011 at 15:53 Comment(2)
This is a good alternative, but Locale.getDefault() might be less locale specific.Linnie
@trashgod: May may not, This strongly depends on our use case. Local.getDefault() works in a stand alone appliction, but not on a server. -- Anyway: you are correct in standalone application.Disharmonious
L
1

You can use setDateFormatOverride(), as shown here.

Addendum:

isn't there a way to change only the top level?

ChartPanel has methods related to the zoom state. You should be able to set the date format as desired either by overriding the chartChanged() method or in response to user input, as suggested in this example.

Linnie answered 7/4, 2011 at 15:57 Comment(1)
After using setDateFormatOverride() the axis is always labeled after the SimpleDateFormat i gave it, on every zoom level ; isn´t there a way to change only the top level ? In other words, top level "EEE, dd.MM.yyyy" and further down "HH:mm".Causey

© 2022 - 2024 — McMap. All rights reserved.