Reading computed values in prose

A number the canvas computes is read from the construct with a {{…}} expression rather than typed into the prose.

#Computed numbers in prose

A number produced by a fit, an integral, a curve or a parameter is read from the construct rather than typed into the prose. A typed number is correct at the moment it was read off the screen and at no other: any edit to the data, change of model, or movement of a slider leaves the sentence asserting what the adjacent picture contradicts.

#Reading one in prose

With a {{…}} expression naming the construct and the member. It works the same in prose and in any rich-text attribute, so a sentence and a mark's own label quote the same number:

Right now $k$ is {{#k.value}}, and the band holds
{{round(100 * #band.value, 1)}}% of the distribution.

The expression does the arithmetic, and the text functions do the rest of the shaping — !format:comma{ {{#n.value}} } for separators. In attribute position a reference is written bare only where the attribute's declared type is reference (fit(of: #points)); in a rich-text one it is the group again. Derived attributes lists what each construct publishes.

#Why the compiler cannot freeze one

Reading a value that moves at render time makes the surrounding expression bound: the compiler evaluates everything else in it and ships the rest as a tree, evaluated by the renderer every frame — which is what keeps a live number from ever being frozen into a sentence that would later contradict the picture beside it.

The fitted slope is {{#f.slope}}.

A dataset column reads plainly, with no such deferral, because a dataset is immutable: nothing can replace it and no cell depends on a varying value, so there is nothing for the expression to wait on.

#Rounding a live number

  • A bare reading shows about four significant figures. Too many read as spurious precision; too few print two distinct quantities identically, so a number worth quoting is usually worth rounding — {{round(#f.slope, 2)}}.
  • Round for the claim being made, not for the width of the number: a slope quoted to two decimals asserts that the second decimal means something.
  • A live value and a typed approximation in one sentence — about 0.34 beside the reading itself — reproduce the disagreement the mechanism prevents.

What the canvas does not compute is covered in Checking a document's claims.