2. Initialize Scene and Import Data

To creata a visualization, we need to create a scene first:

let scene = atlas.scene();

The returned object is an instance of the Scene class, which is one of the most important class in Atlas. Mark/glyph creation, data binding, visual encoding and graphical constraints are all accomplished as methods in this class.

Currently Atlas supports importing data formatted as Comma Separated Values (CSV) files, with the assumption that the first row contains the column names, and the data is in a long form. For an explanation of the differences between long and wide forms of data, see this Wikipedia article. Section 3 of Tiday Data by Hadley Wickham contains a more technical discussion. To import a CSV file, use the csv function:

let table = await atlas.csv("path/to/file");

IMPORTANT: The csv function is an asynchronous function that returns a promise, hence the await keyword. When the promise is fulfilled, a DataTable object is returned. You need to put the above line of code and any other code that handles the table object in an asychronous function, or use the Promise.then() method to handle the table object. To read more about promise and asynchrous function, here are some tutorials: link 1, link 2.

When importing a csv file, Atlas automatically infers the data type for each column, and parses the values accordingly. An imported data table can be used in one or more scenes.