Configuration of Data Sources

Data Sources are a core concept of the ArcGIS Experience Builder (see ESRIs docs on adding data). Widgets, such as the Map Widget or the Chart widget, can select data sources and visualize their content. A Datasources is essentially tabular data with predefined columns and data types.

Most commonly, developers of an experience will use data sources that are available on their ArcGIS Portal. The DASF widget now enables you to setup dynamic data sources, i.e. data sources that do not have to be filled with precomputed content, but instead can be filled from your DASF backend module dynamically. This is especially useful if your backend module has access to large amounts of data that is too big to make it available through your ArcGIS portal, or if your DASF backend module requires powerful computational resources, such as an HPC system, that is not exposed to the web.

To use this framework (i.e. dynamically populate a data source), you need to follow two steps:

  1. define the data source in the DASF Widget

  2. populate the data source from your backend module.

Defining the data source

To define a data source that can be used by other widgets, click the DASF widget in the experience builder and, in the configuration sidebar, expand the Add new data source section.

section to add a new datasource

Now you have to options to create a new data source, manually, or via an upload of a JSON configuration file.

Manual creation

To create a datasource manually, enter the name and click Add data source

manual creation of datasource

It will now appear as a collapsed item above the button with the name you chose. Expand it, to define columns (aka variables) for the data source.

data source config overview

Now define a new variable and click the + button.

Warning

Note that variable names should not have spaces or special characters (including hyphens). A good orientation is: what ever you can use to define a variable in python, works (as such, underscores _ are fine).

add a new variable to a data source

Once created, you can customize the variable by expanding it in the configuration view

setup a variable

We recommend that you define a Human readable Alias as these are used in the frontend for visualization in legends tables, and you can change the data type of the variable,

variable data types

Upload configuration

As an alternative to the manual generation of a data source, you can also upload a config from a JSON file local to your computer. The easiest way to create such a JSON file, is to use the dasf_exb.return_models.DataSource.generate_datasource_config() method.

from dasf_exb.return_models import DataSource

# define some demo record
record = {"variable1": 3, "variable2": "some text"}

# create a data source
ds = DataSource(name="my datasource", records=[record])

# dump to a file named `datasource-config.json`
with open("datasource-config.json", "w") as f:
    f.write(ds.generate_datasource_config().model_dump_json())

You can then click the Upload config button in the experience builder and upload the datasource-config.json file you created

button to upload a data source config

Afterwards you can edit the data source config in the browser as described in the previous section Manual creation.