pub struct GanttPlot {
pub tasks: Vec<GanttTask>,
pub group_order: Vec<String>,
pub now_line: Option<f64>,
pub bar_height_frac: f64,
pub milestone_size: f64,
pub show_labels: bool,
pub label_min_width: f64,
pub color: String,
pub group_bg: String,
pub legend_label: Option<String>,
}Expand description
Builder for a Gantt chart.
Tasks are grouped by phase (optional). Within each phase, tasks appear in insertion order. Milestones are rendered as diamonds. An optional “now” line marks the current date/time. Progress fills show task completion.
§Example
use kuva::prelude::*;
let gantt = GanttPlot::new()
.with_task_group("Design", "Wireframes", 0.0, 3.0)
.with_task_group("Design", "Prototyping", 2.0, 5.0)
.with_task_group("Dev", "Backend API", 3.0, 8.0)
.with_task_group_progress("Dev", "Frontend", 4.0, 9.0, 0.4)
.with_milestone("Launch", 10.0)
.with_now_line(6.0);
let plots = vec![Plot::from(gantt)];
let layout = Layout::auto_from_plots(&plots)
.with_title("Project Plan")
.with_x_label("Week");Fields§
§tasks: Vec<GanttTask>§group_order: Vec<String>Explicit group ordering. Groups not listed appear in insertion order after.
now_line: Option<f64>If Some(v), draw a vertical dashed line at x = v.
bar_height_frac: f64Bar height as a fraction of row height. Default 0.6.
milestone_size: f64Diamond half-size in pixels for milestones. Default 7.0.
show_labels: boolWhen true, task labels are drawn inside (or beside) bars. Default true.
label_min_width: f64Minimum bar pixel width to attempt an inside label. Default 40.0.
color: StringDefault bar color when no group color or per-task color applies. Default "steelblue".
group_bg: StringBackground band color for group header rows. Default "#ebebeb".
legend_label: Option<String>Implementations§
Source§impl GanttPlot
impl GanttPlot
pub fn new() -> Self
Sourcepub fn with_task(
self,
label: impl Into<String>,
start: impl Into<f64>,
end: impl Into<f64>,
) -> Self
pub fn with_task( self, label: impl Into<String>, start: impl Into<f64>, end: impl Into<f64>, ) -> Self
Add an ungrouped task.
Sourcepub fn with_task_group(
self,
group: impl Into<String>,
label: impl Into<String>,
start: impl Into<f64>,
end: impl Into<f64>,
) -> Self
pub fn with_task_group( self, group: impl Into<String>, label: impl Into<String>, start: impl Into<f64>, end: impl Into<f64>, ) -> Self
Add a task belonging to a named group/phase.
Sourcepub fn with_task_progress(
self,
label: impl Into<String>,
start: impl Into<f64>,
end: impl Into<f64>,
progress: impl Into<f64>,
) -> Self
pub fn with_task_progress( self, label: impl Into<String>, start: impl Into<f64>, end: impl Into<f64>, progress: impl Into<f64>, ) -> Self
Add an ungrouped task with a progress fill (0.0–1.0).
Sourcepub fn with_task_group_progress(
self,
group: impl Into<String>,
label: impl Into<String>,
start: impl Into<f64>,
end: impl Into<f64>,
progress: impl Into<f64>,
) -> Self
pub fn with_task_group_progress( self, group: impl Into<String>, label: impl Into<String>, start: impl Into<f64>, end: impl Into<f64>, progress: impl Into<f64>, ) -> Self
Add a grouped task with a progress fill.
Sourcepub fn with_colored_task(
self,
label: impl Into<String>,
start: impl Into<f64>,
end: impl Into<f64>,
color: impl Into<String>,
) -> Self
pub fn with_colored_task( self, label: impl Into<String>, start: impl Into<f64>, end: impl Into<f64>, color: impl Into<String>, ) -> Self
Add an ungrouped task with a per-task color override.
Sourcepub fn with_milestone(
self,
label: impl Into<String>,
at: impl Into<f64>,
) -> Self
pub fn with_milestone( self, label: impl Into<String>, at: impl Into<f64>, ) -> Self
Add a milestone (diamond marker) with no group.
Sourcepub fn with_milestone_group(
self,
group: impl Into<String>,
label: impl Into<String>,
at: impl Into<f64>,
) -> Self
pub fn with_milestone_group( self, group: impl Into<String>, label: impl Into<String>, at: impl Into<f64>, ) -> Self
Add a milestone belonging to a named group/phase.
Sourcepub fn with_now_line(self, value: impl Into<f64>) -> Self
pub fn with_now_line(self, value: impl Into<f64>) -> Self
Set the x-value for the vertical “now” reference line.
Sourcepub fn with_group_order(
self,
groups: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn with_group_order( self, groups: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Override the display order of groups. Unlisted groups follow in insertion order.
Sourcepub fn with_bar_height(self, frac: f64) -> Self
pub fn with_bar_height(self, frac: f64) -> Self
Set bar height as fraction of row height. Default 0.6.
Sourcepub fn with_milestone_size(self, size: f64) -> Self
pub fn with_milestone_size(self, size: f64) -> Self
Set milestone diamond half-size in pixels. Default 7.0.
Sourcepub fn with_show_labels(self, show: bool) -> Self
pub fn with_show_labels(self, show: bool) -> Self
Show or hide task labels. Default true.
Sourcepub fn with_color(self, color: impl Into<String>) -> Self
pub fn with_color(self, color: impl Into<String>) -> Self
Set the default bar color (used when there are no groups). Default "steelblue".
Sourcepub fn with_group_bg(self, color: impl Into<String>) -> Self
pub fn with_group_bg(self, color: impl Into<String>) -> Self
Set the group header row background color. Default "#ebebeb".
Sourcepub fn with_legend(self, label: impl Into<String>) -> Self
pub fn with_legend(self, label: impl Into<String>) -> Self
Attach a legend label (shows a colored rect entry).
Sourcepub fn effective_group_order(&self) -> Vec<Option<String>>
pub fn effective_group_order(&self) -> Vec<Option<String>>
Returns groups in effective display order.
Named groups appear first (in group_order, then insertion order),
ungrouped tasks last (represented as None).
Sourcepub fn ordered_display_rows(&self) -> Vec<GanttDisplayRow>
pub fn ordered_display_rows(&self) -> Vec<GanttDisplayRow>
Returns display rows in top-to-bottom order.
Sourcepub fn row_labels(&self) -> Vec<String>
pub fn row_labels(&self) -> Vec<String>
Row labels in top-to-bottom display order (used to build y_categories).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GanttPlot
impl RefUnwindSafe for GanttPlot
impl Send for GanttPlot
impl Sync for GanttPlot
impl Unpin for GanttPlot
impl UnsafeUnpin for GanttPlot
impl UnwindSafe for GanttPlot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.