diagram_core/src/report/run.rs#
Source: lib/diagram_core/src/report/run.rs
run -- a report definition run against a drawing: the shapes it takes, their values, the
table with groups, summaries and the grand total
run(doc, &def, &Ctx) -> Table
Ctx { page, selection, labels } the page shown, the selected shapes, the words of the
summary rows (the app's language; English by default)
Table { title, columns, rows, shapes } rows of RowKind Item, Group (a group's heading),
Summary(f) (a group's subtotal), Grand(f) (over all);
None instead of a function: a row with several
The layouts:
* no grouping: the shapes' rows (sorted, duplicates left out when the definition says so),
then one row per summary function any column has (Grand), the function's name in the first
empty cell
* grouping with the rows shown: per group a heading row (the group's value in its column),
its rows, one subtotal row per function; with GrandSummary the summaries over all at the end
* grouping, summaries only (ItemDisplay 0): one row per group -- the group's value, then a
column per (field, function): "Anzahl" for the grouping field itself, else
"<field> (<function>)" -- and with GrandSummary a last row over all (Visio's inventory:
Master-Name and the count of each)
Summaries take the numbers of a column, also numbers kept as text ("450" in a text field).
Values: a number in the definition's precision with the drawing's decimal sign
(Document::fields), with the unit's abbreviation when ShowUnits is on and the unit has one
(lengths in the unit of their cell, per cent, angles, durations); dates in the general date
format; Booleans as Labels::yes / no; texts as they are. Each cell also carries its value
typed (Val): the number in the shown unit, rounded to the precision, for CSV and XLSX.
Sorting compares numbers as numbers and texts by their characters (case as the sort key
says); an empty or missing value comes first. Criteria: =, <>, <, <=, >, >= compare numbers
when both sides are numbers (the criterion's value in its Unit, else in the shape's unit),
else texts (case as the definition says); exists / does not exist ask whether the shape has
the field. Every criterion must hold, one with AndOr 0 is an "or" with the ones before.
struct Labelsthe words of the summary rows and of truth values (the app's language)total: String-- Func::Totalaverage: String-- Func::Averagecount: String-- Func::Countmin: String-- Func::Minmax: String-- Func::Maxmedian: String-- Func::Mediangrand: String-- the rows over all groupsyes: String-- a true valueno: String-- a false value
impl Labels
fn func(&self, f: Func) -> &strthe word of a functionstruct Ctx<'a>where a report runspage: Option<PageRef>-- the page shown (Scope::Page)selection: &'a [ShapeRef]-- the selected shapes (Scope::Selection)labels: Labels-- the words of the summary rows
enum Vala cell's value, typedEmpty-- nothingNum(f64)-- a number in the unit shownText(String)-- a textBool(bool)-- a truth valueDate(f64)-- a date (days since 30 December 1899)
struct Cella cell of the table: its text and its valuetext: String-- as shownvalue: Val-- typed
enum RowKindwhat a row of the table isItem-- a shape's row (summaries only: a group's row)Group-- a group's headingSummary(Option<Func>)-- a group's subtotal (None: several functions in one row)Grand(Option<Func>)-- the summary over all (None: several functions in one row)
struct Rowa row of the tablekind: RowKind-- what it iscells: Vec<Cell>-- a cell per column
struct Columna column of the tablename: String-- its headingnumeric: bool-- its values are numbers (right-aligned)
struct Tablea report's resulttitle: String-- the title (the definition's Title, else its Name)columns: Vec<Column>-- the columnsrows: Vec<Row>-- the rowsshapes: usize-- how many shapes the report took
fn run(doc: &Document, def: &ReportDef, ctx: &Ctx) -> Tablerun a definition against a drawing