Bind OWC Chartspace with Pivot Table

S

Sukhdev

Hi,
I have been able to generate the Pivot by supplying my own MDX at runtime.
Could anybody please help me in binding the OWC Chartspace to the Pivot table?

That means if any further changes are made to the Pivot table by manually
dragging or removing fields from it, the Chartspace displays the chart.

Please note, I'm creating a Windows application using VB.NET.

Here's what I did:
myChartspace.Datasource = myPivotTable ' Error: --> specified cast is not
valid

Next i tried
myChartspace.Datasource = myPivotTable.datasource ' No Error, no graph
generated, no effect at all

Next i tried
myChartspace.Datasourcename = "myPivotTable" ' Error --> Catastrophic failure

Please show me a way how to bind the chartspace to the pivot table.

Thank you.
Sukhdev.
 
P

PierreDechaine

Are you using JavaScript to set your datasource property?

If so then you should use something like this:

var ptable=document.getElementById('PivotTable1');
var chart=document.getElementById('ChartSpace1');

chart.DataSource = ptable;
//To make sure all ags get plotted
chart.PlotAllAggregates=1;

HTH, Pierre
 
S

Sukhdev

Hi,
Thanks for answering, but that's not what i was looking for.

I'm creating a Windows Application, using VB.NET. My App has got the OWC11
components added to.

Here I tried the following in VB.NET
myChartSpace.DataSource = myPivotTable --> 'Error: Specified cast is not valid

However, when I try the same in VB6, it's perfect. The chartspace is bound
to the pivottable and there's no error.

Here's what I think, VB6, does some internal conversion so there's no error.
But VB.NET we must explicity specify what it is. And this is what i don't
know how to do.

could you or anyone else please help me with this. in VB.NET

thanks.
Sukhdev
 
S

Sukhdev

Hi,
I've found the solution.
There's a slight difference in binding charts to pivot table in vb6 and vb.net

Below is the solution for both vb6 and vb.net
In VB6
--------
myChartspace.Datasource = myPivotTable

In VB.NET
-----------
myChartspace.Datasource = myPivotTable.GetOcx

Reason: In VB6 the datasource property of the myChartspace has a default
value as myPivotTable
Whereas, in VB.NET, the OWC component DOES NOT support early binding, so
therefore there is no default property for the DataSource.

We must manually use GetOcx method, to return the object that reprsents the
ActiveX Control.

Cheers!!
Sukhdev.
 
P

PierreDechaine

That is interesting to see. The GetOcx method does not show up in
intellisense. If you set Option Strict on your class you will have to cast
your object like so:

cSpace.DataSource = CType(pTable.GetOcx, msdatasrc.DataSource)
cSpace.PlotAllAggregates =
ChartPlotAggregatesEnum.chPlotAggregatesSeries

Just thought that I would share my findings, Pierre
 

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