Skip to content
Carlos Scheidegger edited this page Oct 26, 2013 · 8 revisions

Building and using the 1.0 nanocube and API

Prerequisites

You'll need gcc 4.7 or later, LLVM 3.2's clang or later, or some other compiler with good support for the C++-11 standard. We routinely build and use nanocubes on modern Linuxes (say, Ubuntu 12.04) and OS X 10.8.

You'll need a recent version of boost as well (we run 1.54).

On OS X:

$ git clone https://github.com/laurolins/nanocube.git
$ git checkout 1.0
$ ./bootstrap
$ CC=clang CXX=clang++ CXXFLAGS="-std=c++11 -stdlib=libc++" ./configure
$ make

On Linux:

$ git clone https://github.com/laurolins/nanocube.git
$ git checkout 1.0
$ ./bootstrap
$ ./configure
$ make

Then, get some example data:

$ wget http://cscheid.net/static/brightkite.dmp.gz

Then, to run the server:

$ gunzip -c brightkite.dmp.gz | src/stree_serve --tbin=2008_1h --levels=25 --rf=100000

When this is done, an HTTP server on port 29512 will open. In a different shell, then, type the following:

$ cd nanocube/api/js
$ python -m SimpleHTTPServer

This should open an HTTP server on port 8000. Then, fire up Chrome, and visit http://127.0.0.1:8000/examples/brightkite.html.

Other examples from the examples directory will also work, but notice that they will be querying data from nanocubes.net instead of your local machine.

Data Conversion

We provide a simple Python script to convert your data to the .dmp format that the nanocube server requires. It is quite inefficient, and serves more to illustrate the format than to use it in production. The format is simple enough that you'll probably want to (as we do) write custom code to efficiently emit .dmp files.

IMPORTANT Make sure rows are sorted by time in your .dmp file, otherwise you'll see unpredictable behavior.

Configuring the view schema

After you have a working script, you'll need to configure the view schema so that the visualizations built using the Javascript API match the data schema. There are a variety of examples in view_schemata.js.

Each view schema is a JSON object (well, almost, aside from a single fields). It has the following fields:

  • url: The base URL of the nanocube server. Ideally needs to match the fully qualified domain name of the machine in which you're running the nanocube server (sometimes you can get away with 127.0.0.1, but we've had reports of this not working).
  • title: The String title to use for the heading
  • center: A JSON object with lat, lon, and zoom fields, Lat and lon are in degrees, and zoom is in a relative scale where 1 shows the entire map, and 2*i is zoomed in to a scale twice as big as i (2^n where n is the zoom level in your typical tile server also works)
  • time_range: a list with two Date objects, representing the bounds of the timestamps in the nanocube
  • max_zoom: This should match the levels parameter you passed to stree_serve (FIXME: naming consistency)
  • parent_div: the id of the div under which to append the non-geographical plots
  • views: A list of JSON objects specifying each view. Each view is a JSON object with, at least, the type field. The following types are valid:
  • count: A div showing the total count of selected events
  • histogram: A div showing a histogram of a particular categorical field. height specifies the height of the div in pixels, and field selects the categorical field, with name being the field name and values being the values which the user can see and select. Optionally, title specifies the title (which by default is name)
  • time_series: A div showing a timeseries of the selected events. height specifies the height of the div in pixels.
  • binned_scatterplot: A two-dimensional histogram, with field_x and field_y specified in the same way as a histogram