Methods

This section describes the methods that can be used in code to manipulate the dxChart object.

Use the dxChart registered method to access the dxChart object, as demonstrated in the code below.

JavaScript
var chart = $("#chartContainer").dxChart("instance");

beginUpdate()

Prevents the widget from refreshing until the endUpdate method is called.

The beginUpdate and endUpdate methods allow you to apply several modifications to the widget at once. After the beginUpdate method is called, the widget does not rerender itself until the endUpdate method is called. The usage of these methods prevents excessive widget updating when changing multiple widget settings at once.

NOTE: It is recommended that you do not perform any actions on a widget within the updating transaction other than changing widget options.

clearSelection()

Deselects the chart's selected series. The series is displayed in an initial style.

To learn about series selection, refer to the Selection Handling help section.

Show Example:
jQuery

In this example, click a series to select it. Since the seriesSelectionMode is set to multiple, more than one series can be selected. To deselect all the series, click the Clear selected series button. The chart's clearSelection() method will be called.


                                    

                                    

endUpdate()

Enables the widget to refresh after the beginUpdate method call.

The beginUpdate and endUpdate methods allow you to apply several modifications to the widget at once. After the beginUpdate method is called, the widget does not rerender itself until the endUpdate method is called. The usage of these methods prevents excessive widget updating when changing multiple widget settings at once.

NOTE: It is recommended that you do not perform any actions on a widget within the updating transaction other than changing widget options.

getAllSeries()

Returns an array of all series in the chart.

Return Value: Array
The series from the chart's series collection.

Show Example:
jQuery

In this example, click the Display series names button to call the getAllSeries() method and display the name of each chart series.


                                    

                                    

getSeriesByName(seriesName)

Gets a series within the chart's series collection by the specified name (see the name option).

Parameters:
seriesName: String
The name of the series to be found.
Return Value: Object
The series that is found by the specified name.

If a series with the specified name is not found, the function returns null.

Show Example:
jQuery

Enter the name of a series in the textbox and click the Display maximum value button. The getSeriesByName(seriesName) method will be called and the maximum value in the series with the specified name will be shown. If a series with the entered name does not exist, the corresponding message will be displayed.


                                    

                                    

getSeriesByPos(seriesIndex)

Gets a series within the chart's series collection by its position number.

Parameters:
seriesIndex: Number
The index of the series to be found within the chart's series collection.
Return Value: Object
The series that is found by the specified position index.

Series in the chart's series collection are arranged as they are defined in the series array of the chart's configuration object. Note that the series are numbered from zero in the series collection.

Show Example:
jQuery

Choose an index of the series using the set of radio buttons below and click the Display maximum value button to call the getSeriesByPos(seriesIndex) method. The maximum value in the series with the specified index will be displayed.


                                    

                                    

hideLoadingIndicator()

Conceals the loading indicator.

Although the loading indicator hides automatically when a chart is ready, you can hide it from code at the required time using the hideLoadingIndicator() method.

To show the loading indicator, invoke the showLoadingIndicator() method.

Show Example:
jQuery

In this example, the chart options are assigned five seconds after the example is loaded. You can show/hide the loading indicator using the buttons under the chart. Note that the loading indicator can be displayed or concealed manually at any time no matter whether the chart is ready or not.


                                    

                                    

hideTooltip()

Hides all widget tooltips.

Use this method to hide all widget tooltips programmatically.

Show Example:
jQuery

In this example, you can show and hide tooltips using the corresponding buttons below. When clicking the Show next tooltip button, the showTooltip() method of the next point in the order will be called. When clicking the Hide all tooltips button, the chart's hideTooltip() method will be called. This method clears the chart plot from tooltips.


                                    

                                    

instance()

Returns an instance of the widget.

Return Value: Object
An instance of the widget.

Use this method to access the widget.

Show Example:
jQuery

In the following example, the instance() method is used to get access to the chart options. This method is called not like the other methods. To call the instance() method, the following construction is used:

$("#chartContainer").dxChart("instance")

Use the check box below to switch between the values of the commonAxisSettings | visible option.


                                    

                                    

option()

Returns the object representing the configuration options of the widget.

Return Value: Object
The object representing the configuration options of the widget.

Use the fields of the returned object to configure the widget.

Show Example:
jQuery

