We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Syncronize a OlapChart with a PivotGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

99745 Jun 8,2011 11:29 AM Aug 3,2012 08:22 AM WPF 3
loading
Tags: OlapChart
Jorge Pampin
Asked On June 8, 2011 11:29 AM

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!


Ganesan [Syncfusion]
Replied On June 9, 2011 08:43 AM

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



R H Giri
Replied On August 1, 2012 09:45 AM

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?


Sabapathy K  [Syncfusion]
Replied On August 3, 2012 08:22 AM

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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;