blob: 9e8a5e677c81cc74e974471028c77a575bbf0f64 [file] [log] [blame]
<?xml version="1.0"?>
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.
<mx:Module xmlns:fx="" xmlns:mx="library://"
paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0"
height="100%" width="100%"
import mx.rpc.AsyncResponder;
import mx.rpc.AsyncToken;
import mx.olap.OLAPQuery;
import mx.olap.OLAPSet;
import mx.olap.IOLAPQuery;
import mx.olap.IOLAPQueryAxis;
import mx.olap.IOLAPCube;
import mx.olap.OLAPResult;
import mx.controls.Alert;
import mx.collections.ArrayCollection;
private var flatData:ArrayCollection = new ArrayCollection(
{customer:"AAA", product:"Flex SDK", quarter:"Q1", revenue:210, cost:25},
{customer:"AAA", product:"Flex JS", quarter:"Q2", revenue:210, cost:25},
{customer:"AAA", product:"Falcon", quarter:"Q3", revenue:250, cost:125},
{customer:"AAA", product:"Falcon JX", quarter:"Q4", revenue:430, cost:75},
{customer:"BBB", product:"Flex SDK", quarter:"Q2", revenue:125, cost:20},
{customer:"BBB", product:"Flex JS", quarter:"Q3", revenue:210, cost:20},
{customer:"BBB", product:"Falcon", quarter:"Q4", revenue:320, cost:120},
{customer:"BBB", product:"Falcon JX", quarter:"Q1", revenue:280, cost:70},
{customer:"CCC", product:"Flex SDK", quarter:"Q3", revenue:375, cost:120},
{customer:"CCC", product:"Flex JS", quarter:"Q4", revenue:430, cost:120},
{customer:"CCC", product:"Falcon", quarter:"Q1", revenue:470, cost:220},
{customer:"CCC", product:"Falcon JX", quarter:"Q2", revenue:570, cost:170},
{customer:"AAA", product:"Flex SDK", quarter:"Q4", revenue:215, cost:90},
{customer:"AAA", product:"Flex JS", quarter:"Q1", revenue:210, cost:90},
{customer:"AAA", product:"Falcon", quarter:"Q2", revenue:175, cost:190},
{customer:"AAA", product:"Falcon JX", quarter:"Q3", revenue:670, cost:75},
{customer:"BBB", product:"Flex SDK", quarter:"Q1", revenue:175, cost:20},
{customer:"BBB", product:"Flex JS", quarter:"Q2", revenue:210, cost:20},
{customer:"BBB", product:"Falcon",quarter:"Q3", revenue:120, cost:120},
{customer:"BBB", product:"Falcon JX", quarter:"Q4", revenue:310, cost:70},
{customer:"CCC", product:"Flex SDK", quarter:"Q1", revenue:385, cost:120},
{customer:"CCC", product:"Flex JS", quarter:"Q2", revenue:340, cost:120},
{customer:"CCC", product:"Falcon", quarter:"Q3", revenue:470, cost:220},
{customer:"CCC", product:"Falcon JX", quarter:"Q4", revenue:270, cost:170},
{customer:"AAA", product:"Flex SDK", quarter:"Q1", revenue:100, cost:25},
{customer:"AAA", product:"Flex JS", quarter:"Q2", revenue:150, cost:25},
{customer:"AAA", product:"Falcon", quarter:"Q3", revenue:200, cost:125},
{customer:"AAA", product:"Falcon JX", quarter:"Q4", revenue:300, cost:75},
{customer:"BBB", product:"Flex SDK", quarter:"Q2", revenue:175, cost:20},
{customer:"BBB", product:"Flex JS", quarter:"Q3", revenue:100, cost:20},
{customer:"BBB", product:"Falcon", quarter:"Q4", revenue:270, cost:120},
{customer:"BBB", product:"Falcon JX", quarter:"Q1", revenue:370, cost:70},
{customer:"CCC", product:"Flex SDK", quarter:"Q3", revenue:410, cost:120},
{customer:"CCC", product:"Flex JS", quarter:"Q4", revenue:300, cost:320},
{customer:"CCC", product:"Falcon", quarter:"Q1", revenue:510, cost:220},
{customer:"CCC", product:"Falcon JX", quarter:"Q2", revenue:620, cost:170},
{customer:"AAA", product:"Flex SDK", quarter:"Q4", revenue:215, cost:90},
{customer:"AAA", product:"Flex JS", quarter:"Q1", revenue:210, cost:90},
{customer:"AAA", product:"Falcon", quarter:"Q2", revenue:175, cost:190},
{customer:"AAA", product:"Falcon JX", quarter:"Q3", revenue:420, cost:75},
{customer:"BBB", product:"Flex SDK", quarter:"Q1", revenue:240, cost:20},
{customer:"BBB", product:"Flex JS", quarter:"Q2", revenue:100, cost:20},
{customer:"BBB", product:"Falcon", quarter:"Q3", revenue:270, cost:120},
{customer:"BBB", product:"Falcon JX", quarter:"Q4", revenue:370, cost:70},
{customer:"CCC", product:"Flex SDK", quarter:"Q1", revenue:375, cost:120},
{customer:"CCC", product:"Flex JS", quarter:"Q2", revenue:420, cost:120},
{customer:"CCC", product:"Falcon", quarter:"Q3", revenue:680, cost:220},
{customer:"CCC", product:"Falcon JX", quarter:"Q4", revenue:570, cost:170}
private function creationCompleteHandler():void {
// You must initialize the cube before you
// can execute a query on it.
// Create the OLAP query.
private function getQuery(cube:IOLAPCube):IOLAPQuery {
// Create an instance of OLAPQuery to represent the query.
var query:OLAPQuery = new OLAPQuery;
// Get the row axis from the query instance.
var rowQueryAxis:IOLAPQueryAxis =
// Create an OLAPSet instance to configure the axis.
var productSet:OLAPSet = new OLAPSet;
// Add the Product to the row to aggregate data
// by the Product dimension.
// Add the OLAPSet instance to the axis.
// Get the column axis from the query instance, and configure it
// to aggregate the columns by the Quarter dimension.
var colQueryAxis:IOLAPQueryAxis =
var quarterSet:OLAPSet= new OLAPSet;
return query;
// Event handler to execute the OLAP query
// after the cube completes initialization.
private function runQuery(event:CubeEvent):void {
// Get cube.
var cube:IOLAPCube = IOLAPCube(event.currentTarget);
// Create a query instance.
var query:IOLAPQuery = getQuery(cube);
// Execute the query.
var token:AsyncToken = cube.execute(query);
// Setup handlers for the query results.
token.addResponder(new AsyncResponder(showResult, showFault));
// Handle a query fault.
private function showFault(result:Object, token:Object):void {"Error in query.");
// Handle a successful query by passing the query results to
// the OLAPDataGrid control..
private function showResult(result:Object, token:Object):void {
if (!result) {"No results from query.");
myOLAPDG.dataProvider= result as OLAPResult;
<mx:OLAPCube name="FlatSchemaCube"
<mx:OLAPDimension name="CustomerDim">
<mx:OLAPAttribute name="Customer" dataField="customer"/>
<mx:OLAPHierarchy name="CustomerHier" hasAll="true">
<mx:OLAPLevel attributeName="Customer"/>
<mx:OLAPDimension name="ProductDim">
<mx:OLAPAttribute name="Product" dataField="product"/>
<mx:OLAPHierarchy name="ProductHier" hasAll="true">
<mx:OLAPLevel attributeName="Product"/>
<mx:OLAPDimension name="QuarterDim">
<mx:OLAPAttribute name="Quarter" dataField="quarter"/>
<mx:OLAPHierarchy name="QuarterHier" hasAll="true">
<mx:OLAPLevel attributeName="Quarter"/>
<mx:OLAPMeasure name="Revenue"
<mx:Panel title="OLAPCube Control Example"
paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10"
height="100%" width="100%">
<mx:OLAPDataGrid id="myOLAPDG" width="100%" height="100%"/>