Methods
-
get(params)
-
Gets a floating window instance.
If the
tag
parameter is provided, the function checks whether the document already contains a floating window with that tag. If so, the function parameters are stored as properties of the floating window object (see setProps), and a reference to the floating window is returned. Otherwise, the function returns a new floating window created with the provided parameters.Note: Tags can be used to manage floating windows in multi-chart documents. For more information, see the
tag
parameter of floatingWindowEventListener.Parameters:
Name Type Description params
object Floating window parameters.
Properties
Name Type Argument Description content
string The contents of the floating window, typically an HTML string.
container
HTMLElement <optional>
The DOM element that visually contains the floating window. The floating window is positioned on screen relative to the container element (see positionRelativeTo).
title
string <optional>
Text that appears in the title bar of the floating window.
tag
string <optional>
A label that identifies the floating window type; for example, "shortcut", which indicates that the floating window contains the chart keyboard shortcuts legend.
minWidth
number <optional>
The minimum width of the floating window.
minHeight
number <optional>
The minimum height of the floating window.
onClose
function <optional>
A callback function to execute when the floating window closes.
- Since:
-
8.2.0
Returns:
A DocWindow instance.
- Type
- object
-
bindEvents()
-
Adds event listeners to the floating window.
The listeners enable the window to be moved, resized, collapsed/expanded, and closed.
- Since:
-
8.2.0
-
clampX(value)
-
Helper function that constrains the floating window to the document view when the window is dragged horizontally.
Clamps the horizontal position of the floating window between 0 (so the window cannot be dragged off the left side of the view) and the width of the document view minus the width of the floating window (so the window cannot be dragged off the right side of the view).
Parameters:
Name Type Description value
number The position of the mouse relative to the left edge of the floating window.
- Since:
-
8.2.0
Returns:
The value for the clamped horizontal position of the floating window:
value
ifvalue
is greater than 0 and less than the width of the document view minus the width of the floating window- 0 if
value
is less than 0 - The width of the document view minus the width of the floating window if
value
is greater than the width of the document view minus the width of the floating window
- Type
- number
-
clampY(n)
-
Helper function that constrains the floating window to the document view when the window is dragged vertically.
Clamps the vertical position of the floating window between 0 (so the window cannot be dragged off the top of the view) and the height of the document view minus the height of the floating window title bar and a margin (so the window title bar cannot be dragged off the bottom of the view).
Parameters:
Name Type Description n
number The position of the mouse relative to the top edge of the floating window.
- Since:
-
8.2.0
Returns:
The value for the clamped vertical position of the floating window:
n
ifn
is greater than 0 and less than the height of the document view minus the height of the floating window title bar and margin- 0 if
n
is less than 0 - The height of the document view minus the height of the floating window title bar and
margin if
n
is greater than the height of the document view minus the height of the floating window title bar and margin
- Type
- number
-
ensureVisible()
-
Repositions the floating window (if necessary) when the display is resized to keep the window within the document view.
- Since:
-
8.2.0
-
onMouseMove(e)
-
The event listener for mouse move events that occur when a floating window is being dragged or resized.
Moves or resizes the floating window.
Parameters:
Name Type Description e
MouseEvent The mouse event object.
- Since:
-
8.2.0
-
onMouseUp()
-
The event listener for mouse up events that occur on a floating window.
Stops a dragging or resizing action of the floating window.
- Since:
-
8.2.0
-
onStartDrag(e)
-
The event listener for mouse down events that occur on the floating window's title bar.
The mouse down event starts a click-and-drag action on the floating window.
Parameters:
Name Type Description e
MouseEvent The mouse event object.
- Since:
-
8.2.0
-
positionRelativeTo(params)
-
Positions the floating window relative to the DOMRect of a DOM element.
Parameters:
Name Type Description params
object Positioning parameters.
Properties
Name Type Argument Default Description container
HTMLElement <optional>
The DOM element relative to which the floating window is positioned. Defaults to the
container
parameter of the floatingWindowEventListener or, if thecontainer
parameter is not available,document.body
.location
string <optional>
"center" The location of the floating window within the container element's bounding rectangle. If the value is "center" (the default), the floating window is centered horizontally and vertically within the container rectangle. Otherwise, the window is positioned in the upper left corner of the rectangle.
- Since:
-
8.2.0
-
setProps(params)
-
Stores the function parameters as properties of the floating window object.
Parameters:
Name Type Description params
object Parameters to store as properties.
Properties
Name Type Argument Description title
string <optional>
Text that appears in the title bar of the floating window.
content
string <optional>
The contents of the floating window, typically an HTML string.
container
HTMLElement <optional>
The DOM element that visually contains the floating window. The window is positioned on screen relative to the container element (see positionRelativeTo).
minWidth
number <optional>
The minimum width of the floating window.
minHeight
number <optional>
The minimum height of the floating window.
onClose
function <optional>
A callback function to execute when the floating windows closes.
- Since:
-
8.2.0
-
toggle( [value])
-
Opens and closes the floating window.
Parameters:
Name Type Argument Description value
boolean <optional>
If true, the floating window is opened. If false, the floating window is closed. If undefined, the floating window is toggled; that is, opened if it is currently closed, closed if it is currently open.
- Since:
-
8.2.0
-
toggleCollapse()
-
Toggles the display state — expanded or collapsed — of the floating window.
In the expanded state, the full floating window is displayed; in the collapsed state, only the floating window title bar appears.
- Since:
-
8.2.0
-
update(params)
-
Updates properties of the floating window.
Parameters:
Name Type Description params
object Floating window properties.
Properties
Name Type Argument Description x
number <optional>
The horizontal position of the floating window in pixels.
y
number <optional>
The vertical position of the floating window in pixels.
width
number <optional>
The width of the floating window in pixels.
height
number <optional>
The height of the floating window in pixels.
- Since:
-
8.2.0