简体   繁体   English

在非工作时间更改JFreeChart GanttChart-SegmentedTimeline上的范围轴

[英]Changing the range axis on JFreeChart GanttChart - SegmentedTimeline for non-working hours

I hope i will be able to get my message across in the right way and tell you what is that i am looking to achieve. 我希望我能够以正确的方式传达我的信息,并告诉你我希望实现的目标。

I am using JFreeChart GanttChart in my Swing application to display the scheduling of tasks. 我在我的Swing应用程序中使用JFreeChart GanttChart来显示任务计划。 Was able to prepare the right dataset and got the chart on the panel. 能够准备正确的数据集并在面板上得到图表。 It looks something like this. 看起来像这样。

原始甘特图

There is no problem as such with the overall functionality, but our task scheduling is done in shifts, so it doesn't take up the whole 24 hours in a day. 总体功能没有任何问题,但是我们的任务调度是轮班完成的,因此一天不会占用整个24小时。 Say for example, in our case the operating hours are only from 0800 hrs - 1600 hrs. 举例来说,在我们的情况下,工作时间仅为0800时至1600时。 My dataset conforms to this as well. 我的数据集也与此相符。 As you can see in the image, Step 7 is a task with a duration of 2 hours, starts on 1500 hrs on 22nd Jan and ends at 0900 on the next day ( 1 hour on both days because the operating hours ends at 1600 and starts at 0800 only on the next day). 如图所示,第7步是一个持续2小时的任务,从1月22日的1500小时开始,到第二天的0900结束(两天均为1小时,因为营业时间从1600开始并开始仅在第二天的0800)。

But looking at the graph, makes step 7 to be one of the longest tasks in the event, just because the graph is also considering the non-operating hours into account. 但是看一下图表,使步骤7成为事件中最长的任务之一,因为图表还考虑了非工作时间。 Is there a way to change the range axis / date axis to consider the time periods only in custom hours or trim down the non-operating hours (1600-0800 hrs in my case )?. 是否可以更改范围轴/日期轴以仅在自定义小时内考虑时间段或减少非工作时间(在我的情况下为1600-0800小时)?

Unfortunately, i don't have the JFreeChart Dev Guide to probe further. 不幸的是,我没有《 JFreeChart开发指南》进一步探讨。

Below are my snippets for generating the dataset and creating the chart 以下是用于生成数据集和创建图表的代码段

                 for (int i = 0; i < tempList.size(); i++) {

                     GanttChartPojo tempGCPojo = new GanttChartPojo();
                     tempGCPojo = tempList.get(i);
                     s1.add(new Task(tempGCPojo.getTaskStepDesc(), tempGCPojo.getEST(), tempGCPojo.getEFT()));
                     s2.add(new Task(tempGCPojo.getTaskStepDesc(), tempGCPojo.getLST(), tempGCPojo.getLFT()));


             }
         }
     }

     // Add the task series to a TaskSeriesCollection
     final TaskSeriesCollection collection = new TaskSeriesCollection();
     collection.add(s1);
     collection.add(s2);

Create Chart Code 创建图表代码

 // create the chart...
    final JFreeChart chart = ChartFactory.createGanttChart(
        "Scheduling of Task Steps : Maintenance Event "+eventKey,      // chart title
        "Task",                      // x axis label
        "Time",                      // y axis label
        dataset,                  // data
        true,                     // include legend
        true,                     // tooltips
        false                     // urls
    );


    chart.setBackgroundPaint(Color.pink);


    return chart;

}

UPDATE: After looking up on the internet extensively, i found out that i can eliminate this non-working hours using SegmentedTimeline API. 更新:在Internet上进行了广泛查找之后,我发现可以使用SegmentedTimeline API消除这些非工作时间。 Anyone who has used it before, please help me in removing the non-working hours away from the plot? 以前曾经使用过它的人,请帮助我从地块上去除非工作时间吗?

Looking at the example in XYTaskDatasetDemo1 you shold be able to do this. 查看XYTaskDatasetDemo1中的示例,您可以执行此操作。 It may be work getting a copy of the developer guide as this will give you access to the demo source code 获得开发人员指南的副本可能是工作,因为这将使您可以访问演示源代码

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM