Stem-and-Leaf Builder
Builds a stem-and-leaf plot from editable data. The learner picks the stem's place value, splits stems into two lines (leaves 0-4 and 5-9), places values one at a time and sorts the leaves, or turns the plot on its side to see a histogram that still keeps every digit. Clicking a leaf reads back the value it stands for.
Used in: Introduction to Statistics
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| title | string | Stem-and-leaf plot | Card title. |
| data | number[] | [52, 55, 61, 63, 64, 68, 70, 71, 74, 79, 83] | The data values, in the order they were recorded (up to 300; negatives allowed, shown on '−' stems). Build mode places them in this order. |
| stemUnit | number | (auto: the finest power of ten giving at most 15 stems) | Place value of the stem, a power of ten: 10 = stem tens / leaf ones, 1 = stem ones / leaf first decimal place, 100 = stem hundreds / leaf tens. The leaf is the next digit (stemUnit / 10); lower digits are truncated (see leafRounding). The learner can change it. |
| split | boolean | false | Two lines per stem: leaves 0-4 on the first line and 5-9 on the second; every stem in range gets both lines (empty ones kept). The learner can toggle it. |
| caption | string | (none) | Data set name shown above the plot, e.g. 'Resting Heart Rates of BSU Students'. |
| keyStyle | string | both | Key under the plot: 'places' = 'Stem: Tens / Leaf: Ones' (slide style), 'value' = 'Key: 5 | 2 = 52' (smallest value), 'both', or 'none'. |
| stemLabel | string | (from stemUnit, e.g. 'Tens') | Override the stem's place name in the key. |
| leafLabel | string | (from stemUnit, e.g. 'Ones' or 'First decimal place') | Override the leaf's place name in the key. |
| mode | string | plot | 'plot' shows the finished plot. 'build' starts empty: the learner places the values one at a time in data order (each leaf lands on its stem's line, unsorted), then sorts the leaves. |
| placed | number | 0 | Build mode only: how many values are already placed at the start (0 to n). |
| view | string | plot | 'plot' = stems down the side; 'sideways' = turned on its side so the leaf columns stand up like histogram bars. Ignored with compareData. |
| viewToggle | boolean | true | Show the Plot / Sideways switch in the title bar. |
| controls | string[] | boolean | all controls shown | Ids of the hideable controls to show (see the controls registry: toggle.stem-unit, toggle.split, toggle.counts, toggle.view); core controls always show. Omit to show everything. Fitted per page by component_scopes.py, not by hand. Legacy boolean: false hides the stem-unit choice, the two-lines-per-stem switch and the counts switch (a fixed display); true = omitted. Starting states (split, showCounts, view) still apply when their switch is hidden. |
| editable | boolean | true | Let the learner replace the data (comma- or space-separated numbers). |
| showCounts | boolean | false | Show the number of leaves on each line (its frequency). The learner can toggle it. |
| showData | boolean | (true when editable or in build mode) | Show the raw data as clickable chips above the plot (clicking one highlights its leaf). |
| compareData | number[] | (none) | A second group for a back-to-back plot: its leaves run leftward from the shared stems (smallest next to the stem), `data` runs rightward. |
| dataLabel | string | (none) | Name of the `data` group (right side of a back-to-back plot). |
| compareLabel | string | (none) | Name of the `compareData` group (left side). |
| leafRounding | string | truncate | How digits below the leaf are handled: 'truncate' (drop them; textbook default) or 'round'. A note appears when any value loses digits. |