WebChartControl.SelectedItemsChanged Event
Occurs after chart items are selected.
Namespace: DevExpress.XtraCharts.Web
Assembly:
DevExpress.XtraCharts.v24.1.Web.dll
NuGet Package:
DevExpress.Web.Visualization
Declaration
public event SelectedItemsChangedEventHandler SelectedItemsChanged
Public Event SelectedItemsChanged As SelectedItemsChangedEventHandler
Event Data
The SelectedItemsChanged event's data class is SelectedItemsChangedEventArgs.
The following properties provide information specific to this event:
Property |
Description |
Action |
Gets an action which describes how the collection has been changed.
|
NewItems |
Provides access to a collection of new selected chart elements (series and series points) and business data objects if a Chart Control or a series is bound to a data source.
|
OldItems |
Provides access to previously selected chart elements (series and series points) and business data objects if a Chart Control or a series is bound to a data source.
|
Use the SelectedItemsChanged event to customize the WebChartControl when the chart items including business data objects (if the control is connected to a data source) are selected.
For instance, you can display only bar series which correspond to the selected pie segments:
<dx:WebChartControl ID="WebChartControlPie" EnableCallBacks="False" runat="server" Height="250px" Width="700px" CrosshairEnabled="False" RenderFormat="Svg"
ClientInstanceName="chartTotal" OnObjectSelected="WebChartControlPie_ObjectSelected" DataSourceID="chartDataSource1"
SelectionMode="Multiple" SeriesSelectionMode="Point" OnSelectedItemsChanged="WebChartControlPie_SelectedItemsChanged">
</dx:WebChartControl>
protected void WebChartControlPie_SelectedItemsChanged(object sender, SelectedItemsChangedEventArgs e) {
InitColorIndices();
paletteIndices = new List<int>();
IList selectedItems = WebChartControlPie.SelectedItems;
if (selectedItems == null || selectedItems.Count == 0)
WebChartControlBars.SeriesTemplate.FilterCriteria = null;
else {
List<CriteriaOperator> filters = new List<CriteriaOperator>();
HashSet<string> regions = new HashSet<string>();
foreach (DevAVDataItem dataItem in WebChartControlPie.SelectedItems) {
string region = dataItem.Region;
if (!regions.Contains(region)) {
filters.Add(new BinaryOperator(RegionDataMember, region, BinaryOperatorType.Equal));
paletteIndices.Add(colorIndices[region]);
regions.Add(region);
}
}
WebChartControlBars.SeriesTemplate.FilterCriteria = new GroupOperator(filters.ToArray()) { OperatorType = GroupOperatorType.Or };
}
}
Protected Sub WebChartControlPie_SelectedItemsChanged(ByVal sender As Object, ByVal e As SelectedItemsChangedEventArgs)
InitColorIndices()
paletteIndices = New List(Of Integer)()
Dim selectedItems As IList = WebChartControlPie.SelectedItems
If selectedItems Is Nothing OrElse selectedItems.Count = 0 Then
WebChartControlBars.SeriesTemplate.FilterCriteria = Nothing
Else
Dim filters As New List(Of CriteriaOperator)()
Dim regions As New HashSet(Of String)()
For Each dataItem As DevAVDataItem In WebChartControlPie.SelectedItems
Dim region As String = dataItem.Region
If Not regions.Contains(region) Then
filters.Add(New BinaryOperator(RegionDataMember, region, BinaryOperatorType.Equal))
paletteIndices.Add(colorIndices(region))
regions.Add(region)
End If
Next dataItem
WebChartControlBars.SeriesTemplate.FilterCriteria = New GroupOperator(filters.ToArray()) With {.OperatorType = GroupOperatorType.Or}
End If
End Sub
See Also