Skip to content

Commit 5091aba

Browse files
authored
gantty:0.5.0 (#3289)
1 parent 51f696e commit 5091aba

File tree

17 files changed

+1922
-0
lines changed

17 files changed

+1922
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.5.0]
9+
10+
### Added
11+
12+
- Task dependencies under the `dependencies` field.
13+
- Drawers API to allow complete customization of various parts of the Gantt
14+
chart. This decision was made because there are many different ways of drawing
15+
dependencies (and, in fairness, many other parts of the Gantt chart) and
16+
because it will integrate better with show/set rules when they are available
17+
for custom elements.
18+
- The `drawers.default-drawer` dictionary containing the default drawer
19+
- An `x` field to intervals, tasks, milestones, and dependencies: to facilitate
20+
adding custom descriptions for custom drawers.
21+
- Expose the following functions under the `util` namespace: `EPSILON`, `rects-intersect`,
22+
`content-if-fits`, `task-anchor`, `task-anchor-line`, `task-anchor-sidebar`,
23+
`id-level`, `styles-for-level`, `styles-for-id`, `foreach-task`, `task-start`,
24+
`task-end`, `gantt-range`, `date-ratio`, `date-x-coord`, and `date-coord`.
25+
- Ability to provide a function to change how the sidebar items are styled.
26+
- Hide a milestone's date with `milestone.show-date`.
27+
28+
### Changed
29+
30+
- The `taskgroups` key is now `tasks`
31+
- The `tasks` key is now `subtasks`. All tasks can have subtasks.
32+
- Tasks are now drawn with rectangles, not lines.
33+
34+
### Fixed
35+
36+
- Poor normalization of the `today` milestone
37+
38+
### Removed
39+
40+
- The `style` key.
41+
- The `viewport-snap` key. Specify a `start` and `end` date instead.
42+
- Nameless tasks.
43+
- The `show-today` and `today-localized` keys. These should be configured on the
44+
milestone drawer instead.
45+
46+
## [0.4.0]
47+
48+
### Added
49+
50+
- The `intervals` field to task to allow for specifying multiple intervals in
51+
which as task is valid.
52+
- You can now manually specify interviews for a taskgroup
53+
54+
### Changed
55+
56+
- `form-well` is now called `normalize-gantt`
57+
- The `normalize-gantt` function now parses all datetimes as well.
58+
- Update `cetz`
59+
60+
### Fixed
61+
62+
- Certain properties on `block` and `baseline` causing messed up gridlines
63+
64+
## [0.3.0]
65+
66+
### Added
67+
68+
- The `today-localized` field to change the translation of "Today".
69+
- Documented the package.
70+
- The `create-header`, `create-custom-year-header`, `create-custom-month-header`,
71+
`create-custom-day-header`, and `create-custom-week-header`.
72+
- The ability for anonymous taskgroups
73+
74+
## [0.2.1]
75+
76+
### Fixed
77+
78+
- Days overrunning the header.
79+
80+
## [0.2.0] - 2025-03-06
81+
82+
### Added
83+
84+
- Support for custom start end and dates.
85+
86+
### Fixed
87+
88+
- A floating point precision error causing milestones to fail to resolve.
89+
- A typo in the documentation.
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
GNU LESSER GENERAL PUBLIC LICENSE
2+
3+
Version 3, 29 June 2007
4+
5+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
6+
7+
Everyone is permitted to copy and distribute verbatim copies of this license
8+
document, but changing it is not allowed.
9+
10+
This version of the GNU Lesser General Public License incorporates the terms
11+
and conditions of version 3 of the GNU General Public License, supplemented
12+
by the additional permissions listed below.
13+
14+
0. Additional Definitions.
15+
16+
17+
18+
As used herein, "this License" refers to version 3 of the GNU Lesser General
19+
Public License, and the "GNU GPL" refers to version 3 of the GNU General Public
20+
License.
21+
22+
23+
24+
"The Library" refers to a covered work governed by this License, other than
25+
an Application or a Combined Work as defined below.
26+
27+
28+
29+
An "Application" is any work that makes use of an interface provided by the
30+
Library, but which is not otherwise based on the Library. Defining a subclass
31+
of a class defined by the Library is deemed a mode of using an interface provided
32+
by the Library.
33+
34+
35+
36+
A "Combined Work" is a work produced by combining or linking an Application
37+
with the Library. The particular version of the Library with which the Combined
38+
Work was made is also called the "Linked Version".
39+
40+
41+
42+
The "Minimal Corresponding Source" for a Combined Work means the Corresponding
43+
Source for the Combined Work, excluding any source code for portions of the
44+
Combined Work that, considered in isolation, are based on the Application,
45+
and not on the Linked Version.
46+
47+
48+
49+
The "Corresponding Application Code" for a Combined Work means the object
50+
code and/or source code for the Application, including any data and utility
51+
programs needed for reproducing the Combined Work from the Application, but
52+
excluding the System Libraries of the Combined Work.
53+
54+
1. Exception to Section 3 of the GNU GPL.
55+
56+
You may convey a covered work under sections 3 and 4 of this License without
57+
being bound by section 3 of the GNU GPL.
58+
59+
2. Conveying Modified Versions.
60+
61+
If you modify a copy of the Library, and, in your modifications, a facility
62+
refers to a function or data to be supplied by an Application that uses the
63+
facility (other than as an argument passed when the facility is invoked),
64+
then you may convey a copy of the modified version:
65+
66+
a) under this License, provided that you make a good faith effort to ensure
67+
that, in the event an Application does not supply the function or data, the
68+
facility still operates, and performs whatever part of its purpose remains
69+
meaningful, or
70+
71+
b) under the GNU GPL, with none of the additional permissions of this License
72+
applicable to that copy.
73+
74+
3. Object Code Incorporating Material from Library Header Files.
75+
76+
The object code form of an Application may incorporate material from a header
77+
file that is part of the Library. You may convey such object code under terms
78+
of your choice, provided that, if the incorporated material is not limited
79+
to numerical parameters, data structure layouts and accessors, or small macros,
80+
inline functions and templates (ten or fewer lines in length), you do both
81+
of the following:
82+
83+
a) Give prominent notice with each copy of the object code that the Library
84+
is used in it and that the Library and its use are covered by this License.
85+
86+
b) Accompany the object code with a copy of the GNU GPL and this license document.
87+
88+
4. Combined Works.
89+
90+
You may convey a Combined Work under terms of your choice that, taken together,
91+
effectively do not restrict modification of the portions of the Library contained
92+
in the Combined Work and reverse engineering for debugging such modifications,
93+
if you also do each of the following:
94+
95+
a) Give prominent notice with each copy of the Combined Work that the Library
96+
is used in it and that the Library and its use are covered by this License.
97+
98+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
99+
document.
100+
101+
c) For a Combined Work that displays copyright notices during execution, include
102+
the copyright notice for the Library among these notices, as well as a reference
103+
directing the user to the copies of the GNU GPL and this license document.
104+
105+
d) Do one of the following:
106+
107+
0) Convey the Minimal Corresponding Source under the terms of this License,
108+
and the Corresponding Application Code in a form suitable for, and under terms
109+
that permit, the user to recombine or relink the Application with a modified
110+
version of the Linked Version to produce a modified Combined Work, in the
111+
manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
112+
113+
1) Use a suitable shared library mechanism for linking with the Library. A
114+
suitable mechanism is one that (a) uses at run time a copy of the Library
115+
already present on the user's computer system, and (b) will operate properly
116+
with a modified version of the Library that is interface-compatible with the
117+
Linked Version.
118+
119+
e) Provide Installation Information, but only if you would otherwise be required
120+
to provide such information under section 6 of the GNU GPL, and only to the
121+
extent that such information is necessary to install and execute a modified
122+
version of the Combined Work produced by recombining or relinking the Application
123+
with a modified version of the Linked Version. (If you use option 4d0, the
124+
Installation Information must accompany the Minimal Corresponding Source and
125+
Corresponding Application Code. If you use option 4d1, you must provide the
126+
Installation Information in the manner specified by section 6 of the GNU GPL
127+
for conveying Corresponding Source.)
128+
129+
5. Combined Libraries.
130+
131+
You may place library facilities that are a work based on the Library side
132+
by side in a single library together with other library facilities that are
133+
not Applications and are not covered by this License, and convey such a combined
134+
library under terms of your choice, if you do both of the following:
135+
136+
a) Accompany the combined library with a copy of the same work based on the
137+
Library, uncombined with any other library facilities, conveyed under the
138+
terms of this License.
139+
140+
b) Give prominent notice with the combined library that part of it is a work
141+
based on the Library, and explaining where to find the accompanying uncombined
142+
form of the same work.
143+
144+
6. Revised Versions of the GNU Lesser General Public License.
145+
146+
The Free Software Foundation may publish revised and/or new versions of the
147+
GNU Lesser General Public License from time to time. Such new versions will
148+
be similar in spirit to the present version, but may differ in detail to address
149+
new problems or concerns.
150+
151+
Each version is given a distinguishing version number. If the Library as you
152+
received it specifies that a certain numbered version of the GNU Lesser General
153+
Public License "or any later version" applies to it, you have the option of
154+
following the terms and conditions either of that published version or of
155+
any later version published by the Free Software Foundation. If the Library
156+
as you received it does not specify a version number of the GNU Lesser General
157+
Public License, you may choose any version of the GNU Lesser General Public
158+
License ever published by the Free Software Foundation.
159+
160+
If the Library as you received it specifies that a proxy can decide whether
161+
future versions of the GNU Lesser General Public License shall apply, that
162+
proxy's public statement of acceptance of any version is permanent authorization
163+
for you to choose that version for the Library.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Gantty
2+
3+
Gantty is a typst library for creating Gantt charts using datetimes.
4+
5+
View the manual [here](https://john_t.gitlab.io/typst-gantty/manual.pdf).
6+
7+
## Features
8+
9+
- Works with real dates.
10+
- Customizable styling.
11+
- Extensible to support multiple languages.
12+
13+
## Why not typst-timeliney
14+
15+
[Typst-timeliney](https://typst.app/universe/package/timeliney) is another
16+
excellent typst Gantt chart creator. The main differences between this library
17+
and typst-timeliney is that Gantty uses datetimes to work with real dates,
18+
whereas typst-timeliney works with coordinates. Look at the typst-timeliney
19+
documentation and decide which is more fitting for your use.
20+
21+
## Examples
22+
23+
![A Gantt chart](https://gitlab.com/john_t/typst-gantty/-/raw/master/example/gantt.svg)
24+
25+
index.typ:
26+
27+
```typst
28+
#import "@preview/gantty:0.5.0": gantt
29+
30+
#gantt(yaml("gantt.yaml"))
31+
```
32+
33+
Here, the orange is used to indicate a task completed late and the green is used
34+
to indicate a task that has been completed.
35+
36+
gantt.yaml:
37+
38+
```yaml
39+
show-today: true
40+
# Either month or day
41+
viewport-snap: day
42+
# Can include `year`, `month`, `week`, or `day`
43+
headers:
44+
- month
45+
- week
46+
# A start date. Not required.
47+
start: 2024-11-01
48+
# An end date. Not required.
49+
end: 2025-03-31
50+
taskgroups:
51+
- name: Research
52+
tasks:
53+
- name: Read Statements
54+
start: 2024-11-27
55+
end: 2024-12-04
56+
done: 2024-11-29
57+
- name: Drafting
58+
tasks:
59+
- name: α draft
60+
start: 2024-12-12
61+
end: 2024-12-31
62+
- name: β draft
63+
start: 2024-12-31
64+
end: 2025-01-31
65+
- name: First draft
66+
start: 2025-01-31
67+
end: 2025-02-14
68+
- name: γ draft
69+
start: 2025-02-14
70+
end: 2025-03-07
71+
- name: Final Draft
72+
start: 2025-03-07
73+
end: 2025-03-24
74+
- name: Production Log
75+
tasks:
76+
- name: Record initial ideas
77+
start: 2024-11-27
78+
end: 2024-12-04
79+
done: 2024-12-08
80+
milestones:
81+
- name: 1st Draft Hand In
82+
date: 2025-02-14
83+
- name: Final Hand In
84+
date: 2025-03-24
85+
```
86+
87+
## Styling
88+
89+
Gantty is very customizable. Here is the `test/serious-depepdencies` example:
90+
91+
![A Gantt chart with dependencies](https://gitlab.com/john_t/typst-gantty/-/raw/master/tests/serious-dependencies/ref/1.png)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/// Gets the length of the month in the datetime.
2+
///
3+
/// Note: this functions is made public only for niche usecases.
4+
/// In all likelihood if you are using this you are probably using
5+
/// `create-custom-header` instead of `create-custom-month-header`
6+
/// -> function
7+
#let month-length(
8+
/// A datetime for specific month (only year and month are used).
9+
/// -> datetime
10+
datetime,
11+
) = {
12+
let year = datetime.year()
13+
let month = datetime.month()
14+
15+
let leap-year = (
16+
(
17+
(calc.rem(year, 4) == 0) and not (calc.rem(year, 100) == 0)
18+
)
19+
or calc.rem(year, 400) == 0
20+
)
21+
22+
let feb = if leap-year {
23+
29
24+
} else {
25+
28
26+
}
27+
28+
(31, feb, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31).at(month - 1)
29+
}
30+
31+
/// Parse an iso8601 datetime
32+
///
33+
/// Passes through actual datetime objects
34+
#let parse-datetime(s) = {
35+
if type(s) == datetime {
36+
s
37+
} else {
38+
datetime(year: int(s.slice(0, 4)), month: int(s.slice(5, 7)), day: int(
39+
s.slice(8, 10),
40+
))
41+
}
42+
}
43+
44+
/// Gets the dat before the given datetime
45+
#let yesterday(dt) = {
46+
dt - duration(days: 1)
47+
}

0 commit comments

Comments
 (0)