OMD Documentation

OMD Objects Reference (Verified)

This file documents the high-level JSON shapes accepted by the OMD classes and the low-level Class().loadFromJSON(data) APIs for each OMD visual. All shapes were verified against the code in src/.

Usage

Notes


COMMON: Expression / Terms / Number / Variable / Operator

Expression objects appear in several places; there are two common forms used across the codebase:

  1. Compact expression string
  1. Structured expression (preferred for programmatic usage)

{
// either a high-level expression object (terms) or the parsed low-level form
// Low-level parser output used in the codebase is termsAndOpers
"termsAndOpers": [
{ "omdType": "term", "coefficient": number, "variable"?: string, "exponent"?: number },
{ "omdType": "number", "value": number },
{ "omdType": "variable", "name": string },
{ "omdType": "operator", "operator": "+"|"-"|"/"|"÷"|"x"|"*"|"•"|"×"|"=" }
]
}

Legacy/alternate simple structured form used in some places (terms array):
{
"terms": [ { "coefficient"?: number, "variable"?: string, "value"?: number } ]
}

Primitive pieces

Examples


SPECIFIC OBJECTS (by omdType / class)

-- omd (root container)

shapes (in omdShapes.js)

spinner / omdSpinner

table / omdTable

problem / omdProblem


Examples (call loadFromJSON on instances)

  1. Equation (string form)
const eq = new omdEquation();
eq.loadFromJSON({ omdType: 'equation', equation: '2x + 3 = 11' });
  1. Coordinate plane with a function
const plane = new omdCoordinatePlane();
plane.loadFromJSON({
  omdType: 'coordinatePlane',
  xMin: -10, xMax: 10,
  yMin: -10, yMax: 10,
  graphEquations: [{ equation: 'y = x^2 - 4', color: '#e11d48', strokeWidth: 2 }]
});
  1. Tape diagram (values)
const tape = new omdTapeDiagram();
tape.loadFromJSON({ omdType: 'tapeDiagram', values: [1,2,3], unitWidth: 30, labelSet: [{ omdType: 'omdTapeLabel', startIndex: 0, endIndex: 3, label: '6', showBelow: true }] });
  1. Number tile
const tile = new omdNumberTile();
tile.loadFromJSON({ omdType: 'numberTile', value: 8, size: 'medium', dotsPerColumn: 10 });

Appendix / Implementation notes

If you want, I can:

↑ Top