DataStation Documentation Blog Community Subscribe

Code Panel Documentation

DataStation is an open-source data IDE for developers. It allows you to easily build graphs and tables with data pulled from SQL databases, logging databases, metrics databases, HTTP servers, and all kinds of text and binary files. Need to join or munge data? Write embedded scripts as needed in Python, JavaScript, Ruby, R, or Julia. All in one application.

Code panels allow you to use Python, JavaScript, Ruby, R, Julia or an in-memory SQL engine to produce data for or manipulate data from other panels. The language must be installed on your laptop already. R and Julia have some additional requirements documented below.

Importing 3rd party libraries

Since DataStation uses the language already installed, you can import any libraries you already have installed too.

Communicating between panels

Use DM_getPanel($number) to pull the results from another panel where $number is the zero-indexed panel you want to grab. And use DM_setPanel($var) to set the current panel's result.

Panel results can be of any format. But when setting a panel you intend to have read from a Table or Graph panel, there is a single accepted data format.

In-Memory SQL

In-memory SQL is a way of running SQL queries solely against other panels without a running database. It is useful in situations where you don't have a database but the most natural way to express a join or filter is in SQL rather than code.

SQL panels can refer to the results of other panels by using DM_getPanel($number) where $number is the zero-indexed panel you want to grab.

DM_getPanel($number) should only be called once. After that it can be referred to by the alias t$number. For example: SELECT * FROM DM_getPanel(0) WHERE t0.age < 12> will fetch all results from the first panel (zero-indexed) and filter out rows where the age column is less than 12.

Table and Graph panel data format

Table and Graph panels must read from a panel that formats data as an array of objects. Each object-element must be a mapping of column name to column value. For example: [{ "age": 1, "name": "Eliza" }, { "age": 3, "name": "Javier" }].

Julia

After you have installed Julia, you must also install JSON.jl for Code panels to work.

R

After you have installed R, you must also install rjson.

Overriding program path

If you want to use a version of the language that is not in your PATH or not the default, you can modify $HOME/DataStationProjects/.settings and modify the ${language}Path variable like rPath or pythonPath to point at the program you'd like to be run.

Online Environment

The online environment uses in-browser implementations of JavaScript and Python. Other languages are not available.