Skip to contents

Computes the rectangle geometry of the structure plot as a plain data.frame — one band per timeframe (coarsest at the top, plus the implicit ANNUAL root), one rectangle per contiguous timeslice segment, x normalized to [0, 1] (share of the covered year). Exposed so the layout can be drawn with something other than ggplot2; the same frame backs gg_calendar().

Usage

calendar_layout(x, annual = TRUE)

Arguments

x

A Calendar.

annual

Include the ANNUAL root band on top? Default TRUE.

Value

A data.frame with columns timeframe, label (the token label of the segment, e.g. h00), timeslice (the member of the timeframe the segment shows, e.g. Q1_h00), rank (0 for ANNUAL, then 1 = coarsest), xmin/xmax (in [0, 1]), ymin/ymax (bands, top row highest), total (the part of the year the segment stands for, which is what its extent shows), share, width and weight (those of the leaf timeslice for a segment of the finest timeframe; for a coarser segment and the root, those of the timeslice merged from its leaves, as prune_calendar() states them: its own unit, width 1 and weight 1 unless the timeframe declares a unit), order (index of the segment's first leaf in chronological order), and within (1-based position among its siblings, restarting per parent).

Examples

head(calendar_layout(calendar("q4_h24")))
#>   timeframe  label timeslice rank      xmin       xmax ymin ymax      total
#> 1    ANNUAL ANNUAL    ANNUAL    0 0.0000000 1.00000000    2  2.9 1.00000000
#> 2   QUARTER     Q1        Q1    1 0.0000000 0.24657534    1  1.9 0.24657534
#> 3   QUARTER     Q2        Q2    1 0.2465753 0.49589041    1  1.9 0.24931507
#> 4   QUARTER     Q3        Q3    1 0.4958904 0.74794521    1  1.9 0.25205479
#> 5   QUARTER     Q4        Q4    1 0.7479452 1.00000000    1  1.9 0.25205479
#> 6      HOUR    h00    Q1_h00    2 0.0000000 0.01027397    0  0.9 0.01027397
#>          share width weight order within
#> 1 1.0000000000     1      1     1      1
#> 2 0.2465753425     1      1     1      1
#> 3 0.2493150685     1      1    25      2
#> 4 0.2520547945     1      1    49      3
#> 5 0.2520547945     1      1    73      4
#> 6 0.0001141553     1     90     1      1