Getting started with DataLens
In this tutorial, you will deploy DataLens locally, create your first dataset, build several charts for data visualization, and place them on a dashboard.
Deploy DataLens
To deploy DataLens locally, just run multiple containers using Docker Compose:
If you do not have Docker, install it by following the guide for your platform:
Run the following commands:
git clone https://github.com/datalens-tech/datalenscd datalensHC=1 docker compose up
The last command will run all containers required to start DataLens. You can execute it with a parameter for connecting an external database:
METADATA_POSTGRES_DSN_LIST="postgres://{user}:{password}@{host}:{port}/{database}" HC=1 docker compose up
Note
Highcharts is a patented commercial product. If you enable Highcharts in your DataLens instance (with the
HC=1
variable), make sure to comply with the license.Open the DataLens GUI at
http://localhost:8080
.
Once you run DataLens, you can:
- Review demo examples
- Attach data sources
- Build custom dashboards
The first release of the open-source version includes everything you need to try DataLens features in your infrastructure. The repository currently hosts the service core, a set of key connectors (PostgreSQL, ClickHouse®, and YTsaurus), and the main interface components.
Create a workbook
- Go to the DataLens home page.
- In the left-hand panel, select
- In the top-right corner, click Create → Create workbook.
- Enter a name for the workbook.
- Click Create.
Create a connection
Go to the workbook page.
In the top-right corner, click Create → Connection.
Select the ClickHouse connection.
In the window that opens, specify the connection parameters:
- Host name:
rc1a-ckg8nrosr2lim5iz.mdb.yandexcloud.net
. - HTTP interface port:
8443
(default). - Username:
samples_ro
. - Password:
MsgfcjEhJk
.
- Host name:
Enable Allow subqueries in datasets and queries from charts.
Check the connection and click Create connection.
Enter
Sample ClickHouse
as your connection name.Click Create.
Wait for the connection to be saved.
Create a dataset
In the top-right corner, click Create dataset.
Drag the
MS_SalesMiniTable
table to the workspace.Go to the Fields tab.
In the Aggregation column, select Sum for the
Sales
field.Create a measure for the number of orders:
- Rename the
OrderID
field toOrderCount
. - Change the aggregation type to Number of unique.
- Rename the
For the
ShopAddressCoord
field, change the data type to Geopoint.Save the dataset:
- In the top-right corner, click Save.
- Enter a name for the dataset and click Create.
Create a column chart
In the top-right corner, click Create chart.
Select the Bar chart visualization type.
Add the product subcategory to the chart. To do this, drag the
ProductSubcategory
field from Dimensions to the X section.Add a sales measure to the chart. To do this, drag the
Sales
field from Measures to the Y section.Sort the chart in descending order by sales by dragging the Sales field from
Measures
to the Sorting section.Save the chart:
- In the top-right corner, click Save.
- In the window that opens, enter the Sales by subcategory name for the chart and click Save.
Create a stacked area chart
In the chart you created in the previous step, select Stacked area chart for the visualization type.
Replace the product subcategories with the order date on the X-axis. To do this, drag the
OrderDate
field from Dimensions to the X section and hold it over theProductSubcategory
field until it turns red.Add the product category to the chart. To do this, drag the
ProductCategory
field from Dimensions to the Colors section.Display a week by week chart:
- Click the calendar icon next to the OrderDate field in the
X
section. - In the Grouping field, select Rounding → Week.
- Click Apply.
- Click the calendar icon next to the OrderDate field in the
Save the chart:
- In the top-right corner, click
- In the window that opens, enter the Sales by week name for the new chart and click Save.
- In the top-right corner, click
Create a pie chart
In the chart you created in the previous step, select Pie chart for the visualization type.
Add the product category to the chart. To do this, drag the
ProductCategory
field from Dimensions to the Colors section.Add a sales measure to the chart. To do this, drag the Sales field from
Measures
to the Measures section.Add a measure label:
- Drag the Sales field from
Measures
to the Labels section. - Click the icon to the left of the measure name.
- In the window that opens, to set the Label value, select Percentage and click Apply.
- Drag the Sales field from
Save the chart:
- In the top-right corner, click
- In the window that opens, enter the Sales by category name for the new chart and click Save.
- In the top-right corner, click
Create a dashboard
- Go to the workbook page.
- In the top-right corner, click Create → Dashboard.
- Enter a name for the dashboard and click Create.
Add charts to the dashboard
In the top-right corner, click Add and choose Chart.
Select the Sales by subcategory chart. This will automatically fill in the Name field.
Click Add.
Repeat the steps to add the Sales by month and Sales by category charts.
Position the charts on the dashboard however you like.
Save the dashboard. To do this, click Save in the top-right corner.
Add a selector to the dashboard
In the top-right corner, click Edit.
Click Add and choose Selector.
Add the calendar selector for the order date:
- Select the created dataset.
- Select the
OrderDate
field. This will automatically fill in the Name field. - Enable Range.
- Click Add.
Position the selector on the dashboard wherever you like.
Save the dashboard. To do this, click Save in the top-right corner.
What's next
- Read about service concepts.
- View an example of a ready-to-use dashboard.
ClickHouse® is a registered trademark of ClickHouse, Inc.