diagram_core/src/datagraphic/legend.rs#
Source: lib/diagram_core/src/datagraphic/legend.rs
legend -- (JD19, ST-08, RD-07) the legend of the data graphics on a page
Texts the words the legend writes (the caller's language): its title,
the tests of icon rules, the line of a text item
groups(doc, page, &texts) what the legend shows: one group per item of the graphics the
page's shapes show (its field and kind once), each with its
entries: an icon and its rule, a colour and its value or range,
a bar and its range, a text item
insert(tx, eng, page, horizontal, &texts) -> ShapeRef the legend as Visio 2010 and later
build it: an outer list ("Legende", horizontal or vertical), one
container per group with the field as its heading, inside an
invisible list of the entries; at the top right of the page
The legend is built with diagram_core::structure (Relationships on both sides, the lists
laid out, the containers fitted) from plain shapes, so it is edited like any list: entries can
be retyped and dragged. Like Visio's it is not kept up to date: after the graphics change
the user inserts it again. Its outer list carries User.JFD_DGLegend = TRUE (own cell; how
Visio marks its legend is not known). The swatches are instances of the items' callout
masters (an icon with its number fixed, a bar half full) and small rectangles in the colours.
struct Textsthe words of a legend in the caller's languagetitle: String-- the outer list's heading ("Legende")text: String-- the entry of a text item ("Wert als Text")ops: [String; 10]-- the tests in the order of Op::ALL ("", "=", "≠", ">" ... "zwischen", "enthält" ...)icon: String-- an icon whose rule is not known ("Symbol {}")
enum Swatchthe picture of an entryCallout { master: MasterRef, icon: Option<i32>, value: Option<f64> }-- an instance of a callout master: an icon number, a value for the fieldColor(u32)-- a rectangle in this colour (0xRRGGBB)None-- text only
struct Entryan entry: its picture and textswatch: Swatchtext: String
struct Groupa group: the field's label and the entrieslabel: Stringentries: Vec<Entry>
fn groups(doc: &Document, page: PageRef, t: &Texts) -> Vec<Group>the groups of the legend of the graphics shown onpagefn insert(tx: &mut Transaction, eng: &mut Engine, page: PageRef, horizontal: bool, t: &Texts, layer_name: &str) -> Result<ShapeRef, EditError>the legend of the data graphics onpage(see the file header) at the top right of the page -> its outer list (Invalid: the page shows no data graphic)fn is_legend(doc: &Document, s: ShapeRef) -> boolwhether a shape is (the outer list of) a data graphic legend