How to Refresh a Data Series for One or More Chart Controls

Description

Multiple Chart controls can reference the same data series. When a Data series is refreshed, all charts that reference the data series are also updated.

Discussion

If a Chart control is based on a dynamic data series, the data series be refreshed using the {dialog.object}.refreshDataSeries method. The {dialog.object}.refreshDataSeries method makes an Ajax callback to update the specified data series. For example, the following updates a data series named 'Series1':

{dialog.object}.refreshDataSeries('Series1');

You can refresh multiple series by passing in each series into the {dialog.object}.refreshDataSeries method as a JavaScript array as shown below

{dialog.object}.refreshDataSeries(['Series1','Series2','Series3']);

If the data series is based on an Xbasic function, such as the one shown below, the {dialog.object}.refreshDataSeries method will execute the Xbasic function to recalculate the data series.

function seriesdata as c (e as p)
    if (variable_exists("e._state.seriesdata") = .f.) then
        seriesdata = <<%txt%
2|south
5|east
3|west
1|north
%txt%

        e._state.seriesdata = seriesdata
    else
        seriesdata = alltrim(e._state.seriesdata) + crlf() + "" + (10 * rand()) + "|" + rand_string(10)
        e._state.seriesdata = seriesdata
    end if
end function

When the application receives the updated data series, the UX Component refreshes all Chart controls based on the data series.

For more information about how to refresh data series for one or more Chart controls, watch the video below:

Refreshing a Data Series

Download Component

See Also