JFLib

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 Texts the words of a legend in the caller's language

    • title: 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 Swatch the picture of an entry

    • Callout { master: MasterRef, icon: Option<i32>, value: Option<f64> } -- an instance of a callout master: an icon number, a value for the field
    • Color(u32) -- a rectangle in this colour (0xRRGGBB)
    • None -- text only
  • struct Entry an entry: its picture and text

    • swatch: Swatch
    • text: String
  • struct Group a group: the field's label and the entries

    • label: String
    • entries: Vec<Entry>
  • fn groups(doc: &Document, page: PageRef, t: &Texts) -> Vec<Group> the groups of the legend of the graphics shown on page

  • fn 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 on page (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) -> bool whether a shape is (the outer list of) a data graphic legend

Source: docs/API.md in the JFLib repository.