Skip to content

Tables

Description

Display a Data Table

Attributes

  • tile: table
  • title:
  • connect: [Connection objects]
    • ..standard fields..
    • hTotal: tuple with expression, title and format
    • vTotal: tuple with expression, title and format
    • rules: [Array of Objects] Provide a rules to display the configure value in the cell
      • value: Provide a value to be display in a cell also allow a template string to display within a cell.
      • rule: Valid conditional rule.
  • classes: Provide a classes for a table.For e.g cell class for table cell.
  • table: configuration related to the table content formatting
    • timeSeries: time series expression for e.g YYYY-MM; MMM YYYY; P1M
    • groupBy: provide either $user or any key
    • groupByTransform: provide either system:countryIso or any key
    • title
    • firstCol:
    • export: Any valid Dispatch query
    • width: table header column width
    • users: users query
    • conditionalBackground: provide a background color based different condition [color]: match expression

Notes

  • at(ls, index) allows a lookup of specific location in the list with negative values counted from the end.

Example1

Display Data table with horizontal and Vertical column at the end of table cell. In which for Htotal the configuration like below one where first arg indicate the expression which calculate the value for cell, second one for title of Htotal cell, third one for display data format in the cell. Also, Same Description for vTotal.

 {
  "hTotal": [
    "at(ls, -1)",
    "Total Horizontal",
    "0.0"
  ]
}
 {
  "tile": "table",
  "table": {
    "timeSeries": "YYYY-MM-DD; DD MMM; P1D",
    "export": "given trackers [wellness]",
    "groupBy": "$user, sleep"
  },
  "connect": [
    {
      "title": "Wellness test",
      "source": "wellness",
      "pick": "values.sleep",
      "apply": "mean(ls)",
      "hTotal": [
        "at(ls, -1)",
        "Total Horizontal",
        "0.0"
      ],
      "vTotal": [
        "mean(ls)",
        "Total Vertical",
        "0.0"
      ]
    }
  ]
}

Example2

Display Data table cell with different background color of cell based on dispatches results.And Show different value within a cell based on dispatches results.

{
  "tile": "table",
  "classes": {
    "cell": "text-center"
  },
  "table": {
    "timeSeries": "YYYY-MM-DD; DD MMM; P1D",
    "conditionalBackground": {
      "#FFF5EB, #0A1931": "n <= 0",
      "#DF5E5E, #0A1931": "n >= 5 and n < 10",
      "#B5CDA3, #0A1931": "n >= 10 and n < 15",
      "#DEEDF0, #0A1931": "n >= 15"
    },
    "export": "given trackers [wellness]",
    "groupBy": "$user, sleep"
  },
  "connect": [
    {
      "title": "Wellness test",
      "source": "wellness",
      "pick": "values.sleep",
      "apply": "sum(ls)",
      "format": "0.0",
      "rules": [
        {
          "rule": "values.result >= 5 and values.result < 10",
          "value": "◎"
        },
        {
          "rule": "values.result >= 10 and values.result < 15",
          "value": "◯"
        },
        {
          "rule": "values.result >= 15",
          "value": "{values.sleep}"
        }
      ]
    }
  ]
}

NOTE:-

Provide a valid datasource to display the table layout.

{
  "dataSources": [
    {
      "id": "wellness",
      "query": "current user, given trackers [wellness] from today to -30 days"
    }
  ]
}

Example of conditional Pick and [rules based on pick values]

Here want to display a different string based on pick condition. like status and goal is some numerica value. Apply a coniditional expression and return pick values based on pick values display a string within an table. To display a different string mapping a pick values result as with rules. Here rule condition only applicable to the pick results.

{
  "title": "",
  "source": "general",
  "trackerHandle": "top2",
  "pick": "values.status == values.goal ? 3 : values.status == 0 ? 1 : (values.goal > values.status ) ? 2 : nil",
  "apply": "mean(ls)",
  "format": "0,0",
  "rules": [
    {
      "rule": "values.result == 3",
      "value": "◎"
    },
    {
      "rule": "values.result == 2",
      "value": "◯"
    },
    {
      "rule": "values.result == 1",
      "value": "X"
    }
  ]
}