-
Notifications
You must be signed in to change notification settings - Fork 3
Selection Api
Clears the selection.
-
id
is anentityId
Adds object specified by id
to the selection. id
is an ID of a drawing or a study. If the object does not exist, then an error is thrown.
-
ids
is an array ofentityId
Adds objects specified by ids
to the selection. ids
is an array of drawings or studies IDs. If any of the objects does not exist, an error is thrown.
-
id
is anentityId
Clears current selection and selects an object specified by. set(id)
is the same as clear();add(id)
. If the object is does not exist, an error is thrown.
-
ids
is an array ofentityId
Clears current selection and selects objects specified by ids
. ids
is an array of drawings or studies IDs. set(ids)
is the same as clear();add(ids)
. If any of the objects does not exist, an error is thrown.
-
id
is anentityId
Removes specified object from selection. id
is an identifier of a drawing or a study. If the object is not selected, then this method does nothing. If the object does not exist, then an error is thrown.
-
ids
is an array ofentityId
Removes specified objects from the selection. ids
is an array of drawings identifiers. If any of the specified objects is not selected, then it is skipped by this method. If any of the objects does not exist, then an error is thrown.
-
id
is anentityId
Checks if specified object is selected. id
is an identifier of a drawing or a study. Returns false
if the object is not selected. If the object does not exist, then an error is thrown.
Returns an array of identifiers of the selected objects.
Checks if the selection is empty. It returns true
if there is no selected objects on the chart.
Returns a Subscription object that can be used to subscribe to the selection changes.
Multiple selection:
Multiple selection works for shapes only using the following rules:
- If you add a study to the selection, then it clears the selection and selects the study.
- If you add a shape to the selection when the currently selected object is a study, then it clears the selection and selects the shape.
- If you add an array of objects to the selection, it works as if you add these objects one by one.
Example:
var chart = tvWidget.activeChart();
chart.selection().onChanged().subscribe(null, s => console.log(chart.selection().allSources())); // it will print all selection changes to the console
var studyId = chart.createStudy("Moving Average", false, false, { length: 10 }); // create a study and save its id
chart.selection().add(studyId); // add the study to the selection ([<id>] is printed to the console)
chart.selection().clear(); // clear the selection ([] is printed to the console)
API Reference
Customisation by areas
- Global
- Toolbars
- Chart
- Symbol Search
- Legend
- Price Scale
- Time Scale
- Marks
- Indicators
- Snapshots
- Drawings
- Watchlist
- News
Creating Custom Studies