简体   繁体   English

与Highcharts Gantt一起度过周末

[英]Skipping weekends with Highcharts Gantt

I am looking for a way to skip weekends while using date-time xAxis with Highcharts Gantt. 我正在寻找一种在Highcharts Gantt中使用日期时间xAxis时跳过周末的方法。

I have read a few posts about the 我已经阅读了一些有关

xAxis.ordinal 

option for HighStock but I am using HighCharts HighStock的选项,但我正在使用HighCharts

Also, I would need to stick to date-time because I plan on creating an interactive Gantt / planning and update a database with these interactions and I don't want to be able to Drag and Drop (or expanding) a task into a weekend. 另外,我需要坚持日期时间,因为我计划创建一个交互式甘特图/通过这些交互来计划和更新数据库,并且我不希望能够将任务拖放(或扩展)到周末。 I believe I could prevent that with the drop event (I think there is one) but then, 2/7th of my graph would be "empty". 我相信我可以通过放置事件来防止这种情况发生(我认为有一个),但是,我的图形的2/7将是“空”的。 在此处输入图片说明

If anyone knows of a hack for this situation, I'm all for it ! 如果有人知道这种情况的破解,我全力以赴!

PS: As I type this, I realise that xAxis seems to always be datetime with Gantt, so the "hack" of defining every xValue myself was probably for a regular chart... Am I doomed to have weekends ? PS:在键入此内容时,我意识到xAxis似乎总是与甘特(Gantt)约会,因此我自己定义每个xValue的“技巧”可能是用于常规图表...我注定要有周末吗?

Edit: Here's a fiddle of where we're at right now. 编辑:这是我们现在所在位置的小提琴 As you can see, we are able to hide all weekends using 如您所见,我们可以使用

xAxis: [{
    breaks: [{
        from: Date.UTC(2018, 11, 8),
        to: Date.UTC(2018, 11, 10),
        breakSize: 0,
        repeat: 7 * 24 * 36e5 //every week/7 days
    }]
}]

But, unfortunately, breaks don't seem to be compatible with the "draggable-points" module and causes dragged points/tasks to "resize" themselves when moved over a break (weekends in our case), flicker and, at some point, even disappear from the Gantt :/ (Also, some labels act weirdly when dragging) 但是,不幸的是,中断似乎与“可拖动点”模块不兼容,并且在经过中断(在本例中为周末)时,拖动的点/任务会自行“调整大小”,闪烁,并且在某些时候,甚至从Gantt中消失了:/(此外,某些标签在拖动时行为异常)

I suppose I could "hide" the weekend labels using a custom formater and checking the X value but this would probably leave a blank, but existing, column in the graph and this is why I need to truly remove these dates. 我想我可以使用自定义格式器“隐藏”周末标签并检查X值,但这可能会在图中留下空白但现有的列,这就是为什么我需要真正删除这些日期。

I'll probably have to leave the weekends turned on and do checks/maths so that adding 2 days to a 5 workdays task doesn't "draw" the task over the weekend but actually adds 4 days to compensate (modulo for the win) but that's not ideal... 我可能必须将周末保持打开状态并进行检查/计算,以便在5个工作日的任务中增加2天不会在周末“吸引”该任务,而是实际上要增加4天的补偿(取胜的模数)但这不理想...

Should I report this (kinda) weird behavior between draggable-points and xAxis breaks as a bug ? 我应该将可拖动点和xAxis中断之间的这种(奇怪的)异常行为报告为bug吗? Technically, the points don't change value (I mean, in this demo , using the buttons and console, you see that the xmax-xmin for each point stays the same) but, when drag-dropped onto a weekend, they disappear. 从技术上讲,这些点不会改变值(我是说,在本演示中 ,使用按钮和控制台,您会看到每个点的xmax-xmin保持不变),但是当拖放到周末时,它们消失了。 That's what I'm trying to avoid. 这就是我要避免的事情。

tl;dr: The breaks act as black-holes when a point is dragged near them (you can't drag a to less than... half a week of distance between your mouse and the break). tl; dr:当在点附近拖曳中断时,中断就像黑洞(将a拖到鼠标与中断之间半周的距离不能少于...)。

Edit: bug report 编辑: 错误报告

You can use breaks to hide weekends on the chart. 您可以使用breaks时间在图表上隐藏周末。 Below you can find an example how to use breaks, but you can also create a function which would insert a break in every weekend: 您可以在下面找到如何使用休息时间的示例,但是您还可以创建一个在每个周末插入休息时间的函数:

xAxis: [{
    breaks: [{
        from: Date.UTC(2018, 11, 8),
        to: Date.UTC(2018, 11, 10),
        breakSize: 0
    }]
}, {
    visible: false
}]

Live demo: https://jsfiddle.net/BlackLabel/se1vL6mx/ 现场演示: https : //jsfiddle.net/BlackLabel/se1vL6mx/

API: https://api.highcharts.com/gantt/xAxis.breaks API: https//api.highcharts.com/gantt/xAxis.breaks

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

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