pub struct Timeline { /* private fields */ }Expand description
Labelled ranges on a numeric scale, such as the steps of a build in seconds: a Gantt strip when every range has its own row, a timeline of lanes when ranges share a row.
- Each row is labelled on the left. Ranges on the same row that overlap are stacked onto extra lines under it, so none hides another.
- Ranges are drawn
█, or▓when one follows another on the same line (#and=in ASCII), in their row’schart.series.Ncolour. A range covers every column whose centre value is inside it, and at least one. - Each range’s length is written after it when there is room before
the next one (
durations, on by default), so the chart reads without the axis. milestonemarks a point with◆(*) on a line under the ranges, its label beside it when it fits.- The axis runs along the bottom. Its labels sit on evenly spaced
columns and name each column’s exact value, as on a
LineChart;unitis written after each value (20s). - Compression: when the range is wider than the plot, so that the
shortest range would get less than a column of its own, idle gaps
longer than four times the shortest range, and longer than three
columns’ worth of the uncut scale, are cut out
(
compress, on by default). Each cut is three columns with≈(~) on the axis, and the axis labels each stretch at its start and end. - It fills the width given, or
width. Given less, the row labels are cut so the plot keeps 8 columns.
use rich::Console;
use rich_ext::chart::Timeline;
let console = Console::builder().width(40).color_system(None).build();
let build = Timeline::new()
.span("fetch", 0.0, 4.0)
.span("compile", 4.0, 26.0)
.span("test", 12.0, 30.0)
.span("test", 20.0, 34.0)
.milestone("ship", 36.0)
.unit("s")
.width(40);
assert_eq!(
console.render_export(&build),
concat!(
"fetch ████ 4s \n",
"compile █████████████████ 22s \n",
"test ███████████████ 18s \n",
" ████████████ 14s\n",
" ship ◆ \n",
" ┬───────┬───────┬───────┬───────\n",
" 0s 10s 20s 30s \n",
)
);Implementations§
Source§impl Timeline
impl Timeline
Sourcepub fn span(self, row: impl Into<String>, start: f64, end: f64) -> Self
pub fn span(self, row: impl Into<String>, start: f64, end: f64) -> Self
Add a range on row row from start to end.
Sourcepub fn range(self, min: f64, max: f64) -> Self
pub fn range(self, min: f64, max: f64) -> Self
Fix the scale instead of fitting it to the ranges (no compression).
Sourcepub fn charset(self, charset: Charset) -> Self
pub fn charset(self, charset: Charset) -> Self
Glyphs to draw with: Charset::Ascii asks for ASCII; anything else
draws blocks (ASCII on an ASCII-only console).
Sourcepub fn format(self, format: ValueFormat) -> Self
pub fn format(self, format: ValueFormat) -> Self
How values are written (default ValueFormat::Compact).
Sourcepub fn unit(self, unit: impl Into<String>) -> Self
pub fn unit(self, unit: impl Into<String>) -> Self
Written after every value on the axis and every length, such as s.
Trait Implementations§
Source§impl AccessibleText for Timeline
Timeline, 3 rows, 4 ranges, 1 milestone, from 0s to 95s, then each
range (compile from 0s to 12s, 12s), twenty at most, and each
milestone (Milestone release at 90s).
impl AccessibleText for Timeline
Timeline, 3 rows, 4 ranges, 1 milestone, from 0s to 95s, then each
range (compile from 0s to 12s, 12s), twenty at most, and each
milestone (Milestone release at 90s).
Source§fn accessible_text(&self, _width: usize) -> String
fn accessible_text(&self, _width: usize) -> String
The content as plain lines, laid out for
width where layout matters.Source§impl Renderable for Timeline
impl Renderable for Timeline
fn rich_render( &self, console: &Console, options: &ConsoleOptions, ) -> Vec<Segment>
Source§fn measure(&self, _console: &Console, options: &ConsoleOptions) -> Measurement
fn measure(&self, _console: &Console, options: &ConsoleOptions) -> Measurement
The
(minimum, maximum) cell width this renderable wants. Port of
__rich_measure__. The default is what upstream’s Measurement.get
returns for a renderable without one: anything from nothing to the
whole width, (0, max_width).Source§fn fit_to_measurement(&self) -> bool
fn fit_to_measurement(&self) -> bool
Whether a top-level
Console::print shrinks this renderable to its
measured width. Upstream renders every top-level renderable at the full
console width, so the default is false; an extension may opt in.Source§fn vertical(&self) -> Option<VerticalAlign>
fn vertical(&self) -> Option<VerticalAlign>
The vertical alignment a
Table cell holding this renderable uses in
place of its column’s. Upstream reads getattr(renderable, "vertical", None); Align sets it.Source§fn print_end_line(&self, _options: &ConsoleOptions) -> bool
fn print_end_line(&self, _options: &ConsoleOptions) -> bool
Whether a top-level print ends this renderable’s last line. This
port’s renderables separate lines, where upstream’s end each line
with
"\n", so a print adds the final line break. A renderable
whose upstream output stops without one (Screen, LiveRender, a
Rule whose end has no newline) returns false, and the next
output continues its last line. options are the print’s options.impl StructuralPartialEq for Timeline
Auto Trait Implementations§
impl Freeze for Timeline
impl RefUnwindSafe for Timeline
impl Send for Timeline
impl Sync for Timeline
impl Unpin for Timeline
impl UnsafeUnpin for Timeline
impl UnwindSafe for Timeline
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
Mutably borrows from an owned value. Read more