Skip to main content

GanttPlot

Struct GanttPlot 

Source
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: f64

Bar height as a fraction of row height. Default 0.6.

§milestone_size: f64

Diamond half-size in pixels for milestones. Default 7.0.

§show_labels: bool

When true, task labels are drawn inside (or beside) bars. Default true.

§label_min_width: f64

Minimum bar pixel width to attempt an inside label. Default 40.0.

§color: String

Default bar color when no group color or per-task color applies. Default "steelblue".

§group_bg: String

Background band color for group header rows. Default "#ebebeb".

§legend_label: Option<String>

Implementations§

Source§

impl GanttPlot

Source

pub fn new() -> Self

Source

pub fn with_task( self, label: impl Into<String>, start: impl Into<f64>, end: impl Into<f64>, ) -> Self

Add an ungrouped task.

Source

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.

Source

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.01.0).

Source

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.

Source

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.

Source

pub fn with_milestone( self, label: impl Into<String>, at: impl Into<f64>, ) -> Self

Add a milestone (diamond marker) with no group.

Source

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.

Source

pub fn with_now_line(self, value: impl Into<f64>) -> Self

Set the x-value for the vertical “now” reference line.

Source

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.

Source

pub fn with_bar_height(self, frac: f64) -> Self

Set bar height as fraction of row height. Default 0.6.

Source

pub fn with_milestone_size(self, size: f64) -> Self

Set milestone diamond half-size in pixels. Default 7.0.

Source

pub fn with_show_labels(self, show: bool) -> Self

Show or hide task labels. Default true.

Source

pub fn with_color(self, color: impl Into<String>) -> Self

Set the default bar color (used when there are no groups). Default "steelblue".

Source

pub fn with_group_bg(self, color: impl Into<String>) -> Self

Set the group header row background color. Default "#ebebeb".

Source

pub fn with_legend(self, label: impl Into<String>) -> Self

Attach a legend label (shows a colored rect entry).

Source

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).

Source

pub fn ordered_display_rows(&self) -> Vec<GanttDisplayRow>

Returns display rows in top-to-bottom order.

Source

pub fn row_labels(&self) -> Vec<String>

Row labels in top-to-bottom display order (used to build y_categories).

Source

pub fn x_bounds(&self) -> Option<(f64, f64)>

Compute x-axis bounds across all tasks and the now line.

Trait Implementations§

Source§

impl Default for GanttPlot

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<GanttPlot> for Plot

Source§

fn from(p: GanttPlot) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Finish for T

Source§

fn finish(self)

Does nothing but move self, equivalent to drop.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

Source§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
Source§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

Source§

fn to_owned_table(&self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.