A two axis input with scaling, ticks, units and multiple handles.
Import and register the <xy-input>
custom element, upgrading any
instances already in the DOM:
import XYInput from 'literal/documentation/templates/xy-input.js';
The <xy-input>
element may now be written in your HTML:
<xy-input value="0 0, 0.2 0.4 step 0.4 1.5 exponential 0.6 1 linear 0.8 0 target 0.4" ymin="-0.5" ymax="2" yticks xmin="0" xmax="1.4" xticks>
Envelope
</xy-input>
xmin ="0"
Value at upper limit of fader. Can interpret string values with recognised
units, eg. "0dB"
or "200Hz"
, or numbers.
xmax ="1"
Value at upper limit of fader. Can interpret string values with recognised
units, eg. "0dB"
or "200Hz"
, or numbers.
ymin ="0"
Value at upper limit of fader. Can interpret string values with recognised
units, eg. "0dB"
or "200Hz"
, or numbers.
ymax ="1"
Value at upper limit of fader. Can interpret string values with recognised
units, eg. "0dB"
or "200Hz"
, or numbers.
xscale ="linear"
Scale on the x axis. This is the name of a transform to be applied over the x range of the fader travel. Possible values are:
"linear"
"pow-2"
"pow-3"
"pow-4"
"log"
"log-24dB"
"log-48dB"
"log-60dB"
"log-96dB"
yscale ="linear"
Scale on the y axis. This is the name of a transform to be applied over the y range of the fader travel. Possible values are:
"linear"
"pow-2"
"pow-3"
"pow-4"
"log"
"log-24dB"
"log-48dB"
"log-60dB"
"log-96dB"
xstep
Step is either:
"any"
(the default value)"tick"
. The values in the ticks
attribute are used as step valuesystep
Step is either:
"any"
(the default value)"tick"
. The values in the ticks
attribute are used as step valuesxticks
A space or comma separated list of values at which to display tick marks. Values may be listed with or without units, eg:
xticks="0 0.2 0.4 0.6 0.8 1"
xticks="-48dB -36dB -24dB -12dB 0dB"
yticks
A space or comma separated list of values at which to display tick marks. Values may be listed with or without units, eg:
yticks="0 0.2 0.4 0.6 0.8 1"
yticks="-48dB -36dB -24dB -12dB 0dB"
xdisplay
The units to display the value in. The output value and all ticks are displayed in this unit. Possible values are:
"dB"
– 0-1
is displayed as -∞dB
to 0dB
"Hz"
"bpm"
"s"
"semitone"
ydisplay
The units to display the value in. The output value and all ticks are displayed in this unit. Possible values are:
"dB"
– 0-1
is displayed as -∞dB
to 0dB
"Hz"
"bpm"
"s"
"semitone"
ordered
Boolean attribute. When set, data points may not overlap their neighbours, keeping the order of points on the x axis constant.
value ="0,0"
The initial value of the element. This is a series of space or comma
separated x,y
values such as:
value="0,0 1,0.5 2,0"
Values may also be given an optional label.
value="0,0 [First] 1,0 [Second] 2,0 [Last]"
An <xy-input>
supports WebAudio automation data. Labels must be one of
the types 'step'
, 'linear'
, 'exponential'
or 'target'
. The type
'target'
must be followed by a fourth parameter duration:
value="0,0 step 1,0 linear 2,0 target 0.2"
.xmin
Value at upper limit of fader. Can interpret string values with recognised
units, eg. "0dB"
or "200Hz"
, or numbers.
.xmax
Value at upper limit of fader. Can interpret string values with recognised
units, eg. "0dB"
or "200Hz"
, or numbers.
.ymin
Value at upper limit of fader. Can interpret string values with recognised
units, eg. "0dB"
or "200Hz"
, or numbers.
.ymax
Value at upper limit of fader. Can interpret string values with recognised
units, eg. "0dB"
or "200Hz"
, or numbers.
.value
The value of the element. Returns an array of objects representing each point in the input. The array is a live object. Objects mutate in response to handles being moved, and handles are moved if the objects are mutated.
When submitted as part of a form the array is serialised to a formdata parameters.
.data
The value of the element as an array of objects representing the values of the input. The array is ‘live’ – objects mutate in response to moved handles, and handles move when the object values are set.
"input"
Emitted from the element during the movement of an xy handle.
"change"
Emitted from the element when an xy handle has been moved.
--line-color
Colour of axis lines drawn on the graph background.
--line-color-x
Colour of vertical x-axis lines drawn on the graph background.
--line-color-y
Colour of horizontal y-axis lines drawn on the graph background.
--envelope-color
Colour of envelope plot. The envelope is rendered in WebAudio, and is an accurate reflection of a WebAudio automation curve.
--crosshair-color
Colour of crosshairs. Defaults to none
.
Support development: Sponsor
github.com/stephband/form-elements
github.com/stephband/form-elements/issues
Built by Stephen Band for Cruncher.
Documentation set in Euclid
and Martian Mono. Fonts
used for documentation not included as part of the license covering the
use of xy-input
.