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:

  1. If you do not have Docker, install it by following the guide for your platform:

  2. 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.

  3. Open the DataLens GUI at http://localhost:8080.

Once you run DataLens, you can:

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

  1. Go to the DataLens home page.
  2. In the left-hand panel, select Collections and workbooks.
  3. In the top-right corner, click CreateCreate workbook.
  4. Enter a name for the workbook.
  5. Click Create.

Create a connection

  1. Go to the workbook page.

  2. In the top-right corner, click CreateConnection.

  3. Select the ClickHouse connection.

    1. 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.
    2. Enable Allow subqueries in datasets and queries from charts.

    3. Check the connection and click Create connection.

    4. Enter Sample ClickHouse as your connection name.

    5. Click Create.

      create-connection

Wait for the connection to be saved.

Create a dataset

  1. In the top-right corner, click Create dataset.

  2. Drag the MS_SalesMiniTable table to the workspace.

    drag-table

  3. Go to the Fields tab.

  4. In the Aggregation column, select Sum for the Sales field.

  5. Create a measure for the number of orders:

    1. Rename the OrderID field to OrderCount.
    2. Change the aggregation type to Number of unique.
  6. For the ShopAddressCoord field, change the data type to Geopoint.

  7. Save the dataset:

    1. In the top-right corner, click Save.
    2. Enter a name for the dataset and click Create.

    create-dataset

Create a column chart

  1. In the top-right corner, click Create chart.

  2. Select the Bar chart visualization type.

  3. Add the product subcategory to the chart. To do this, drag the ProductSubcategory field from Dimensions to the X section.

  4. Add a sales measure to the chart. To do this, drag the Sales field from Measures to the Y section.

  5. Sort the chart in descending order by sales by dragging the Sales field from Measures to the Sorting section.

  6. Save the chart:

    1. In the top-right corner, click Save.
    2. In the window that opens, enter the Sales by subcategory name for the chart and click Save.

    create-chart-1

Create a stacked area chart

  1. In the chart you created in the previous step, select Stacked area chart for the visualization type.

  2. 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 the ProductSubcategory field until it turns red.

  3. Add the product category to the chart. To do this, drag the ProductCategory field from Dimensions to the Colors section.

  4. Display a week by week chart:

    1. Click the calendar icon next to the OrderDate field in the X section.
    2. In the Grouping field, select RoundingWeek.
    3. Click Apply.
  5. Save the chart:

    1. In the top-right corner, click Save as copy.
    2. In the window that opens, enter the Sales by week name for the new chart and click Save.

    create-chart-2

Create a pie chart

  1. In the chart you created in the previous step, select Pie chart for the visualization type.

  2. Add the product category to the chart. To do this, drag the ProductCategory field from Dimensions to the Colors section.

  3. Add a sales measure to the chart. To do this, drag the Sales field from Measures to the Measures section.

  4. Add a measure label:

    1. Drag the Sales field from Measures to the Labels section.
    2. Click the icon to the left of the measure name.
    3. In the window that opens, to set the Label value, select Percentage and click Apply.
  5. Save the chart:

    1. In the top-right corner, click Save as copy.
    2. In the window that opens, enter the Sales by category name for the new chart and click Save.

    create-chart-2

Create a dashboard

  1. Go to the workbook page.
  2. In the top-right corner, click CreateDashboard.
  3. Enter a name for the dashboard and click Create.

Add charts to the dashboard

  1. In the top-right corner, click Add and choose Chart.

  2. Select the Sales by subcategory chart. This will automatically fill in the Name field.

  3. Click Add.

  4. Repeat the steps to add the Sales by month and Sales by category charts.

  5. Position the charts on the dashboard however you like.

  6. Save the dashboard. To do this, click Save in the top-right corner.

    add-charts

Add a selector to the dashboard

  1. In the top-right corner, click Edit.

  2. Click Add and choose Selector.

  3. Add the calendar selector for the order date:

    1. Select the created dataset.
    2. Select the OrderDate field. This will automatically fill in the Name field.
    3. Enable Range.
    4. Click Add.
  4. Position the selector on the dashboard wherever you like.

  5. Save the dashboard. To do this, click Save in the top-right corner.

    add-selectors

What's next