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


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.


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':


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


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%

        e._state.seriesdata = seriesdata
        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