Skip to content
Last updated

API / geotoolkit / plot / Plot / Plot

Class: Plot

plot.Plot.Plot

A plot with 2D rendering capabilities.<br> The plot requires a canvas to be passed in the options to render its content.<br> <br> The plot is internally structured as a SceneGraph, using Node.<br> Each node having a scene-transform transformation that will be applied at render time.<br> <br> The plot offers an autoupdate behavior that will check regularly if a render is required (using requestanimationframe if available, polling otherwise).<br> When this autoupdate lands, the plot will check if it is flagged as dirty.<br> If so, it will trigger a render phase.<br> This mechanism can be configured when instantiating the Plot or changed using the corresponding setters.<br> One could also temporarily suspend any rendering by calling suspendUpdate in order to apply large scale changes or simply force the plot to hibernate when not used/visible.<br> <br> If the autoupdate mechanism is not enabled, the client code is responsible of calling the update function to tell the plot that it should render itself.<br> <br>

Throws

if parameter canvasElement is not HTMLCanvasElement or HTML5 Canvas is not supported.

Hierarchy

Table of contents

Constructors
  • [new Plot(options)](/solutions/geotoolkit/GeoToolkit_JS/apis/classes/geotoolkit.plot.plot.plot.md#new plot(options))
Methods

Contents

Constructors

new Plot(options)

• new Plot(options?)

Creates plot

Parameters

Name Type Description
Optional optionsOptionsplot options

Overrides

EventDispatcher.constructor

Methods

dispose

▸ dispose(disposeRoot?): void

Disposes the plot and the associated resources.<br> This may also call dispose on the root node (see disposeRoot).<br> The plot should not be used/accessed anymore after this has been called.<br>

Parameters

Name Type Description
Optional disposeRootbooleanAlso dispose root node

Returns

void

Overrides

EventDispatcher.dispose


getAutoUpdateInterval

▸ getAutoUpdateInterval(): number

Returns the time interval for autoupdate mechanism.<br>

Returns

number

The time interval in ms


getBoundingClientRect

▸ getBoundingClientRect(): DOMRect

Returns the client rect for the plots container element as DOMRect.<br>

Returns

DOMRect

the client rect for the plots container element


getCanvas

▸ getCanvas(): HTMLCanvasElement | HTMLCanvasElement[]

Returns the canvas element or elements used by this plot

Returns

HTMLCanvasElement | HTMLCanvasElement[]

The canvas element


getClassName

▸ getClassName(): string

Returns

string

Inherited from

EventDispatcher.getClassName


getContainingElement

▸ getContainingElement(): HTMLElement

Returns the containing element for the plot<br> This is either the canvas element or the div element depending on the chosen functionality<br>

Returns

HTMLElement

The canvas width


getHeight

▸ getHeight(): number

Returns the containing element height in virtual pixels.<br> This returns the raw size given at initialization or through the setSize function.<br> It ignores any Browser zoom.<br>

Returns

number

The canvas height


getLineMeasure

▸ getLineMeasure(): LineMetrics

Returns line measure

Returns

LineMetrics

line measure


getRoot

▸ getRoot(): Node

Returns the root node of the scenegraph.<br>

Returns

Node

The root node


getTool

▸ getTool(): ToolsContainer

Returns root tool associated to plot

Returns

ToolsContainer


getWidth

▸ getWidth(): number

Returns the containing element width in virtual pixels.<br> This returns the raw size given at initialization or through the setSize function.<br> It ignores any Browser zoom.<br>

Returns

number

The canvas width


hasEventListener

▸ hasEventListener(type, callback?): boolean

Check if a list of event listeners for this type contains this listener

Parameters

Name Type Description
typestringtype of event or property
Optional callbackFunctionto be called, if null, check if any callback is registered

Returns

boolean

Inherited from

EventDispatcher.hasEventListener


isAutoUpdate

▸ isAutoUpdate(): boolean

Return true if auto update is enabled.<br>

Returns

boolean

The status of autoupdate


isDisposed

▸ isDisposed(): boolean

Returns whether this object has been disposed

Returns

boolean

Inherited from

EventDispatcher.isDisposed


isInfiniteAutoUpdate

▸ isInfiniteAutoUpdate(): boolean

Return true if infinite auto update is enabled.<br>

Returns

boolean

The status of infinite auto update


isSilent

▸ isSilent(): boolean

Return true if the event dispatcher doesn't notify any events

Returns

boolean

Inherited from

EventDispatcher.isSilent


notify

▸ notify<E&gt;(type, source, args?): Plot

Notify listeners

Type parameters

NameType
Eextends string

Parameters

Name Type Description
typeEevent types
sourcePlotof the event
Optional argsEventMap[E]arguments of the event

Returns

Plot

this

Overrides

EventDispatcher.notify


off

▸ off<E&gt;(type?, callback?): Plot

Detach listener on event. Calling .off() with no arguments removes all attached listeners. Calling .off(type) with no callback removes all attached listeners for specific type.

Type parameters

NameType
Eextends string

Parameters

Name Type Description
Optional typeEtype of the event
Optional callback(eventType: E, sender: Plot, args: EventMap[E]) => voidfunction to be called

Returns

Plot

this

Overrides

EventDispatcher.off


on

▸ on<E&gt;(type, callback, options?): Plot

Attach listener on event that will be called whenever the specified event is delivered to the target <p> If the callback function is already in the list of event listeners for this target, the function is not added a second time. </p> <p> If a particular anonymous function is in the list of event listeners registered for a certain target, and then later in the code, an identical anonymous function is given in an "on" call, the second function will also be added to the list of event listeners for that target. </p>

Type parameters

NameType
Eextends string

Parameters

Name Type Description
typeEtype of event or property
callback(eventType: E, sender: Plot, args: EventMap[E]) => voidto be called
Optional optionsOptionsoptions of subscription

Returns

Plot

this

Overrides

EventDispatcher.on


onResize

▸ onResize(): Plot

Forces a resize on the plot using its known width and height.<br>

Returns

Plot

this


resumeUpdate

▸ resumeUpdate(refresh?): Plot

Resumes plot update, allowing the update function of triggering a render.<br>

Parameters

Name Type Description
Optional refreshbooleanIf set to true, a render will be run immediately

Returns

Plot

this


setAutoSize

▸ setAutoSize(autoSize): Plot

Enable or disable autosize mechanism.<br> If enabled, this will let the Plot resize the associated canvas whenever the plot itself is resized.<br>

Parameters

Name Type Description
autoSizebooleanThe status of autosize

Returns

Plot

this


setAutoUpdate

▸ setAutoUpdate(enable, infinite?): Plot

Enables or disables auto update mechanism.<br> If auto update is enabled, whenever a node is invalidated it will trigger a Plot update/render.<br>

Parameters

Name Type Description
enablebooleanThe autoupdate status
Optional infinitebooleanEnables or disables infinite auto update mechanism.<br> if true, run timer or request animation frame in infinite loop overwise if node is invalidated it will trigger a Plot update/render. if false, browser pixel scale is not updated.

Returns

Plot

this


setAutoUpdateInterval

▸ setAutoUpdateInterval(interval?): Plot

Sets the time interval for autoupdate mechanism.<br> This will define the delay for polling the status of the Plot and trigger an update/render if necessary.<br>

Parameters

Name Type Description
Optional intervalnumberThe time interval in ms. window.requestAnimationFrame will be used if available and interval set to null.

Returns

Plot

this


setLineMeasure

▸ setLineMeasure(lineMeasure): Plot

Set line measure

Parameters

Name Type
lineMeasureLineMetrics | Options

Returns

Plot

this


setRoot

▸ setRoot(root): Plot

Sets the root node ot be the given node.<br>

Parameters

Name Type Description
rootNodeThe scenegraph root node

Returns

Plot

this


setSilent

▸ setSilent(bool): Plot

Set silent mode

Parameters

Name Type Description
boolbooleanflag to enable silent mode

Returns

Plot

this

Inherited from

EventDispatcher.setSilent


setSize

▸ setSize(width, height): Plot

Sets the plot size to the given dimensions.<br> This will also change the canvas size if autosize is enabled.<br> If autorootbounds is enabled, this will also update the bounds of the root node.<br>

Parameters

Name Type Description
widthnumberThe width of plot
heightnumberThe height of plot

Returns

Plot

this


setWatermark

▸ setWatermark(watermark): Plot

Sets watermark to have on a plot

Example

import {Text} from '@int/geotoolkit/scene/shapes/Text';
import {AnchorType} from '@int/geotoolkit/util/AnchorType';
const watermark = new Text({
'alignment': AnchorType.LeftBottom, // watermark position on the screen
'textstyle': {
'font': '60px sans-serif'
},
'text': 'My Watermark'
});
plot.setWatermark(watermark);

Parameters

Name Type Description
watermarkAnchoredShapewatermark shape

Returns

Plot

this


suspendUpdate

▸ suspendUpdate(): Plot

Suspends plot update, preventing the update function from triggering a render.<br>

Returns

Plot

this


update

▸ update(): Plot

Updates the plot, forcing a render.<br> This will be called automatically when the plot has been marked as dirty if the autoupdate is enabled.<br>

Returns

Plot

this


getClassName

▸ Static getClassName(): string

Returns

string

Inherited from

EventDispatcher.getClassName


getPlotByNode

▸ Static getPlotByNode(node): Plot

Get registered plot associated with node

Parameters

Name Type Description
nodeNodenode on plot

Returns

Plot

plot


setEnableDevTool

▸ Static setEnableDevTool(enabled): void

Enable/disable dev tool support

Parameters

Name Type Description
enabledbooleanTrue to enable dev tool support, false otherwise

Returns

void