arpanghosh8453 / public-fitbit-projects

A script to fetch data from Fitbit servers using their API and store the data in a local influxdb database.
BSD 4-Clause "Original" or "Old" License
336 stars 31 forks source link

Sleep Regularity Panel #12

Closed latetedemelon closed 8 months ago

latetedemelon commented 8 months ago

image

undefined is not iterable (cannot read property Symbol(Symbol,iterator))

I keep getting the following error on the Sleep Regularity Panel and I can't figure out why (data?) If I try to mess with the panel config I get the following:

An unexpected error happened
    Details
    TypeError: Cannot read properties of undefined (reading 'pushEvent')

    at r (http://xxxxxxx.xxx:12358/public/build/5017.830b14490d17e9cbdabb.js:194:122062)
    at div
    at div
    at x 

I'm using the latest build and latest panel.

arpanghosh8453 commented 8 months ago

I would like to ask for mor information. Where are you getting the error? In the Grafana panel? what is the influxdb version? 1.x or 2.x? Can you check the raw data as table format in Grafana panel editor? That seems like more of a Grafana panel issue that issue with this project.

latetedemelon commented 8 months ago

image

arpanghosh8453 commented 8 months ago

Not sure what's going wrong here, you can start with a fresh heatmap panel, then use the same query. as the data is there, you can build up the visual gradually using testing and tweaking I hope.

latetedemelon commented 8 months ago

Solved. Some issue with the colour palette. Changing this to Spectral seemed to work:

image

latetedemelon commented 8 months ago

My panel JSON if it helps anyone.

{
  "datasource": {
    "type": "influxdb",
    "uid": "b76a18a0-2cde-42d1-8779-6d42d4afac3f"
  },
  "description": "",
  "fieldConfig": {
    "defaults": {
      "custom": {
        "groupBy": 30,
        "calculation": "mean",
        "colorPalette": "interpolateSpectral",
        "invertPalette": false,
        "nullValueColor": "transparent",
        "colorSpace": "rgb"
      },
      "mappings": [
        {
          "options": {
            "asleep": {
              "index": 1,
              "text": "0"
            },
            "awake": {
              "index": 0,
              "text": "1"
            }
          },
          "type": "value"
        }
      ],
      "thresholds": {
        "mode": "absolute",
        "steps": [
          {
            "color": "green",
            "value": null
          },
          {
            "color": "red",
            "value": 80
          }
        ]
      },
      "color": {
        "mode": "continuous-YlRd"
      },
      "decimals": 2,
      "min": 0
    },
    "overrides": []
  },
  "gridPos": {
    "h": 9,
    "w": 12,
    "x": 12,
    "y": 46
  },
  "id": 42,
  "options": {
    "showCellBorder": false,
    "showTooltip": false,
    "from": "0",
    "to": "0",
    "showLegend": false,
    "showValueIndicator": false,
    "legendGradientQuality": "medium",
    "regions": [
      {
        "color": "#00000000",
        "end": {
          "hour": 22,
          "minute": 30
        },
        "start": {
          "hour": 6,
          "minute": 30
        }
      }
    ],
    "timeFieldName": "Time",
    "valueFieldName": "Value"
  },
  "pluginVersion": "9.3.2",
  "targets": [
    {
      "alias": "Sleep Regularity",
      "datasource": {
        "type": "influxdb",
        "uid": "b76a18a0-2cde-42d1-8779-6d42d4afac3f"
      },
      "groupBy": [
        {
          "params": [
            "30m"
          ],
          "type": "time"
        }
      ],
      "measurement": "Sleep Levels",
      "orderByTime": "ASC",
      "policy": "default",
      "query": "SELECT median(\"level\") FROM \"Sleep Levels\" WHERE $timeFilter GROUP BY time(1h)",
      "queryType": "randomWalk",
      "rawQuery": false,
      "refId": "A",
      "resultFormat": "time_series",
      "select": [
        [
          {
            "params": [
              "level"
            ],
            "type": "field"
          },
          {
            "params": [],
            "type": "median"
          }
        ]
      ],
      "tags": [],
      "tz": "$TimeZone"
    }
  ],
  "title": "Sleep Regularity",
  "transparent": true,
  "type": "marcusolsson-hourly-heatmap-panel"
}