Skip to main content

BubbleSeries.Data Property

Gets or sets the series data.

Namespace: DevExpress.XamarinForms.Charts

Assembly: DevExpress.XamarinForms.Charts.dll

NuGet Package: DevExpress.XamarinForms.Charts

Declaration

public IXYSeriesData Data { get; set; }

Property Value

Type Description
IXYSeriesData

An object that provides data for the series.

Remarks

To provide data for the bubble series, set the BubbleSeries.Data property to the SeriesDataAdapter class instance. Use the adapter’s properties to specify the data source for the series, and to define the data source members used to generate series points and labels. This series type requires 1 argument and 2 values (value and weight) for a data point.

You can also create a custom data adapter to populate the series with data. For example, it can be useful when data is generated on the fly and you don’t need to store it.

<ContentPage.BindingContext>
    <local:MainViewModel/>
</ContentPage.BindingContext>
<dxc:ChartView>
    <dxc:ChartView.Series>
        <dxc:BubbleSeries ColorEach="true">
            <dxc:BubbleSeries.Data>
                <dxc:SeriesDataAdapter DataSource="{Binding HighestGrossingFilmsByYearData}" ArgumentDataMember="Date">
                    <dxc:ValueDataMember Type="Value" Member="Value" />
                    <dxc:ValueDataMember Type="Weight" Member="WorldwideGrosses" />
                </dxc:SeriesDataAdapter>
            </dxc:BubbleSeries.Data>
        </dxc:BubbleSeries>
    </dxc:ChartView.Series>
</dxc:ChartView>
Show View Model
public class MainViewModel {
   public List<FilmData> HighestGrossingFilmsByYearData { get; }

   public MainViewModel() {
       HighestGrossingFilmsByYearData = new List<FilmData> {
           new FilmData(new DateTime(2007, 1, 1), "Pirates of the Caribbean: At World's End", 300D, 0.963),
           new FilmData(new DateTime(2008, 1, 1), "The Dark Knight", 185D, 1.004),
           new FilmData(new DateTime(2009, 1, 1), "Avatar", 237D, 2.788),
           new FilmData(new DateTime(2010, 1, 1), "Toy Story 3", 200D, 1.067),
           new FilmData(new DateTime(2011, 1, 1), "Harry Potter and the Deathly Hallows Part 2", 250D, 1.341),
           new FilmData(new DateTime(2012, 1, 1), "Marvel's The Avengers", 220D, 1.519),
           new FilmData(new DateTime(2013, 1, 1), "Frozen", 150D, 1.276),
           new FilmData(new DateTime(2014, 1, 1), "Transformers: Age of Extinction", 210D, 1.104),
           new FilmData(new DateTime(2015, 1, 1), "Star Wars: The Force Awakens", 245D, 2.068),
           new FilmData(new DateTime(2016, 1, 1), "Captain America: Civil War", 250D, 1.153),
       };
   }
}

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;
   }
}

Bubble Series Data

Important

ChartView chooses the X-axis type depending on data in the first series. If you specify the axis X for the chart or an individual series, set the ChartView.AxisX or Series.AxisX property to an object that is compatible with the series’ data type (otherwise, the chart does not display the series).

See Also