My Solution,. binding ChartSpace to PivotTable in c#

S

scott

After many hours I have finnaly got this to work, I still
have not found a good solution on the web so I will post
mine


MSScriptControl.ScriptControlClass sc = new
MSScriptControl.ScriptControlClass();
sc.Language
= "javascript";
string script
= "cs.Clear();cs.DataSource = pvt;";

OWC10.ChartSpaceClass cs = new ChartSpaceClass();
sc.AddObject
("pvt",pTable,true);
sc.AddObject
("cs",cs,true);
sc.Eval(script);

Simple. I create a script language object, Bind the
chartspace source to pivotTable and thats it

When I call ExportPicture, I actually get a populated
chart :>
 
A

Alvin Bruney [MVP]

Let's examine the code to load data from a pivot table




Figure 4.12 Sample code to bind to a pivot table




C# snippet




ChartSpace1.DataSource = PivotTable1

SetData(ChartDimensionsEnum.chDimCategories,
(int)ChartSpecialDataSourcesEnum.chDataBound,
PivotTable1.ActiveView.ColumnAxis.FieldSets("Vehicle").Fields("Year"));

SetData(ChartDimensionsEnum.chDimValues,
(int)ChartSpecialDataSourcesEnum.chDataBound
PivotTable1.ActiveView.ColumnAxis.FieldSets("Vehicle").Fields("Model"));




VB.NET snippet




ChartSpace1.DataSource = PivotTable1

SetData(ChartDimensionsEnum.chDimCategories,
CType(ChartSpecialDataSourcesEnum.chDataBound,
PivotTable1.ActiveView.ColumnAxis.FieldSets("Vehicle").Fields("Year"),
Integer))

SetData(ChartDimensionsEnum.chDimValues,CType(ChartSpecialDataSourcesEnum.chDataBound
PivotTable1.ActiveView.ColumnAxis.FieldSets("Vehicle").Fields("Model"),
Integer))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top