A parameter is like a variable that can be used in functions. At its simpest, it consists of a name and a value:
The value of $a$ is ${params.a}.
The value of $b$ is ${params.b}.
`"Fundamentally, a parameter is a variable which the user can adjust, either via a slider or by manipulating something on the graph. The initial value of the parameter is determined by the value
attribute on the parameter definition; the range of the slider is determined by the min
and max
attributes. For example, this sets the initial value of a to 3, and sets it range to be between 0 and 10:
The value of $a$ is ${params.a}.
`" sidebar: controls: - title: Parameters sliders: - {param: a, label: a}By default, parameters are integers; you can change the precision of a by creating a round
command. Here, we round a to the nearest tenth:
The value of $a$ is ${params.a}.
`" sidebar: controls: - title: Rounding Parameters sliders: - {param: a, label: a}Drag the slider back and forth. Oh no! It displays badly. We can fix this by adding a .toFixed(1)
in the HTML:
The value of $a$ is ${params.a.toFixed(1)}.
`" sidebar: controls: - title: Nicely Rounding Parameters sliders: - {param: a, label: a}