Name
A KontrastName
holds a string value that is used as a
unique identifier of an object.
The name may contain normal characters (a-z, A-Z, 0-9), but must not contain a dot, colon, semicolon, hash or any white space character (space, tab, newline). The reason for this character limitation is that the name is also used as a CSS class selector, as described in the plot legend article.
Names must be unique; an error is thrown if you assign the same name to two objects of the equal type (two graphs, for example).
Usage
You can use the name
property to uniquely name objects,
such as figures, graphs and axes.
The name is used when connecting data (i.e. a number, an array of numbers, etc.) to specific axes using the data property. The axis is always identified by its name, which is usually the name of the corresponding quantity.
Another use case is the generation of CSS for plot legends within the HTML page: The name of the figure, graph and the plot itself are used to generate a unique class selector.
Descriptive names facilitate the navigation within the setup context menu, as the names are shown in the menu. Moreover, the names are used in the hover marker when hovering over data points.
Default values
If you do not specify a name upon the creation of a Kontrast object,
Kontrast generates a name automatically. The name usually consists of
the type (for example 'figure'
, 'graph'
,
'plot'
) and a number like 'figure0'
or
'graph2'
. The number starts at zero and is incremented
for each unnamed object.
Interface
Functions
-
assign(value: string)
Assign a new value. -
addEventListener(eventName: string, callback: function)
Registers the callback function as an event listener for the specified event name. -
clearEventListener(eventName: string)
Remove all event listener callbacks associated with the event name.
Properties
-
type
:string
The read-only string 'KontrastName'.
-
value
:string
The current value (as a JavaScript string).
Events
-
change
, callback:function () { … }
Event that fires whenever the value is changed.