Component API

The props and events of the two components, as declared in @edubeam/plot 0.2.0. Neither has slots. Values in SI units are marked as such; sizes are CSS pixels.

StructurePlot

TypeScript
import { StructurePlot } from '@edubeam/plot'

Draws a plane structure and its results. Guide: StructurePlot.

Props

PropTypeDefaultDescription
solverSolver–A @edubeam/fem solver. Results are drawn once its load case is solved.
modelPlotModel–Or the plain data modelFromSolver makes. Takes precedence over solver.
loadCasenumber0Index into solver.loadCases
revisionnumber0Change it to redraw a solver changed in place
layersreadonly PlotLayer[]members, supports, loads, reactions and one resultWhat to draw: 'nodes', 'nodeLabels', 'dimensions', 'members', 'supports', 'loads', 'reactions', 'N', 'V', 'M', 'w'
reservereadonly PlotLayer[]layersLayers to make room for while hidden
compactbooleanfalseThumbnail drawing: smaller symbols, two values per member at most
unitsPartial<Units>KN_UNITSDisplay units
numberFormatIntl.NumberFormatEnglish, at most 1 decimalFormats every number
colorsPartial<PlotColors>–Colour overrides by tone: Theming
widthnumber640, compact 400Width before the box is measured, as on the server
heightnumber–Fixed height. Without it, the height follows the drawing.
maxHeightnumbermax(320, 0.75 × width), compact noneUpper bound of the automatic height
paddingnumber6Space around the drawing
fontSizenumber13, compact 11.5Text size
diagramSizenumber48, compact 26Length of the largest diagram ordinate
deformedSizenumber30, compact 18Largest displacement on the deformed shape
diagramScalePartial<Record<ResultLayer, number>>–Fixed px per SI unit for a result, overriding diagramSize or deformedSize
momentOnTensionSidebooleantrueM on the tension side; false for the compression side
resultLabelMode'horizontal' | 'axis''horizontal'Values upright, or turned along their ordinate
reactionLabels'values' | 'names''values'Reactions as they act, with their size; or, for an exercise, every restrained direction named (Ax, MA) and pointing the way it counts as positive. Names need no results: Reactions as unknowns
reserveLabelModesreadonly ResultLabelMode[]–Label modes to make room for besides the current one
reserveReactionLabelsreadonly ReactionLabels[]–Reaction label styles to make room for besides reactionLabels, so an exercise that turns into its solution keeps its drawing still
animatebooleantrueFade layers in and draw members on. Always off under prefers-reduced-motion.
hoverbooleanfalseRead values under the pointer, marked at each diagram's ordinate tip. Off, the plot takes no pointer input at all.
titlestringa description of what is shownAccessible name of the figure

Without layers, the result is M for beams and frames, N for a truss, and w when nothing carries a force (defaultResultLayer).

Events

EventPayloadWhen
readoutReadout | nullWith hover: the member point under the pointer and its results; null when it leaves
TypeScript
interface Readout {
  readonly member: string
  readonly x: number // m from the member's start node
  readonly px: number // the point on screen, px
  readonly py: number
  readonly values: Readonly<Record<'N' | 'V' | 'M' | 'w', SidedValue>> // SI units
  readonly u: number // displacement along the member's local x, m
}
interface SidedValue {
  readonly left: number
  readonly right: number // equal to left where the result is continuous
}

DiagramStack

TypeScript
import { DiagramStack } from '@edubeam/plot'

Draws a straight beam over its diagrams on one x axis. The members must form one horizontal line, drawn left to right; anything else throws. Guide: DiagramStack.

Props

PropTypeDefaultDescription
solverSolver–The solved beam
modelPlotModel–Or plain data from modelFromSolver; takes precedence
loadCasenumber0Index into solver.loadCases
revisionnumber0Change it to redraw a solver changed in place
membersreadonly string[]all membersThe members of the beam line
rowsreadonly StackRow[]['V', 'M', 'w']Diagram rows, top to bottom, of 'N', 'V', 'M', 'w'
loadRowbooleantrueThe beam with its supports, loads and reactions above the rows
rangesPartial<Record<StackRow, readonly [number, number]>>each row's ownValue range per row, SI units
rowHeightsPartial<Record<StackRow, number>>N 100, V 116, M 128, w 76; below 560 px wide 88, 96, 104, 64Row heights before maxHeight scales them
maxHeightnumber–Rows shrink, to 60 % at most, so the figure fits. Text keeps its size.
unitsPartial<Units>KN_UNITSDisplay units
numberFormatIntl.NumberFormatEnglish, at most 1 decimalFormats every number
colorsPartial<PlotColors>–Colour overrides
widthnumber720Width before the box is measured; at least 320 is used
fontSizenumber12.5Text size
hoverbooleantrueThe reading cursor. Off, the figure takes no pointer input.
loadAtnumber–Position (m along the line) of a point load the reader may drag; use with v-model:load-at
loadLabelstringP = … with the load's magnitudeText beside the draggable load
loadStepnumber0.05The drag rounds to this step, m; the arrow keys move by it
titlestringa description of the rowsAccessible name of the figure

Events

EventPayloadWhen
update:loadAtnumberThe reader moved the load: its new position, m. Drives v-model:load-at.
readoutStackReadout | nullThe cursor's values across the rows; null when the pointer leaves
TypeScript
interface StackReadout {
  readonly x: number // m along the beam line
  readonly values: Partial<Record<'N' | 'V' | 'M' | 'w', { readonly left: number; readonly right: number }>> // SI
}

The plugin

TypeScript
import { EduBeamPlot } from '@edubeam/plot'

app.use(EduBeamPlot) // registers <StructurePlot> and <DiagramStack> globally

It is optional: importing the components by name is lighter, and a bundler drops the plugin from a build that does not use it.

Types

For typed wrappers around the components, the package exports their props and events:

TypeScript
import type { PlotLayer, StructurePlotProps } from '@edubeam/plot'

const figure: StructurePlotProps = { layers: ['members', 'supports', 'M'] satisfies PlotLayer[], compact: true }
TypeIs
StructurePlotProps, StructurePlotEmitsThe props and events of StructurePlot
DiagramStackProps, DiagramStackEmitsThe props and events of DiagramStack
Readout, ReadoutQuantity, SidedValue, StackReadoutEvent payloads
PlotLayer, ResultLayer, ResultLabelMode, ReactionLabels, StackRowLayer, result, label mode, reaction label and row names
Units, Unit, UnitKindDisplay units: { symbol, scale } per kind
PlotColorsColours by tone
PlotModelThe plain model: Plot model

The remaining exports, structureSvg for SVG files and the functions behind the drawing among them, are in Functions.