Introduction
This guide will walk you through creating a simple data app using Latitude. You’ll learn how to:- Create a new data app
- Add a data source
- Write your queries
- Define the layout and visualizations
- Next steps
Prerequisites
Before you begin, make sure you followed the installation guide to install Latitude.1. Create a new data app
To create a new data app, run the following command in your terminal:2. Add a data source
To add a data source to your app, you’ll need to create a new file in thesources
directory.
For this guide, we’ll use the CSV that comes with the sample project, but you can replace that with any other CSV or connect to a live database following these instructions.
Go ahead and download the sample CSV and save it in the queries
directory as source.csv
.
Download sample CSV
Visit the page and hit
Cmd + S
or Ctrl + S
to save the file3. Write your queries
Now that you have a data source, you can write your first query. Create a new file namedsample.sql
in the queries
directory and write the following query:
sample.sql
source.csv
file using the DuckDB adapter that’s configured by default in the source.yml
file.
Next, let’s create a secondary query to aggregate some data. Create a new file named sample_agg.sql
in the queries
directory and write the following query:
sample_agg.sql
ref
function is used to interpolate the sample.sql
query, and use its results as the input for this query. Latitude allows you to chain queries together very easily, find out more about this in the queries reference.
To check that your queries are working as expected, you can run them locally using the latitude run
command. For example:
/queries/sample_agg.sql
query once and display the results in your terminal.
Learn more about latitude run
in the CLI reference.
4. Define the layout and visualizations
Now that you have your queries, you can define the layout and visualizations for your app. Open theindex.html
file in your text editor and replace the content with the following:
index.html
http://localhost:3000
and you should see a working data app with a line chart displaying the number of titles released over time and a table with the raw data.