- Since:
-
- 9.4.0 Introduced
- 10.1.0 Added
rangeValueproperty to button, sourced fromvaluebutton parameter. Added built-in action for pressing a range button.
Members
-
<readonly> name :string
-
Button name.
Type:
- string
- Since:
-
9.4.0
-
<readonly> qc :CompactChart
-
CompactChart instance to which this button belongs.
Type:
- Since:
-
10.1.0
Methods
-
press()
-
Forcibly "presses" a button even if it is not currently visible. This is useful when external UI is created to replicate the internal button functionality. The button must exist for this function to work.
- Since:
-
10.1.0
Example
Switch to a bar chart:
cc.buttons.bar.press(); -
setActive()
-
For a group of buttons that act as radios (only one button in the group can be active at one time), this function will show the instance's button as active while deactivating the rest of the buttons in the group. Note this does not actually perform the button's action.
- Since:
-
- 9.4.0 Introduced
- 10.1.0 removed
qcparameter
Example
Toggle a custom theme:
cc.setTheme("myTheme"); myButton.setActive(); // in the process deactivate any other theme buttons. -
toggleActive(value)
-
For a single button, will activate the button if deactivated, or will deactivate if activated, Note this does not actually perform the button's action.
Parameters:
Name Type Description valueboolean New state of button.
- Since:
-
9.4.0
Example
Turn on custom functionality when a button is pressed:
doAction(...); myButton.toggleActive(true);
Type Definitions
-
ButtonConfig
-
Configuration settings for a single button. Note that the Periodicity settings this type extends are optional.
Type:
- Since:
-
9.4.0
Properties:
Name Type Argument Description groupstring <optional>
For a menu button, set to "main" to indicate top level, otherwise set to the button name of parent menu.
useIconboolean <optional>
trueto place image defined in css for content of button.labelstring <optional>
Text to place within a button. May contain html markup. This text will not appear if useIcon is set to true and an icon is found. If this is not set the text to use in the button will be the same as the button name.
readerstring <optional>
Text to be read by a screen reader when button is in focus.
rolestring <optional>
Usually the button has a checkbox role, but the role can be changed to "radio" with this property.
togglesstring <optional>
If the button toggles a layout setting, set this property to the layout property being set.
actionButtonConfigVoidFunction <optional>
For custom defined buttons, fired when button is pressed. Function has access to the compact chart object and to the button.
escapeButtonConfigVoidFunction <optional>
Used to custom-define an action to be performed when button has focus and the Escape key is pressed. Function has access to the compact chart object and to the button.
shouldShowButtonConfigBooleanFunction <optional>
Used to custom-define whether a button is visible under certain conditions. Function has access to the compact chart object and to the button.
isActiveButtonConfigBooleanFunction <optional>
Used to custom-define whether the button should show an indication of being active (on) or not. Function returns a boolean. Function has access to the compact chart object and to the button.
topLevelboolean <optional>
Indicates a top level menu item. A button with group set to "main" is automatically a top level menu item. Buttons belonging to a group and not a top level item are considered sub-menu items and are accessible only from its group's button.
chartScalestring <optional>
Used in a button that changes the y-axis scaling to indicate the scaling method.
valueArray <optional>
Used in a span button to configure what range the button will set the chart to. For example, to set a value of a 5 day span using 1 hour bars, use value:
[5, "day", 30, 2, "minute"]. For a three-month range with a daily periodicity, only two array elements are required:value: [3, "month"].Elements
Index Type Argument Description 0number Period of range.
1string Units of range.
2number <optional>
Interval of bars to fetch.
3number <optional>
Period of bars to fetch.
4TimeUnit <optional>
Timeunit of bars to fetch.
-
ButtonConfigBooleanFunction(qc)
-
Function used for buttons (ButtonConfig) that returns a boolean. The
thisparameter can be used within the function to refer to the button calling the function.Parameters:
Name Type Description qcCompactChart Compact chart instance.
- Since:
-
9.4.0
Returns:
Result of function.
- Type
- boolean
-
ButtonConfigVoidFunction(qc)
-
Function used for buttons (ButtonConfig) that returns a void. The
thisparameter can be used within the function to refer to the button calling the function.Parameters:
Name Type Description qcCompactChart Compact chart instance.
- Since:
-
9.4.0
-
ButtonsConfig
-
UI menu buttons configuration. Configures the UI buttons that appear on the chart to control various features. The buttons can exist in a hierarchy resembling menus and submenus. Some buttons have their functionality defined within the application, while others can be customized by you. In order to use buttons, you must also include the interaction feature, as it is a "plugin" of interaction. Buttons emit custom events that you can listen to. They propagate up the DOM tree, so you can add an event listener to the chart container to catch them. The event type is "chartiq".
Type:
- Since:
-
9.4.0
Properties:
Name Type Argument Description exportstring <optional>
Name of the exported class, usually "Button".
backgroundColorstring <optional>
Color for the background of the buttton
colorstring <optional>
Color for the text of the button
borderColorstring <optional>
Color for the border of the button
typesRecord.<string, ButtonConfig> <optional>
Collection of buttons represented as objects, where the key is the button name and the value is the configuration object.
-
MenuState
-
Menu state.
Type:
- object
- Since:
-
9.4.0
Properties:
Name Type Argument Description lastStatestring <optional>
Hash of menu layout.
mainstring <optional>
Name of parent menu item of item selected.
overboolean <optional>
Hover state of menu item.
showingstring <optional>
Name of menu item currently selected.
