Tuesday, April 15, 2008

How to use the PivotComponent

If you want to provide "pivot Table" functionalities to ur application .. Just download the swc
from this post of mine .

You can see through the installation and samples there in the source , But just to give u a picture of how easy it is to use , say You have gotta do is

<fc:PivotComponent dataProvider="{flatData}" width="100%" height="100%">
<fc:DimensionList dataProvider="{flatData}" height="100%" width="100%"
color= "0xFFFFFF" alternatingItemColors="[0x000000,0x000000]"/>
<fc:MeasuresList dataProvider="{['Sales', 'Production', 'Cost']}" height="100%"
width="100%" id="m1" color= "0xFFFFFF" />
<fc:OLAPChartExtension height="100%" width="100%" measuresList="{m1}">
<fc:olapChart>
type="Column" showDataTips="true"/>
</fc:olapChart>
</fc:OLAPChartExtension>
<fc:OLAPDataGridExtension width="100%" height="100%"/>
</fc:PivotComponent>

Isnt it easy ?? Hey I have skipped the Layouting for displaying simplicity [ Use HBoxes and VBoxes to layout ]

[I think I have to come up with a component to poste codes .. Any suggestions .. please do give]







19 comments:

Nancy said...

Hello

Having a tough time installing this puppy. I don't have an swc in the bin directory when I download from your site. I would run the .bat, but I'm on a Mac. Can you help me out? How do I compile a library project?

Thanks,

Nancy said...

just figured it out. Sorry to bother you.

Nancy said...

just joking. When I put the code you have for adding your component I get the following error.

The prefix "fc" for element "fc:PivotComponent" is not bound.

Is there something I'm missing

Nancy said...

Do I need to do something with the manifest file when I build the library project?

Nancy said...

Back again. Got it going but am getting an error every time I try and drap a field into the pivot table.

Cannot access a property or method of a null object reference.

The error is coming from PopUpButton.as; line 469

_popUp.cacheAsBitmap = true;

in the following code

*/
override protected function commitProperties():void
{
super.commitProperties();

if (popUpChanged)
{
if (_popUp is IFocusManagerComponent)
IFocusManagerComponent(_popUp).focusEnabled = false;

_popUp.cacheAsBitmap = true;

any hints?

Satish T J said...

@nancy :
Hi kindly use the working swc

from here


I will write a detailed post on how to build the swc from the flexbuilder
soon . But till then u can use the above swc and get the app running .

Unknown said...

The pivot component is good, but how can you assign item renderers, as with OLAPDataGrid? I tried to do so before and after creation ("itemRendererProviders = new Array(itemRend1,itemRend2)", after giving OLAPDataGridEx an id), but it blows up in OLAPMember's uniqueName(), as the "dimension" added to the list is null.

Kurt said...

I am interested in capturing the drop event of the extended OLAP Grid, but haven't found a way to do this. Do you have any suggestions?

The plan is to dynamically create an empty dataset for the grid on each drop. We have too much data to have the full set included.

Satish T J said...

Hi Kurt .. I create a new cube on drop of dimension . So initiallly the cube is empty . When you drop first dimension , cube is created with the first dimension . When you drop second dimension , cube is created with two dimensions and so on .. was that u were looking for?

Unknown said...

Satish,

Can it support hierarchy within the dimension? It looks like it derive the dimension from the "flatData". How about allow the DimensionLIst directly specify the dimensions (and hierarchy) just like the MeasuresList.

Thanks,

Satish T J said...

@wing :
It was designed to emulate Excel .. Although Olap .. allows you to use hierarchy collection ,Dimension list has not taken that into account ..
For dimension list each "atttribute" is a dimension ..
You can use an array .. with names for dimension ..It is supported

mwlau3 said...

Hi, I cannot find the link that has the samples et al. In your comment you say "You can see through the installation and samples there in the source ". I download the SWC and the code listed on the topic "How to use the pivot component". Did I miss something?

Thanks

Pan said...

There's something wrong with your sample code in this post. The bit for olapChart just doesn't parse. I'll try to write it here but it may strip the html tags.

<fc:olapChart>
type="Column" showDataTips="true"/>
</fc:olapChart>

Then when I fix it to what it seems it should be (<fc:olapChart>
type="Column" showDataTips="true"/>), I get this error:

"Could not resolve <fc:olapChart to a component implementation."

I don't see any olapChart in any of the source files, either.

Pan said...

Correction, I fixed it to the following before getting the error:

<fc:olapChart type="Column" showDataTips="true"/>

Pan said...

Oh, duh, it was a capitalization issue. It should be "OLAPChart", not "olapChart."

Here's the corrected code for those following this:

<fc:PivotComponent dataProvider="{flatData}" width="100%" height="100%">
<fc:DimensionList dataProvider="{flatData}" height="100%" width="100%" color= "0xFFFFFF" alternatingItemColors="[0x000000,0x000000]"/>
<fc:MeasuresList dataProvider="{['Sales', 'Production', 'Cost']}" height="100%" width="100%" id="m1" color= "0xFFFFFF"/>
<fc:OLAPChartExtension height="100%" width="100%" measuresList="{m1}">
<fc:OLAPChart type="Column" showDataTips="true"/>
</fc:OLAPChartExtension>
<fc:OLAPDataGridExtension width="100%" height="100%"/>
</fc:PivotComponent>

I used this xmlns:
xmlns:fc="http://www.adobe.com/2006/fc"

And I put the swc in my project libs directory. It figured out how to link it in automatically from there.

All this compiled. But when I ran it, I got:
"Error: Multiple sets of visual children have been specified for this component (component definition and component instance)."

I found that it was caused by the chart, so commenting out the OLAPChartExtension "solved" that problem.

Anonymous said...

Hi Satish,

I think your component is close to what I need but I'm having trouble understanding your API (under my time constraint). What I have now, is a working cube discovery and MDX query (and XML/A) response from a Mondrian (SOAP) service. The cube conforms to IOLAPCube and the MDX query response is parsed into an object that conforms to IOLAPResult. Plugging that into an OLAP DataGrid component yields the display you'd want. What I really need though is to be able to pivot that display. In comes your PivotComponent. I need to figure out how to connect the cube/result objects I have to your component but yours appears to require flat data to start. Can you point me in the right direction please? Thanks! -Andrew.

crorella said...

Hi!

What needs to be done to receive and process a IOLAPResult instead of a flat datasource like ICollectionView?

Thanks

Renato Gonçalves said...

Hi! I'm using this component in a project and I need a method like resetPivotGrid. I see it in the code, but it's private. Can I use this method in public mode? Thanks

Unknown said...

hey i was wondering if instead of using flat data for Pivot Table, if we can use XML data, may be using FlashVars or HTTPService.