Syncronize a OlapChart with a PivotGrid
Hello,
I'm trying to syncronize a OlapChart with a PivotGrid, it's similar to OlapClient. This is my code to generate the OlapReport,it is executed when there are some change in the OlapGrid:
OlapReport LoadFromDataTableCollection()
{
OlapReport olapReport = new OlapReport();
olapReport.ShowExpanders = true;
olapReport.ShowEmptyColumnData = true;
olapReport.ShowEmptyRowData = true;
MeasureElements meansureElements = new MeasureElements();
DimensionElement dimensionElementColumn = new DimensionElement();
dimensionElementColumn.Name = "dimensionElementColumn";
dimensionElementColumn.Hierarchy = new HierarchyElement() { Name = "dimensionElementColumn" };
foreach (PivotItem item in this.PGDatos.PivotColumns)
{
string Nombre = item.FieldMappingName;
dimensionElementColumn.Hierarchy.LevelElements.Add(new LevelElement() { Name = Nombre, DimensionName = item.FieldHeader });
}
DimensionElement dimensionElementRow = new DimensionElement();
dimensionElementRow.Name = "dimensionElementRow";
dimensionElementRow.Hierarchy = new HierarchyElement() { Name = "dimensionElementRow" };
foreach (PivotItem item in this.PGDatos.PivotRows)
{
string Nombre = item.FieldMappingName;
dimensionElementRow.Hierarchy.LevelElements.Add(new LevelElement() { Name = Nombre, DimensionName = item.FieldHeader });
}
SummaryElements summaries = new SummaryElements();
foreach (PivotComputationInfo item in this.PGDatos.PivotCalculations)
{
string Nombre = item.FieldName;
SummaryInfo Sumary = new SummaryInfo { Column = Nombre, Key = Nombre, Type = Syncfusion.Olap.Reports.SummaryType.Sum };
summaries.Add(Sumary);
meansureElements.Elements.Add(new MeasureElement() { Name = item.FieldName + "MM" });
}
olapReport.SeriesElements.Add(summaries);
olapReport.SeriesElements.Add(dimensionElementRow);
olapReport.CategoricalElements.Add(dimensionElementColumn);
olapReport.CategoricalElements.Add(meansureElements);
return olapReport;
}
But that doesn't work right. How should be the code of the function to work properly?
Thanks!
I'm trying to syncronize a OlapChart with a PivotGrid, it's similar to OlapClient. This is my code to generate the OlapReport,it is executed when there are some change in the OlapGrid:
OlapReport LoadFromDataTableCollection()
{
OlapReport olapReport = new OlapReport();
olapReport.ShowExpanders = true;
olapReport.ShowEmptyColumnData = true;
olapReport.ShowEmptyRowData = true;
MeasureElements meansureElements = new MeasureElements();
DimensionElement dimensionElementColumn = new DimensionElement();
dimensionElementColumn.Name = "dimensionElementColumn";
dimensionElementColumn.Hierarchy = new HierarchyElement() { Name = "dimensionElementColumn" };
foreach (PivotItem item in this.PGDatos.PivotColumns)
{
string Nombre = item.FieldMappingName;
dimensionElementColumn.Hierarchy.LevelElements.Add(new LevelElement() { Name = Nombre, DimensionName = item.FieldHeader });
}
DimensionElement dimensionElementRow = new DimensionElement();
dimensionElementRow.Name = "dimensionElementRow";
dimensionElementRow.Hierarchy = new HierarchyElement() { Name = "dimensionElementRow" };
foreach (PivotItem item in this.PGDatos.PivotRows)
{
string Nombre = item.FieldMappingName;
dimensionElementRow.Hierarchy.LevelElements.Add(new LevelElement() { Name = Nombre, DimensionName = item.FieldHeader });
}
SummaryElements summaries = new SummaryElements();
foreach (PivotComputationInfo item in this.PGDatos.PivotCalculations)
{
string Nombre = item.FieldName;
SummaryInfo Sumary = new SummaryInfo { Column = Nombre, Key = Nombre, Type = Syncfusion.Olap.Reports.SummaryType.Sum };
summaries.Add(Sumary);
meansureElements.Elements.Add(new MeasureElement() { Name = item.FieldName + "MM" });
}
olapReport.SeriesElements.Add(summaries);
olapReport.SeriesElements.Add(dimensionElementRow);
olapReport.CategoricalElements.Add(dimensionElementColumn);
olapReport.CategoricalElements.Add(meansureElements);
return olapReport;
}
But that doesn't work right. How should be the code of the function to work properly?
Thanks!
SIGN IN To post a reply.
3 Replies
GA
Ganesan
Syncfusion Team
June 9, 2011 12:43 PM UTC
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
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
RH
R H Giri
August 1, 2012 01:45 PM UTC
Once I change the Pivot, by applying filters, the chart binding does not get refreshed. How to bind the chart so that the changes done by the user on the pivot are reflected on the Olap chart? is there a way to achieve this?
SK
Sabapathy K
Syncfusion Team
August 3, 2012 12:22 PM UTC
Hi Giri,
Thanks for your patience.
We have prepared a simple sample in that the OlapChart content refreshed with respect to filtering in PivotGrid. The following link is the sample for your reference,
http://www.syncfusion.com/downloads/Support/DirectTrac/97207/PivotGridwithOlapChart1485821129.zip
Please let us know, if you have any further concerns.
Regards,
Sabapathy.K
SIGN IN To post a reply.
- 3 Replies
- 4 Participants
-
JP Jorge Pampin
- Jun 8, 2011 03:29 PM UTC
- Aug 3, 2012 12:22 PM UTC