# olap-cube-js

0.16.1 • Public • Published

# OLAP cube.js

The simplest data analysis tools written in javascript. This solution is a means for extracting and replenishing data, which together with your data storage means and a means of providing aggregate data, is intended for decision making.

## Features:

• Multidimensional conceptual data representation
• Tree structure for representing hierarchical data
• Balanced hierarchies
• Multi-level hierarchies
• Each cube dimension contains one hierarchies
• Dynamic fact table
• OLAP data is typically stored in a snowflake schema
• Surrogate key is internally generated as unique identifier for dimension member (used composite dimension keys)
• The ability to edit data
• Filling - solution for Typical Multidimensional Problem: missing values
• Multiple hierarchies (each cube dimension can contains more then one hierarchies, dimension with both fiscal and calendar years is one classic example)

## Getting Started

### Prerequisites

For install the software you need a package manager - npm which is installed with Node.js

### Installing

Then in the console run the following command

## How Cube is work?

### Structure

Now the cube will represent the structure below:

### Sets

A set is a collection of distinct objects. Set provides a specialized syntax for getting and manipulating the multidimensional data stored in OLAP cubes. Access to the elements of the OLAP-cube can be carried out several types of sets

##### Types of sets: Set, Subset, Emptyset, Multiset

Set, that type determines one element:
w : ( x , y , z ) → wxyz ,

Subset, that type determines several elements:
W : ( x , y ) → W = { wz1 , wz2 , … , wzn } ,

Emptyset, that type determines all elements:
W : () → W = { wx1 y1 z1 , wx1 y1 z2 , … , wxn yn zn } ,

Emptyset, that type determines union of elements:
W : ({ z1 , z2 }) → W = { Wx1 y1 , Wxn yn } = { wx1 y1 , wxn yn }z1 ∪ { wx1 y1 , wxn yn }z2 .
Now using different types of sets, you can access the elements of the cube

## API

##### Set

Define the set with maximum cardinality. For this fixate all dimensions of the first level of the hierarchy.

Example:

execute:

return:

execute:

return:

##### Subset

Fixate some of the dimensions:

execute:

return:

execute:

return:

##### Emptyset

This way you can take all the facts from the cube back:

execute:

return:

execute:

return:

##### Multiset

Fixate a plurality of dimension values:

execute:

return:

execute:

return:

##### Emptyset

Simple call return all members of the dimension:

return:

##### SubSet

Queries with the second argument return some members of the dimension in accordance with the passed set

return:

Other example:

return:

return:

### Editing dimension members

The cube and its subcubes have common links to dimension members. It is made possible to edit data in dimension members between operations.

``````const subCube = cube.dice({ product: { id: 1 } }) // some operation
const memberFromCube = cube.getDimensionMembers('regions').find(({id}) => id === 1)
const memberFromSubcube = subCube.getDimensionMembers('regions').find(({id}) => id === 1)
memberFromCube === memberFromSubcube // true
``````

return:

### Removing dimension hierarchy

Returns the result back to the addition of the hierarchy

return:

or:

return:

### Filling empty cells

Fills the fact table with all possible missing combinations. For example, for a table, such data will represent empty cells

Execute filling:

Now get the facts back:

factsFilled will be:

### Removing empty cells

You can remove all or some of the empty cells. At the same time, some of the dimension members can be removed too if no more cells found correspond to the dimension member

### Dice

It may be that the dimension member may content additional properties from the fact table that do not participate in creating own surrogate key, for this use the property `otherProps`

return:

execute:

return:

execute:

return:

execute:

return:

### Custom facts

Like custom members, some times need make custom facts

## Versioning

We use SemVer for versioning. Until olap-cube-js reaches a 1.0 release, breaking changes will be released with a new minor version. For example 0.10.0, and 0.10.1 will have the same API, but 0.11.0 will have breaking changes. The project is on stage of developing API.

## Explanation of Build Files

UMD ES Module
dev cube.js cube.esm.js
prod cube.min.js cube.esm.min.js

## Todo

In future versions:

Perhaps

## Motivation

As a frontend developer, I am not very familiar with the subject area of cubic data, but in my work I was faced with cubic data of a hierarchical type, so I wanted to make a small tool to solve my problems. The task turned out to be difficult, but interesting in terms of creating a public API, the results of which are presented above.

## Package Sidebar

### Install

`npm i olap-cube-js`

### Repository

github.com/feonit/olap-cube-js

261

0.16.1

ISC

1.51 MB

146