Back to Devexpress

HeatmapControl.SelectedItems Property

windowsforms-devexpress-dot-xtracharts-dot-heatmap-dot-heatmapcontrol-f2cb47a3.md

latest5.4 KB
Original Source

HeatmapControl.SelectedItems Property

Gets or sets heatmap cells or source objects that are used to create the selected cells.

Namespace : DevExpress.XtraCharts.Heatmap

Assembly : DevExpress.XtraCharts.v25.2.UI.dll

NuGet Package : DevExpress.Win.Charts

Declaration

csharp
[Browsable(false)]
public IList SelectedItems { get; }
vb
<Browsable(False)>
Public ReadOnly Property SelectedItems As IList

Property Value

TypeDescription
IList

A list of objects that store cell data.

|

Remarks

If the heatmap is bound to a data source, the SelectedItems property returns the data objects assigned to the selected cells. Otherwise, the selected cell objects are returned.

The following example shows how to use heatmap selected cell data as a source for another chart:

Run Demo: Selection

csharp
public HeatmapSelection() {
    InitializeComponent();
    List<ProductSale> data = LoadData();
    HeatmapDataAdapter.DataSource = data;
    HeatmapDataAdapter.XArgumentComparer = new OriginalOrderComparer();
    heatmapControl1.SelectedItems.Add(data[0]);
}
List<ProductSale> LoadData() {
    List<ProductSale> data = new List<ProductSale>();
    try {
        XDocument sales_xml = XDocument.Load(Utils.GetRelativePath("ProductSales.xml"));
        foreach (XElement monthSale in sales_xml.Root.Elements()) {
            string product = monthSale.Element("Product").Value;
            string month = monthSale.Element("Month").Value;
            List<DailySale> dailySales = new List<DailySale>();
            foreach (XElement daySale in monthSale.Elements("SalesByDay").Elements("DailySale")) {
                dailySales.Add(new DailySale() {
                    Product = product,
                    Date = Convert.ToDateTime(daySale.Element("Date").Value),
                    Revenue = Convert.ToDouble(daySale.Element("Revenue").Value)
                });
            }
            data.Add(new ProductSale() { SalesByDay = dailySales });
        }
    }
    catch {
    }
    return data;
}
void heatmapControl1_SelectedItemsChanged(object sender, XtraCharts.SelectedItemsChangedEventArgs e) {
    List<DailySale> list = new List<DailySale>();
    foreach (ProductSale item in heatmapControl1.SelectedItems)
        list.AddRange(item.SalesByDay);
    chartControl1.DataSource = list;
}
vb
Public Sub New()
    Me.InitializeComponent()
    Dim data As System.Collections.Generic.List(Of DevExpress.XtraTreeMap.Demos.ProductSale) = Me.LoadData()
    Me.HeatmapDataAdapter.DataSource = data
    Me.HeatmapDataAdapter.XArgumentComparer = New DevExpress.XtraTreeMap.Demos.OriginalOrderComparer()
    Me.heatmapControl1.SelectedItems.Add(data(0))
End Sub
Private Function LoadData() As List(Of DevExpress.XtraTreeMap.Demos.ProductSale)
    Dim data As System.Collections.Generic.List(Of DevExpress.XtraTreeMap.Demos.ProductSale) = New System.Collections.Generic.List(Of DevExpress.XtraTreeMap.Demos.ProductSale)()
    Try
        Dim sales_xml As System.Xml.Linq.XDocument = System.Xml.Linq.XDocument.Load(DevExpress.XtraTreeMap.Demos.Utils.GetRelativePath("ProductSales.xml"))
        For Each monthSale As System.Xml.Linq.XElement In sales_xml.Root.Elements()
            Dim product As String = monthSale.Element(CType(("Product"), System.Xml.Linq.XName)).Value
            Dim month As String = monthSale.Element(CType(("Month"), System.Xml.Linq.XName)).Value
            Dim dailySales As System.Collections.Generic.List(Of DevExpress.XtraTreeMap.Demos.DailySale) = New System.Collections.Generic.List(Of DevExpress.XtraTreeMap.Demos.DailySale)()
            For Each daySale As System.Xml.Linq.XElement In monthSale.Elements("SalesByDay").Elements("DailySale")
                dailySales.Add(New DevExpress.XtraTreeMap.Demos.DailySale() With {.Product = product, .[Date] = System.Convert.ToDateTime(daySale.Element(CType(("Date"), System.Xml.Linq.XName)).Value), .Reve
            Next

            data.Add(New DevExpress.XtraTreeMap.Demos.ProductSale() With {.SalesByDay = dailySales})
        Next
    Catch
    End Try
    Return data
End Function

Private Sub heatmapControl1_SelectedItemsChanged(ByVal sender As Object, ByVal e As DevExpress.XtraCharts.SelectedItemsChangedEventArgs)
    Dim list As System.Collections.Generic.List(Of DevExpress.XtraTreeMap.Demos.DailySale) = New System.Collections.Generic.List(Of DevExpress.XtraTreeMap.Demos.DailySale)()
    For Each item As DevExpress.XtraTreeMap.Demos.ProductSale In Me.heatmapControl1.SelectedItems
        list.AddRange(item.SalesByDay)
    Next
    Me.chartControl1.DataSource = list
End Sub

See Also

HeatmapControl Class

HeatmapControl Members

DevExpress.XtraCharts.Heatmap Namespace