Alex Arnon
Alex Arnon

Reputation: 113

How to discard time intervals with Time Series / XYPlots using JFreeChart?

I am building a set of chart displays, one of which is for a month display of daily trading - that is, one point of data per day (closing).

Since there is no trade during weekends and holidays, I need to discard these data points. Not only that, but data points should still appear adjacent to each other, regardless of any gaps in time. This can be seen in any such chart e.g. in the 3 month graph for Nasdaq on Yahoo Finance - see how weekends are skipped.

My question is: how should one correctly implement this in JFreeChart?

Thanks in advance!

Upvotes: 2

Views: 2515

Answers (1)

trashgod
trashgod

Reputation: 205785

In addition to omitting the excluded data points, you can apply a SegmentedTimeline to the corresponding DateAxis. For example,

axis.setTimeline(SegmentedTimeline.newMondayThroughFridayTimeline());

Although deprecated in the current version, as discussed here, the implementation may guide creation of a custom TimeLine, as noted in a comment here.

Upvotes: 3

Related Questions