Giter Club home page Giter Club logo

js-hypercube's Introduction

js-hypercube

HyperCube for short.

An n-dimensional database, written in JavaScript, useful for aggregation and charting analytics. Datasets can be "sliced and diced" in real-time, with low-latency. Plot data on a graph. Amaze your boss.

Example

A hypercube is useful for expressing n-dimensional analytics. Spreadsheets work great for 2-dimensional data expressed w/ rows and columns. A hypercube is similar to a spreadsheet, but it can represent data using more than just 2-dimensions. The HyperCube library uses a standard data-model to represent this feature.

Each data set contains n-number of fact-records. A fact-record represents a specific combination of facts at specific time. These attributes are used like a coordinate system. For example, consider the "Super Mario Bros. 2" video game for the Nintendo gaming system. During a 1-hour time interval, this game may have been sold 6 times, rented 43 times, and made $239.94 in revenue:

// this data is fake, but represents the standard HyperCube data format
var data = [{"time":1331773202,"facts":{"name":"Super Mario Bros. 2","platform":"Nintendo","staring":"Mario"},"measures":{"rentals":73,"sales":9,"revenue":359.91}}, {"time":1331841602,"facts":{"name":"Metroid","platform":"Nintendo","staring":"Samus"},"measures":{"rentals":43,"sales":6,"revenue":239.94}}]; // ... etc

You can see that each fact-record has time, facts, and measures fields. The time field can be converted to local time:

// each fact record in the data-set has a unix-time. add standardized local-time facts
ps.Cube.transforms.dateLocal(data);

Deserializing the JSON data-set will turn it into a query-able hypercube:

// turn our fact records into a cube
var cube    = ps.Cube.deserialize(data, ['rentals', 'sales', 'revenue'])

You can then do some interesting stuff:

// run some interesting queries
console.info('Total Rentals', cube.sum().rentals);
console.info('Revenue at 6pm for Super Nintendo games', '$' + cube.slice({hour: 18, platform: 'Super Nintendo'}).sum(2).revenue);
console.info('Avg rentals per hour for games staring Mario', cube.slice({staring: 'Mario'}).avg(24, 2).rentals + ' units');

Source Structure

There are four major parts to this library:

  • ps - the Prescreen namespace and small base library
  • ps.Cube - maintains a set of cells, an index, query methods, and aggregation methods
  • ps.Cell - a discrete record in the database, maintains a "fact set", a "measure set" and a unix-time code.
  • ps.FactIndex - internal, and can be ignored. Its an indexing mechanism used by the query engine to drastically improve performance
  • ps.Cube.transforms - filters hyper.Cell instances unix-time code

Requirements

This library requires jQuery, but you could easily replace jQuery if you create $.each, $.map, $.extend, $.isArray, $.isPlainObject, $.isFunction. This will likely be done in a future release. If you would like to take this project on, please contact me.

Highly Recommended: encourage users to use Google Chrome. IE can be slow for large datasets.

Dedication

I'd like to dedicate this library to Ralph Kimball. This book is an excellent read: http://www.amazon.com/The-Data-Warehouse-Toolki

js-hypercube's People

Contributors

cwarden avatar thesmart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

js-hypercube's Issues

Demo using js-hypercube

I cloned the project and looked into example provided. I am not able to find any working demo for Slice, Dice, cube viewing etc. in the example.

Can you please provide any reference where the cube uses these features?

Thank you,
Sovit

Project name

Please change the name since it is irrelevant to tesseract. I was expecting a canvas3d javascript hypercube project. I am disappointed:(

evrim.

Remove dependence on jQuery

Currently, the library is dependent on jQuery. It should be possible to remove this dependency by adding a few functions to the $ symbol's prototype:

$.each, $.map, $.extend, $.isArray, $.isPlainObject, $.isFunction

See jQuery docs for expected behavior.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.