The global kontrast
object
When you load the Kontrast library by including
kontrast.js
in your web page, a single object will be
added to the global JavaScript scope named kontrast
. This
object serves as an entry point into the complete functionality of the
library. No other global variables are created or modified.
The kontrast
object is the parent object of all other
objects within Kontrast (please refer to the separate documentation
article on
object management within
Kontrast). Thereby, the global kontrast
object also gives
you command-line
access to all objects within your
visualizations by using, for example:
You can enter the above command in
the developer console and
thereby change the aspect ratio of the first graph
(graph0
) of the first figure (figure0
) in
the page. More information about object names can be found in the
documentation of the name
property.
Finally, the kontrast
object manages a
single context menu that allows access to all figures within
the page.
Interface
Functions
-
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. -
createFigure(options: object)
: KontrastFigureCreate a figure and set its properties according to the specified options. -
destroyFigure(name: string)
Destroy the figure specified by its name. -
createSlider(options: object)
: KontrastSliderCreate a slider and set its properties according to the specified options. -
destroySlider(name: string)
Destroy the slider specified by its name. -
parseExpression(options: object)
-
parseCSV(options: object)
-
generateRandomNumbers(options: object)
-
inverseDiscreteFourierTransform(options: object)
-
discreteFourierTransform(options: object)
-
integrateODE(options: object)
-
solveEquations(options: object)
-
generateHistogram(options: object)
-
fit(options: object)
-
getCaretPosition(element: HTMLElement)
This helper-function returns a number that represents the position of the caret in the element. -
setCaretPosition(element: HTMLElement, position: number)
This helper-function sets the current position within the element to the specified position. -
inspectDecimal(options: object)
-
formatDecimal(options: object)
Properties
-
figures
: Collection ofKontrastFigure
A collection of all figures within the document. The object keys are the names of the figures.
-
sliders
: Collection ofKontrastSlider
A collection of all sliders within the document. The object keys are the names of the sliders.
-
menu
:KontrastMenu
This property provides programmatic access to the context menu.
See also: Context menu
-
version
:string
The current version of Kontrast.
-
screenGamma
:KontrastNumber
(default value:2.2
)The gamma exponent of the screen. This value is only used in the
'gamma'
color compensation mode.See also: Color spaces
-
colorSpaceCompensation
:KontrastSelection
(default value:'sRGB'
, possible values:'none'
,'sRGB'
,'gamma'
)The compensation of the color space used when performing blending, interpolation and filtering of color and opacity data within the visualization.
See also: Color spaces
-
decimalSeparator
:KontrastSelection
(default value:'period'
, possible values:'period'
,'comma'
)The decimal separator used in sliders, axis ticks, and markers. Note that the Kontrast math parser and the Kontrast menu always use the decimal dot and never the comma in order to be consistent with the JavaScript notation.
-
printPixelSize
:KontrastNumber
(default value:2
)The pixel size used when rendering the figure for printing.
Events
-
load
, callback:function () { … }
This event is emitted once the document is ready (according to the'load'
event of the global window object) and Kontrast has finished its internal loading procedure. Note that you can only use Kontrast after this event has been emitted.