> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognite.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Plot time series from data model views

> Create dashboards and select the time series you want to plot using custom queries, filtering, aggregation, and advanced features.

<Note>
  Data modeling projects can reference time series using `instanceId` (an object with `space` and `externalId`) in addition to the traditional `id` or `externalId` methods.
</Note>

<a id="create-a-dashboard" />

## Create a dashboard

To create a dashboard with time series data from <span translate="no">Cognite Data Fusion</span> (<span translate="no">CDF</span>):

<Steps>
  <Step title="Sign in and create a dashboard">
    Sign in to your <span translate="no">Grafana</span> instance and create a dashboard.
  </Step>

  <Step title="Select time series for your dashboard">
    Use the query tabs below the main chart area to select time series for your dashboard.

    <Note>
      If your query tabs are missing, check the feature flags in the data source settings.
    </Note>

    * **CogniteTimeSeries** - search for time series from data model views. Select a **View** and start typing to filter and select a time series.

          <Tip>
            Optionally, set a custom **label** and use the format `{{property}}` to pull data from the time series. You can use all the available [time series properties](/api-reference/concepts/20230101/time-series) to define a label, for example, `{{name}} - {{description}}` or `{{metadata.key1}}`.
          </Tip>

      Use this tab when your time series are defined in data models. The **View** dropdown lists views that implement the `CogniteTimeSeries` container and shows the view name, space, and version. After you select a view, search by name or description to find time series instances. This tab filters out string time series, and selections use the instance ID (space and external ID).

    <Tip>
      If a time series has a unit, you can select a target unit in the query. The target unit dropdown appears only when a unit is defined, shows compatible units in the same quantity, and displays the current unit for reference.
    </Tip>

    * **Data models** - run a GraphQL query to fetch instances from a data model and plot their time series. See [Display time series from the Data models tab](#display-time-series-data-from-data-model-instances) below.
  </Step>

  <Step title="Review and adjust the timeframe">
    The time series matching your selection will be rendered in the chart area. Adjust the timeframe as necessary to display relevant data.

    <Frame>
      <img src="https://apps-cdn.cogniteapp.com/@cognite/docs-portal-images/1.0.0/images/cdf/dashboards/grafana/adjust-timeframe_v1.png" alt="Adjust timeframe" width="100%" />
    </Frame>
  </Step>
</Steps>

## Display time series data from data model instances

You can display time series data from instances of <span translate="no">CDF</span> data models using the **Data models** tab:

<Steps>
  <Step title="Select the data model and version">
    On the <span class="ui-element">Data models</span> tab, select the <span class="ui-element">data model</span> and <span class="ui-element">version</span>.
  </Step>

  <Step title="Specify the query">
    <Warning>
      Add `__typename` and `externalId` below the fields that contain the time series. In this example, below `temperature` and `pressure`:

      ```graphql theme={"languages":{"custom":["/_languages/kuiper.json","../_languages/kuiper.json"]}}
      {
        listPump {
          items {
            temperature {
              __typename
              externalId
            }
            pressure {
              __typename
              externalId
            }
          }
        }
      }
      ```
    </Warning>

    Grafana automatically detects time series in your query results. If your query returns fields with `type: "numeric"` that include `space` and `externalId`, Grafana treats them as time series and fetches data points automatically. Keep `__typename` and `externalId` in the query to support older detection behavior and queries that return mixed instance types.

    <Frame>
      <img src="https://apps-cdn.cogniteapp.com/@cognite/docs-portal-images/1.0.0/images/cdf/dashboards/grafana/custom_query_datamodel_v2.png" alt="Custom query data model" width="100%" />
    </Frame>
  </Step>
</Steps>
