Hi Jorge,
You can achieve this adding the below code snippet .
private void Button_Click(object sender, RoutedEventArgs e)
{
OlapDataManager olapDataManager = new OlapDataManager();
olapDataManager.ItemSource = pivotGrid1.ItemSource; //ProductSales.GetSalesData();
olapDataManager.SetCurrentReport(CurrentReport());
this.olapchart1.OlapDataManager = olapDataManager;
this.olapchart1.OlapDataManager.CurrentReport.ShowExpanders = false;
this.olapchart1.Legend.RowsCount = 1;
this.olapchart1.Legend.ColumnsCount = 10;
this.olapchart1.Legend.Visibility = System.Windows.Visibility.Visible;
}
private OlapReport CurrentReport()
{
OlapReport olapReport = new OlapReport();
// Specifying the Row Dimension Element
DimensionElement dimensionElementRow = new DimensionElement();
dimensionElementRow.Name = "Geography";
dimensionElementRow.Hierarchy = new HierarchyElement() { Name = "Product Hierarchy" };
dimensionElementRow.Hierarchy.LevelElements.Add(new LevelElement() { Name = "Product" });
dimensionElementRow.Hierarchy.LevelElements.Add(new LevelElement() { Name = "Date" });
// Specifying the Column Dimension Element
DimensionElement dimensionElementColumn = new DimensionElement();
dimensionElementColumn.Name = "Geography";
dimensionElementColumn.Hierarchy = new HierarchyElement() { Name = "Geography Hierarchy" };
dimensionElementColumn.Hierarchy.LevelElements.Add(new LevelElement() { Name = "Country" });
dimensionElementColumn.Hierarchy.LevelElements.Add(new LevelElement() { Name = "State" });
//Specifying the Summary Elements
SummaryElements summaries = new SummaryElements();
summaries.Add(new SummaryInfo { Column = "Quantity", Key = "Quantity", Type = Syncfusion.Olap.Reports.SummaryType.Sum });
summaries.Add(new SummaryInfo { Column = "Amount", Key = "Amount", Type = Syncfusion.Olap.Reports.SummaryType.Sum, FormatString = "{0:c}" });
// Adding the Row Elements
olapReport.SeriesElements.Add(summaries);
olapReport.SeriesElements.Add(dimensionElementRow);
// Adding the Column Elements
olapReport.CategoricalElements.Add(dimensionElementColumn);
return olapReport;
}
We have also prepared a simple sample based on your requirement .Please download the sample from the below link
BindChartfrom PivotGrid19330643.zip