Menu
Kontrast provides a context menu which can be used by viewers of your interactive visualizations to access functions such as exporting the figure as a PNG image as well as capturing and restoring the view of a graph. Moreover, the menu provides version information and a reference of useful keyboard shortcuts.
The context menu can be accessed by the viewers of the page by right-clicking (or long-pressing when using a mobile, touch-only device) on a figure.
There is an additional setup
context menu that provides access
to all Kontrast objects (i.e. all sliders and all figures, graphs,
axes, plots, …) within the HTML page. Using the
setup
context menu, viewers of the page can interactively
change properties of the listed objects. Temporary changes using the
context menu do not persist a page reload.
The setup
context menu can be accessed via the (normal
)
context menu or by right-clicking a figure while holding either the
Shift or Alt keys.
Since the context menu is a single global object, you can explicitly
embed the context menu within the DOM structure of the HTML page. In
most cases, you might want to add the context menu directly as a child
to the document body, which can be achieved by calling the
appendToElement
property of the global
kontrast.menu
property after the page has been loaded
like this:
Even if the context menu is not explicitly attached to an
HTML element using appendToElement
, the menu is
automatically attached to the figure element in which it is accessed
by a user.
Interface
Functions
-
appendToElement(host: HTMLElement)
Append the menu to the specified element. -
show(x: number, y: number)
Show the menu at the specified position. -
hide()
Hide the menu.
Properties
-
type
:string
The read-only string
'KontrastMenu'
.