Skip to main content

BootstrapChartAggregationSettings.OnCalculate Property

Specifies a client function performing custom aggregation. Applies only if the BootstrapChartAggregationSettings.Method property is set to “custom“.

Namespace: DevExpress.Web.Bootstrap

Assembly: DevExpress.Web.Bootstrap.v24.1.dll

NuGet Package: DevExpress.Web.Bootstrap

Declaration

[DefaultValue("")]
public string OnCalculate { get; set; }

Property Value

Type Default Description
String String.Empty

A string that represents either the name of a JavaScript function or the entire JavaScript function code.

Property Paths

You can access this nested property as listed below:

Object Type Path to OnCalculate
BootstrapChartSeriesBase
.Aggregation .OnCalculate

Remarks

When implementing a custom aggregate function, use the aggregationInfo client-side object that is passed to it as the first argument. In addition, you can access the series object, which is passed to the function as the second argument.

The function below implements the median filter algorithm for custom aggregation:

<script type="text/javascript">
    function aggregationMethod(aggregationInfo, series) {
        if(aggregationInfo.data.length) {
            return {
                argument: aggregationInfo.intervalStart,
                value: aggregationInfo.data[Math.floor(aggregationInfo.data.length / 2)].value
            };
        }
    }
</script>

<dx:BootstrapChart runat="server"  DataSourceUrl="dataSourceUrl">
    <SeriesCollection>
        <dx:BootstrapChartBarSeries>
            <Aggregation OnCalculate="aggregationMethod" Method="Custom" Enabled="true" />
        </dx:BootstrapChartBarSeries>
    </SeriesCollection>
</dx:BootstrapChart>
See Also