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. After the beginUpdate method is called, the widget does not raise events, and does not rerender itself until the endUpdate method is called. Using these methods prevents excessive widget updates when changing multiple widget settings at once.

Show Example:
jQuery

In this example, the commonAxisSettings | visible and commonAxisSettings | grid | visible options can be changed using the buttons below the chart. To alter the values of these options, click the beginUpdate() button. The options will be changed but the chart will not be refreshed until you click the endUpdate() button.


                                    

                                    

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. After the beginUpdate method is called, the widget does not raise events, and does not rerender itself until the endUpdate method is called. Using these methods prevents excessive widget updates when changing multiple widget settings at once.

Show Example:
jQuery

In this example, the commonAxisSettings | visible and commonAxisSettings | grid | visible options can be changed using the buttons below the chart. To alter the values of these options, click the beginUpdate() button. The options will be changed but the chart will not be refreshed until you click the endUpdate() button.


                                    

                                    

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.


                                    

                                    

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:

<!--JavaScript -->$("#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 "commonAxisSettings.visible" value as the optionName parameter to get the value of the commonAxisSettings | visible option of the dxChart widget.

Show Example:
jQuery

In this example, the option(optionName) 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, 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 commonAxisSettings | visible option of the dxChart widget to true, pass the "commonAxisSettings.visible" 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 commonAxisSettings | visible option at runtime. To change this value, use the check box below.


                                    

                                    

option(options)

Sets one or more options of the widget.

Parameters:
options: Object

An object containing required configuration options.

To set one or more widget options, pass the object containing these options as the options parameter.

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

JavaScript
var newOptionsObject = {
    commonAxisSettings: {
        visible: true,
        grid: {
            visible: true
        }
    }
}

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 commonAxisSettings | visible and commonAxisSettings | grid | visible options, use the check box below.


                                    

                                    

render(renderOptions)

Making a widget rerender.

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 should be rerendered manually, i.e., when the size of the chart's container is changed. To make a widget rerender, 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 to perform animation on rerendering with the animate field, and whether 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.


                                    

                                    

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.