npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cubefilter

v1.1.1

Published

Precomputes OLAP cubes and allows to used them in dc.js by exposing a crossfilter compatible API.

Downloads

8

Readme

cubefilter

NPM version Build Status Coverage Status Dependency Status Downloads

what does it do

tl;tr: cubefilter precomputes OLAP cubes that can be used in dc.js by exposing a crossfilter compatible API.

dc.js is a great javascript library to visualize complex multidimensional data beautifully and analytics friendly. dc.js is based on crossfilter, which does all the data management, filtering, grouping and other analytics related tasks in the background. Unfortunately, crossfilter expects all the data (i.e. facts) on client side, even though dc.js only shows aggregated data that is usually much smaller. This imposes a natural limit on dc.js/crossfilter and you cannot visualize arbitrarily large datasets.

cubefilter tries to solve this problem and replaces the fact-based crossfilter with a OLAP cube-based solution that exposes a similar API to dc.js. OLAP cubes aggregate large data-sets along user defined dimensions and are usually much smaller than the dataset (facts) they represent. Cubefilter can be used to incrementally pre-compute and serve cubes as simple and compact json structures on server side. On client side, cubefilter fakes crossfilter's API to feed the aggregated cube data to dc.js.

There is also a python-backend that can be used to create cubes.

Install

npm i --save cubefilter

Usage

Cubefilter can be used both on the serve in node.js and in the browser via standard script tags.

Server

Here we want to pre compute cubes via node.js scripts to later serve them as static .json files.

const cubefilter = require('cubefilter');
const sales = cubefilter.cube();

Then we need to define dimensions and groups that will define the OLAP cube structure.

sales.dimension(d => d.date.month);
sales.dimension(d => d.user.country);
sales.dimension(d => d.category).group().reduceSum(d.price);

Then we can add our facts to the cube.

mySales.forEach(fact => sales.add(fact));

And save the cube to .json

const jsonfile = require('jsonfile');
jsonfile.writeFile('sales-cube.json', sales.cube);

You don't use javascript for your server: there is also a python-backend for cubefilter.

Client

Here we want to use pre computed cubes and visualize them with dc.js. Please refer to the dc.js documentation for details.

Be aware to use the same dimension and group definitions. The order in which dimensions are created is important. The best strategy is to use the same 'definitions.js' both on the server (e.g. node.js) and the browser.

The major different to standard dc.js: you do not add facts, but use pre computed and loaded cube data. E.g. with something like this:

d3.json('sales-cube.json', (data) => {
    // import sales definition
    // ...
    // set the loaded cube       
    sales.cube = data;        
    // dc.js chart code
    // ...
    // render all charts
    dc.renderAll();
});

Example

example contains the code for a working example that emulates the standard dc.js example. (Probably not the most sensible use case, but is demonstrates the retention of most dc.js features.)

To serve the example run

yarn
gulp serve

in the example directory.

Limitations

  • OLAP cubes are not limited by the number of facts, but the number of dimensions and dimension values occupied. Depending on your use case you have to choose whether to go with crossfilter or cubefilter. For example, the monthly data of the dc.js example had to be omitted for a reasonable cube size.
  • Dimension order used to compute and show cubes is relevant. Share cube definition code among server and client code.
  • Only one group per dimension at the moment.

License

MIT © Markus Scheidgen