In this example, the option() method is used to obtain the value of the commonAxisSettings | visible option and display it under the chart. To change this value, use the check box below.


                                    

                                    

option(optionName)

Gets the value of the specified configuration option of the widget.

Parameters:
optionName: String
The name of the option to get.
Return Value: any
The value of the specified option.

To get the value of a configuration option, specify the path to the field representing this option in the configuration object. For example, pass the "tooltip.enabled" value as the optionName parameter to get the value of the tooltip | enabled option.

Show Example:
jQuery

In this example, the option(optionName) method is used to obtain the value of the tooltip | enabled option and display it under the chart. To change this value, use the check box below.


                                    

                                    

option(optionName, optionValue)

Sets a value to the specified configuration option of the widget.

Parameters:
optionName: String
The name of the required option.
optionValue: any
The value to be assigned to the required option.

To set a value to the configuration option, specify the path to the field representing this option in the configuration object. For example, to set the tooltip | enabled option to true, pass the "tooltip.enabled" value as the optionName parameter and the "true" value as the optionValue parameter.

Show Example:
jQuery

In this example, the option(optionName, optionValue) method is used to set the value of the tooltip | enabled option at runtime. To change this value, use the check box below.


                                    

                                    

option(options)

Sets one or more widget options.

Parameters:
options: Object
An object containing required configuration options.

To set one or more widget options, pass the object that contains fields representing these options as the options parameter.

This method is useful if you need to configure several widget options at once.

Show Example:
jQuery

In this example, the option(options) method is used to alter a set of options at once. To change the values of the tooltip | enabled and tooltip | arrowLength options, use the check box below.


                                    

                                    

render(renderOptions)

Redraws a widget.

Parameters:
renderOptions: Object
An object containing rerendering options.

By default, a widget rerenders when the size of the parent window is changed. But there may be situations when a chart must be rerendered manually, i.e., when the size of the chart's container is changed. To rerender a widget, use the render method.

Call the render method without a parameter after the size of the chart's container is changed. Alternatively, call the render method with an options object as the parameter. This object should contain the force field set to 'true'. In addition, you can use this object to specify whether or not to perform animation on rerendering with the animate field, and whether or not to rerender the chart in an asynchronous mode with the asyncSeriesRendering field.

The following code sample illustrates the example of the object to be passed as the renderOptions parameter.

JavaScript
var renderOptions = {
    force: true,
    animate: false,
    asyncSeriesRendering: false
}
Show Example:
jQuery

In this example, click the Enforce Rerendering button to call the render(renderOptions) method.


                                    

                                    

showLoadingIndicator()

Displays the loading indicator.

The loading indicator does not appear automatically. In order to display it, the showLoadingIndicator() method should be invoked.

To hide the loading indicator from code, use the hideLoadingIndicator() method.

Show Example:
jQuery

In this example, the showLoadingIndicator() method invokes when the example loads. Note that it is not necessary to conceal the loading indicator using the hideLoadingIndicator() method, since it executes automatically.


                                    

                                    

svg()

Returns the widget's SVG markup.

Return Value: String
The widget's SVG markup.

NOTE: This method does not support Internet Explorer 8.

Show Example:
jQuery

Click the Get SVG below the chart, and the SVG copy of this chart will appear.


                                    

                                    

zoomArgument(startValue, endValue)

Sets the specified start and end values for the chart's argument axis.

Parameters:
startValue: Number|Date
A new start value for the argument axis.
endValue: Number|Date
A new end value for the argument axis.

This function can be used when implementing zooming for your chart. If your chart is integrated with the dxRangeSelector widget, call the zoomArgument function when the range selector's selected range is changed. Pass the start and end values of the range selector's selected range as the corresponding parameters of the function.

When the chart's adjustOnZoom option is set to true, the maximum and minimum values of the chart's value axis are changed to correspond to the maximum and minimum values of the chart's series. This is required to remove the empty area in the chart that may appear when changing the maximum and minimum values of the argument axis. To prevent value axis adjustment in response to argument axis boundary changes, set the adjustOnZoom option to false.

Show Example:
jQuery

In this example, the dxRangeSelector widget interacts with the dxChart widget. Choose a range in the range selector to zoom the chart to this range. The zooming is performed using the chart's zoomArgument(startValue, endValue) method.