{% if not data or not data.data %}
  &mdash;
{% else %}
  <span class="timeseries-container" data-sampledb-timeseries-title="{{ schema['title'] | get_translated_text }}" data-sampledb-timeseries-id="{{ id_prefix[:-1] }}">
    {% set timeseries_data = data | to_timeseries_data(schema) %}
    {% if timeseries_data.magnitude_average is none and timeseries_data.magnitude_stddev is none and timeseries_data.magnitude_min is none and timeseries_data.magnitude_max is none and timeseries_data.magnitude_count is none %}
      {{ _('Timeseries') }}
    {% else %}
      {% if timeseries_data.magnitude_average is not none %}
        {%- if timeseries_data.magnitude_stddev is not none -%}
          {{ timeseries_data.magnitude_average | babel_format_number(schema.get('display_digits', 2)) }} ± {{ timeseries_data.magnitude_stddev | babel_format_number(schema.get('display_digits', 2)) }}
        {%- else -%}
          x̄ = {{ timeseries_data.magnitude_average | babel_format_number(schema.get('display_digits', 2)) }}
        {%- endif -%} {{ timeseries_data.units }}
      {%- elif timeseries_data.magnitude_stddev is not none -%}
        σ = {{ timeseries_data.magnitude_stddev | babel_format_number(schema.get('display_digits', 2)) }}{{ timeseries_data.units }}
      {%- endif -%}
      {% if timeseries_data.magnitude_min is not none %}
        {%- if timeseries_data.magnitude_average is not none or timeseries_data.magnitude_stddev is not none -%}; {% endif %}
        ≥ {{ timeseries_data.magnitude_min | babel_format_number(schema.get('display_digits', 2)) }}{{ timeseries_data.units }}
        {% if timeseries_data.magnitude_max is not none %} {{ _('and') }} {% endif %}
      {%- endif -%}
      {%- if timeseries_data.magnitude_max is not none -%}
        {%- if timeseries_data.magnitude_min is none and (timeseries_data.magnitude_average is not none or timeseries_data.magnitude_stddev is not none) -%}; {%- endif -%}
        ≤ {{ timeseries_data.magnitude_max | babel_format_number(schema.get('display_digits', 2)) }}{{ timeseries_data.units }}
      {%- endif -%}
      {%- if timeseries_data.magnitude_count is not none -%}
        {%- if timeseries_data.magnitude_min is not none or timeseries_data.magnitude_max is not none or timeseries_data.magnitude_average is not none or timeseries_data.magnitude_stddev is not none-%}; {% endif %}
        {{ timeseries_data.magnitude_count | format_int }} {{ ngettext('value', 'values', timeseries_data.magnitude_count) }}
      {% endif %}
    {% endif %}
    {%- if timeseries_data.relative_times -%}
      {%- if timeseries_data.relative_times | length > 1 -%}
        {{ _('within a period of %(time_s)s s', time_s=timeseries_data.relative_times[-1] - timeseries_data.relative_times[0]) }}
      {%- endif -%}
    {%- else -%}
      {%- if timeseries_data.utc_datetimes | length > 1 -%}
        {% if timeseries_data.same_day -%}
          {{ _('between %(start_time)s and %(end_time)s on %(date)s', start_time=timeseries_data.utc_datetimes[0] | babel_format_time, end_time=timeseries_data.utc_datetimes[-1] | babel_format_time, date=timeseries_data.utc_datetimes[0] | babel_format_date) }}
        {%- else -%}
          {{ _('between %(start_datetime)s and %(end_datetime)s', start_datetime=timeseries_data.utc_datetimes[0] | babel_format_datetime, end_datetime=timeseries_data.utc_datetimes[-1] | babel_format_datetime) }}
        {%- endif -%}
      {%- else -%}
        {{ _('at %(datetime)s', datetime=timeseries_data.utc_datetimes[0] | babel_format_datetime) }}
      {%- endif -%}
    {%- endif -%}
    {%- if timeseries_data.magnitude_first is not none -%}
      ; {{ _('first value') }}: {{ timeseries_data.magnitude_first | babel_format_number(schema.get('display_digits', 2)) }}{{ timeseries_data.units }}
    {%- endif -%}
    {%- if timeseries_data.magnitude_last is not none -%}
      ; {{ _('last value') }}: {{ timeseries_data.magnitude_last | babel_format_number(schema.get('display_digits', 2)) }}{{ timeseries_data.units }}
    {%- endif -%}
    &nbsp;
    <button type="button" class="btn btn-default btn-xs timeseries-chart-button" data-toggle="tooltip" data-placement="top" title="{{ _('View chart') }}"><i class="fa fa-line-chart fa-fw"></i></button>
    <button type="button" class="btn btn-default btn-xs timeseries-table-button" data-toggle="tooltip" data-placement="top" title="{{ _('View table') }}"><i class="fa fa-table fa-fw"></i></button>
    <a href= {% if workflow_display_mode %}
      {# remove workflow prefix #}
      "{{ url_for('.download_timeseries_data', object_id=object_id, timeseries_id='object' + id_prefix[(('workflow_' + (object_id | string)) | length):-1]) }}"
    {% else %}
      "{{ url_for('.download_timeseries_data', object_id=object_id, timeseries_id=id_prefix[:-1]) }}"
    {% endif -%} class="btn btn-default btn-xs timeseries-download-button" data-toggle="tooltip" data-placement="top" title="{{ _('Download data') }}"><i class="fa fa-download fa-fw"></i></a>
    <script type="application/json">{{ timeseries_data | tojson }}</script>
  </span>
{% endif %}
