DataSourceKey.DataObject Property
Gets an object that represents a record in the chart underlying data source.
Namespace: DevExpress.Maui.Charts
Assembly: DevExpress.Maui.Charts.dll
NuGet Package: DevExpress.Maui.Charts
Declaration
public object DataObject { get; }
Property Value
Type | Description |
---|---|
System.Object | An object that represents a data source record. |
Example
In this example, a hint with preset options appears when a user taps a bubble.
Use the FilmData object collection as the data source for the chart to show the highest grossing films as bubbles.
using System; using System.Collections.Generic; namespace BubbleChartExample.Data { public class FilmData { public DateTime Date { get; private set; } public string Name { get; private set; } public double Value { get; private set; } public double WorldwideGrosses { get; private set; } public FilmData(DateTime date, string name, double value, double worldwideGrosses) { Date = date; Name = name; Value = value; WorldwideGrosses = worldwideGrosses; } } }
Subscribe to the SelectionChanged event and enable hints for the chart.
<dxc:ChartView x:Name="bubbleChart" SelectionKind="Point" SelectionMode="Single" SelectionChanged="OnBubbleSelectionChanged" > <dxc:ChartView.Hint> <dxc:Hint Enabled="True" ShowMode="OnTap"/> </dxc:ChartView.Hint> </dxc:ChartView>
In the event handler, use the
DataSourceKey.DataObject
property to access an object that corresponds with the selected bubble and cast it to the type of the data source object (FilmData). Call the ShowHint method to show a hint for the selected bubble and specify the tooltip text pattern.using BubbleChartExample.Data; using DevExpress.Maui.Charts; using Microsoft.Maui.Controls; // … void OnBubbleSelectionChanged(object sender, DevExpress.Maui.Charts.SelectionChangedEventArgs e) { if (e.SelectedObjects.Count > 0 && e.SelectedObjects[0] is DataSourceKey dataSourceKey) { if (dataSourceKey.DataObject is FilmData bubbleDataObject) { bubbleSeries.HintOptions = new SeriesHintOptions(); bubbleSeries.HintOptions.PointTextPattern = bubbleDataObject.Name + "\nProduction budget: {V$$#M}\nWorldwide grosses: {W$$#.##B}"; bubbleChart.ShowHint(0, dataSourceKey.Index); } } }