Skip to main content

PivotGridOptionsChartDataSource Class

Contains options controlling the display of the PivotGrid’s data in a ChartControl.

Namespace: DevExpress.XtraPivotGrid

Assembly: DevExpress.PivotGrid.v24.1.Core.dll

NuGet Packages: DevExpress.PivotGrid.Core, DevExpress.Win.Navigation

Declaration

public class PivotGridOptionsChartDataSource :
    PivotGridOptionsChartDataSourceBase

Remarks

A PivotGrid control’s data can be visualized in a ChartControl. Use the PivotGridControl.OptionsChartDataSource property to access the options controlling the display of data in a chart control.

The main options provided by the PivotGridOptionsChartDataSource class are:

To display a PivotGrid’s data in a chart control, set the chart control’s properties as follows:

  1. the DataSource property to the PivotGrid object;
  2. the SeriesDataMember property to the “Series” string;
  3. the SeriesTemplate.ArgumentDataMember property to the “Arguments” string;
  4. to the SeriesTemplate.ValueDataMembers collection add an array containing the “Values” string;

Example

The following code shows how to display a Pivot Grid Control’s data in a ChartControl.

If the PivotGridOptionsChartDataSourceBase.ProvideDataByColumns property is set to true, series in the chart control are created based on PivotGrid columns:

Pivot_Chart_ex_ChartDataVertical_True

If the PivotGridOptionsChartDataSourceBase.ProvideDataByColumns property is set to false, series in the chart control are created based on PivotGrid rows:

Pivot_Chart_ex_ChartDataVertical_False

using DevExpress.XtraCharts;

chartControl1.DataSource = pivotGridControl1;
chartControl1.SeriesDataMember = "Series";
chartControl1.SeriesTemplate.ArgumentDataMember = "Arguments";
chartControl1.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "Values" });
// Format display values.
chartControl1.SeriesTemplate.PointOptions.ValueNumericOptions.Format = NumericFormat.Currency;
chartControl1.SeriesTemplate.PointOptions.ValueNumericOptions.Precision = 0;

pivotGridControl1.OptionsChartDataSource.ProvideDataByColumns = true;
//see image 1
//...
pivotGridControl1.OptionsChartDataSource.ProvideDataByColumns = false;
//see image 2
//...
See Also