Limit JFreeChart TimeSeries to Business Hours

前端 未结 1 1905
终归单人心
终归单人心 2021-01-23 20:51

Rendering a chart over several days, with a dataset that has 24 hour data, but it\'s only useful during M-F, 7AM to 5PM. If I setup a time series with the code below, I get a c

相关标签:
1条回答
  • 2021-01-23 21:44

    You may be able to use a DateAxis with a custom Timeline. SegmentedTimeline, examined here, is a concrete implementation; although deprecated, it may serve as a guide. Based on this example, your notional newWorkdayTimeline() might look something like this:

    public static SegmentedTimeline newWorkdayTimeline() {
        SegmentedTimeline timeline = new SegmentedTimeline(
            SegmentedTimeline.HOUR_SEGMENT_SIZE, 10, 14);
        timeline.setStartTime(SegmentedTimeline.firstMondayAfter1900()
            + 7 * timeline.getSegmentSize());
        timeline.setBaseTimeline(SegmentedTimeline.newMondayThroughFridayTimeline());
        return timeline;
    }
    

    This example illustrates one way to mitigate any rendering artifacts you encounter.

    0 讨论(0)
提交回复
热议问题