Optional
Readonly
eventsProtected
optionsStatic
optionsset angle
fill color
line color
line extension options
line style.
line width in pixels.
show distance
returns or sets the attribute of an option this function should be used with care - modifications of internal properties might break stuff!
Optional
v: anywill be called before methods are called that need to access x/y-coordinates can be overriden to set up the cache values needed in the other methods The meta parameter passed to the method includes a reason for the redraw, and potentially the indices of the updated values
Helper-method to clear the cache
must be called after willUpdateOptions
once all actions that might potentially changed values of any options are done
IMPORTANT: methods must be called in balance; e.g. for each call to willUpdateOptions
, you must call didUpdateOptions
exactly once.
draws the tool
the 2d canvas context
returns a flat representation of all available config options in the form of a key-value-object optionally only values that are not read-only can be returned
IMPORTANT: this method will always convert I18NStrings to strings, so for displaying strings in a UI use individual calls to Object:get instead
Optional
readWriteOnly: booleandefault: true
Optional
modifiedOnly: booleandefault: true
Optional
nonEphemeralOnly: booleandefault: true
returns the value of the requested option, or a list of all available config options if no parameter is specified.
Optional
s: stringOptional
flags: numberreturns the bounds of this tool in the specified range on the x-Axis currently only used to show/hide bound extension symbols - should probably be renamed
returns the tools chart
by implementing this methods tools can request a special mouse cursor
to use in combination with custom event handling (e.g. for different actions such as buttons)
the selection logic itself has to be implemented based on the values passed to handleEvents
which is always called with the most recent values before this method
desired cursor (all standard css cursors are supported) or null for default
returns the categorization of the objects options can be used for displaying a more structured user interface
returns index of handle at specified point, or null if none is in range
the x coordinate of the point
the y coordinate of the point
maximum distance to the point
returns the indices of the tools initially selected handles
Creates list of legend entry chunks to be displayed in the legend for the index pickerIndex
Optional
range: numberby implementing this methods tools can control the picker markers on the X- and Y-Axes that are shown when interacting with the tool should only be used in combination with custom event handling tools that are controlled via handles should not overwrite this method and stick to the default behaviour
desired picker dimensions
returns the objects current state
returns the style object
return a Translator instance
handle events
the original mouse or touch event
the event to be handled
Optional
button: numberthe pressed button
Optional
layerX: numberthe x-coordinate
Optional
layerY: numberthe y-coordinate
Optional
hovered: booleantool is hovered
Optional
editable: booleantool is currently editable
boolean indicating wether the event has been handled
Automatically toggles the EXPOSED flag on dependent options when a 'parent' option changes value.
For each entry in optionDependencies
, whenever the parent option
emits an optionChanged
event, its dependents (listed in dependentNames
)
will be exposed (flag added) if the new value === exposeWhen
, or
hidden (flag removed) otherwise.
Map where:
exposeWhen
: the boolean that triggers exposing the dependents or a function with the newValue for custom validationdependentNames
: array of dependent option names whose EXPOSED flag will be toggledclass Test extends ChartbreakerObject {
constructor() {
super();
this.registerOptionDependencyVisibility(new Map([
['showLine', { exposeWhen: true, dependentNames: ['lineColor', 'lineStyle'] }],
['advancedMode', { exposeWhen: false, dependentNames: ['simpleModeOnlyOption'] }],
['description'], { exposeWhen: (text) => !!text.length, ['fontSize', 'fontColor']}
]));
}
}
checks if the tool is (at least partly) visible in the current viewport range always return false if tool has not been assigned to a chart yet or if it has no valid bounds
Note: This method does NOT account for value of the "visible" option; e.g. if visible is set to false, but the tool WOULD be visible in the current viewport range, this method returns true!
life cycle method; called when the object should stop normal operation if objects have any pending subscriptions/requests, they should all be stopped here
the object is also responsible for clearing the loading flag from it's state if it is currently active failing to do so will trigger a fatal error
object might be started again afterwards (start) or destroyed (destroy) this is not known yet at this point
called after start or restart
Method that allows reading of values in an instance-specific cache Can be used to reduce the amount of necessary calculations (e.g. x/y-coordinates) by storing/retrieving them only when necessary Keys and values need to be defined in a type that will be passed to the parent Tool class
can be called to tell the object that it should recover from an error and resume will have no effect if no retryable error is currently associated with the object
will set validate and then set the specified option(s) to the provided value(s) after validation
NOTE: if multiple options are used, will return false if at least one value is not valid values are applied individually however, so one option might be set even if the value for another is invalid
Optional
v: anyOptional
flags: ObjectEFlagsProgramatically change the layout of the tool.
Handles are specified as an array of numbers, either in the format [timestamp, value], or [timestamp, offset, value]. The number and layout constraints of handles depends on the type of the tool being added. See the documentation of the respective tool class for detailed information.
updates the indices of the tools initially selected handles indices have to be valid (e.g. in range [0, #handles[)
by default EventEmitters will print a warning if more than 10 listeners are added for a particular event. This is a useful default which helps finding memory leaks. Obviously not all Emitters should be limited to 10. This function allows that limit to be increased. Set to zero for unlimited.
Sets the objName and objType of the Object reverts to the default ones if no arguments are given
Optional
objType: stringOptional
objName: stringReturns a string representation of an object.
will set validate value(s) for the specified option(s)
NOTE: if multiple options are used, will return false if at least one value is not valid
Optional
v: anyOptional
flags: ObjectEFlagsHelper method, must not be called directly Used for validating if a specified chart is suitable for placement of this tool instance
e.g. charts that require a reference OHLC input can check if one is available, and if it uses the correct aggregation, etc.
Helper method, must not be called directly. Used for validating new layouts provided to Tools.setHandles method
When implementing a custom tool, you can overwrite this function to validate specific constraints
This method is explicitly allowed to change options depending on provided layout.
when using custom getters/setters (via _get/_set) in options, the values of options can change
without .set being called - or there might not even be a setter for readonly options;
for example, if the getter simply returns the value of a member variable
this variable could be modified directly.
In this case, events such as optionChanged
would not be fired, and listeners would not be informed about the change.
To account for such cases, the methods willUpdateOptions
and didUpdateOptions
should be called directly BEFORE and AFTER
actions that might potentially change values of options.
the correct events will then automatically be triggered when calling didUpdateOptions
.
if the options that could change are known, they can be supplied via the optional parameter. This provides a small performance gain in most situations.
IMPORTANT: methods must be called in balance; e.g. for each call to willUpdateOptions
, you must call didUpdateOptions
exactly once.
Optional
options: string | string[]Method that allows storing of values in an instance-specific cache Can be used to reduce the amount of necessary calculations (e.g. x/y-coordinates) by storing/retrieving them only when necessary Keys and values need to be defined in a type that will be passed to the parent Tool class
Static
getStatic
guardStatic
listenerStatic
set
Description
Phantom data for type inference