{
  "timezone": "Americas/Martinique",
  "timepicker": {
    "time_options": [
      "5m",
      "15m",
      "1h",
      "6h",
      "12h",
      "24h",
      "2d"
    ],
    "nowDelay": "5s"
  },
  "title": "Smart City Digital Twin - Overview",
  "tags": [
    "smart-city",
    "digital-twin",
    "overview"
  ],
  "schemaVersion": 16,
  "version": 1,
  "refresh": "5s",
  "panels": [
    {
      "id": 1,
      "title": "Total Vehicles",
      "type": "stat",
      "gridPos": {
        "x": 0,
        "y": 0,
        "w": 4,
        "h": 4
      },
      "targets": [
        {
          "query": "from(bucket: \"iot_data\") |> range(start: -24h) |> filter(fn: (r) => r[\"_measurement\"] == \"traffic\") |> group(columns: [\"sensor_id\"]) |> sum()"
        }
      ],
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "justifyMode": "center",
        "orientation": "auto"
      },
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "color": {
            "mode": "thresholds"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "yellow",
                "value": 150
              },
              {
                "color": "red",
                "value": 300
              }
            ]
          }
        }
      }
    },
    {
      "id": 2,
      "title": "Average Air Quality Index",
      "type": "gauge",
      "gridPos": {
        "x": 4,
        "y": 0,
        "w": 4,
        "h": 4
      },
      "targets": [
        {
          "query": "from(bucket: \"iot_data\") |> range(start: -24h) |> filter(fn: (r) => r[\"_measurement\"] == \"airquality\") |> mean(column: \"air_quality_index\")"
        }
      ],
      "options": {
        "showThresholdLabels": false,
        "showThresholdMarkers": true
      },
      "fieldConfig": {
        "defaults": {
          "min": 1,
          "max": 5,
          "unit": "short",
          "color": {
            "mode": "thresholds"
          },
          "thresholds": {
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "yellow",
                "value": 2
              },
              {
                "color": "orange",
                "value": 3
              },
              {
                "color": "red",
                "value": 4
              }
            ]
          }
        }
      }
    },
    {
      "id": 3,
      "title": "Available Parking Spots",
      "type": "stat",
      "gridPos": {
        "x": 8,
        "y": 0,
        "w": 4,
        "h": 4
      },
      "targets": [
        {
          "query": "from(bucket: \"iot_data\") |> range(start: -24h) |> filter(fn: (r) => r[\"_measurement\"] == \"parking\") |> sum(column: \"available_spots\")"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "color": {
            "mode": "thresholds"
          },
          "thresholds": {
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "yellow",
                "value": 50
              },
              {
                "color": "green",
                "value": 100
              }
            ]
          }
        }
      }
    },
    {
      "id": 4,
      "title": "Average Noise Level",
      "type": "gauge",
      "gridPos": {
        "x": 12,
        "y": 0,
        "w": 4,
        "h": 4
      },
      "targets": [
        {
          "query": "from(bucket: \"iot_data\") |> range(start: -24h) |> filter(fn: (r) => r[\"_measurement\"] == \"noise\") |> mean(column: \"noise_level_db\")"
        }
      ],
      "options": {
        "showThresholdLabels": false,
        "showThresholdMarkers": true
      },
      "fieldConfig": {
        "defaults": {
          "min": 30,
          "max": 100,
          "unit": "dB",
          "color": {
            "mode": "thresholds"
          },
          "thresholds": {
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "yellow",
                "value": 60
              },
              {
                "color": "orange",
                "value": 75
              },
              {
                "color": "red",
                "value": 85
              }
            ]
          }
        }
      }
    },
    {
      "id": 5,
      "title": "Traffic Over Time",
      "type": "timeseries",
      "gridPos": {
        "x": 0,
        "y": 4,
        "w": 12,
        "h": 6
      },
      "targets": [
        {
          "query": "from(bucket: \"iot_data\") |> range(start: -24h) |> filter(fn: (r) => r[\"_measurement\"] == \"traffic\") |> aggregateWindow(every: 1m, fn: mean)"
        }
      ],
      "options": {
        "legend": {
          "displayMode": "hidden"
        },
        "tooltip": {
          "mode": "single"
        }
      },
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "lineWidth": 2,
            "fillOpacity": 10,
            "gradientMode": "opacity"
          }
        }
      }
    },
    {
      "id": 6,
      "title": "Air Quality - PM2.5",
      "type": "timeseries",
      "gridPos": {
        "x": 12,
        "y": 4,
        "w": 12,
        "h": 6
      },
      "targets": [
        {
          "query": "from(bucket: \"iot_data\") |> range(start: -24h) |> filter(fn: (r) => r[\"_measurement\"] == \"airquality\") |> aggregateWindow(every: 1m, fn: mean)"
        }
      ],
      "options": {
        "legend": {
          "displayMode": "hidden"
        },
        "tooltip": {
          "mode": "single"
        }
      },
      "fieldConfig": {
        "defaults": {
          "unit": "\u03bcg/m\u00b3",
          "color": {
            "mode": "palette-classic"
          }
        }
      }
    },
    {
      "id": 7,
      "title": "Parking Availability",
      "type": "piechart",
      "gridPos": {
        "x": 0,
        "y": 10,
        "w": 8,
        "h": 6
      },
      "targets": [
        {
          "query": "from(bucket: \"iot_data\") |> range(start: -24h) |> filter(fn: (r) => r[\"_measurement\"] == \"parking\") |> group(columns: [\"sensor_name\"]) |> sum()"
        }
      ],
      "options": {
        "pieType": "donut",
        "displayLabels": "name",
        "legend": {
          "displayMode": "table",
          "placement": "right",
          "values": [
            "value"
          ]
        }
      }
    },
    {
      "id": 8,
      "title": "Weather Conditions",
      "type": "timeseries",
      "gridPos": {
        "x": 8,
        "y": 10,
        "w": 16,
        "h": 6
      },
      "targets": [
        {
          "query": "from(bucket: \"iot_data\") |> range(start: -24h) |> filter(fn: (r) => r[\"_measurement\"] == \"weather\") |> aggregateWindow(every: 5m, fn: mean)"
        }
      ],
      "options": {
        "legend": {
          "displayMode": "hidden"
        },
        "tooltip": {
          "mode": "single"
        }
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "lineWidth": 2,
            "fillOpacity": 5
          }
        }
      }
    }
  ],
  "time": {
    "from": "now-24h",
    "to": "now"
  }
}