jQuery.Gantt
jQuery.Gantt copied to clipboard
Custom date range
It would be nice to have the possibility of setting a start and end date range for the GANTT chart, for example showing only one complete year (no matter if there are items or not).
This would probably mean adding two new parameters (dateStart, dateEnd) to the GANTT configuration.
Is this something that could be done without a lot of work or can I somehow achieve this functionality already?
Thanks for the suggestion! Sounds like a reasonable feature, and it should be fairly straightforward to implement. (And yes, there's at least one way to do this already, though it's pretty hacky and horrible, so I won't even describe it. ;)
Just to clarify, @lazlev, would these options prevent the chart from showing data that might already exist outside the given range? Or would they only dictate the minimum displayable range, still allowing one to scroll past either date if there are more items outside said range? Please also take a look at #121, which seeks to display a minimum date range based on the width of the chart. Would a custom date range override this functionality?
Perhaps we could take four new parameters: minStartDate
, minEndDate
, maxStartDate
, and maxEndDate
?
Sorry for the late late reply, I somehow forgot about this after my holidays...
For me, it would be nice if this feature prevents data from outside to be shown (e.g. should be cut off, if the item range exceeds the date range), so this means a fixed range, whether there are items to display or not. No possibility to scroll outside of this range.
I think the full width chart option should be overridden because otherwise the end date wouldn't always be fixed, right?
I'm not quite sure if I understand what you mean by those four parameters. Would it be possible to define the start date as 01/01/2014 and the end date as 31/12/2014? Which of your suggested parameters would I use for this case, minStartDate and maxEndDate?
Thanks for the continued input, @lazlev.
I suggested the four parameters (instead of only two) to allow users to specify explicit bounds, both upper and lower, for the start and end dates. This would cover both cases where the chart already has data and where it starts empty. For example, an empty chart might need to be initialized with maxStartDate
to make sure the chart goes back at least to a certain date. If a chart had very old data, you may want to limit how far back it goes with minStartDate
. Etc... In short:
minStartDate
== "Don't display earlier than this date, even if data exist before it." (lower bound)
maxStartDate
== "This chart should start at this date or earlier, even if NO data exists (or if all existing data start later)." (upper bound)
minEndDate
== "Display at least up to this date, even if there's no data (or if all existing data end earlier)." (lower bound)
maxEndDate
== "Don't display anything after this date, even if data exist beyond it." (upper bound)
Having all four options allows some more flexibility, permitting users to set a hard or soft limits to the display range. So, for your use case (hard limits on both), you would use all four parameters, setting respective min/max dates to be the same. Alternatively, we could add two more parameters, startDate
and endDate
, which would essentially just be a shortcut to initializing the respective max/min dates to the same value.
Sounds good to me!
Just a minor detail, but I'm wondering if these should be 4 (or 6) separate, flat options or if there should be a bounds
option that takes an object with 1-6 key-value pairs that specify these dates. Any opinions? @taitems?
I'd also really like to be able to set these bounds using an offset from "today", so perhaps a notation (e.g. accepting values matching /[+-][1-9]+[YMDWh]/
) or separate options that treat the passed dates as offsets. Thoughts?
I'd prefer the bounds
option and wouldn't mind an offset from today option although I'd probably use fixed dates in most cases.
Is this perhaps on the cards, would be really useful :)
@jacquesdev It is definitely on the list, though still being fleshed out. Feel free to add your opinion! It probably won't be in the next version, in any case.
Putting in a "me too" for this feature. I need it on a pretty short timeline, so I'm going to hack it in, hoping to see it in a more "official" capacity in a future release that considers all the use cases. I only have time to do it exactly as I need it or I'd put in a PR with my efforts.