Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Showing a Pie Chart based on device properties

Devis Lucato edited this page Jun 27, 2017 · 10 revisions

Step 1: Get the list of devices

The user selects a device group, which implicitly defines the query to use to fetch the list of devices. See the Config UI API for more information.

Request

GET {IoT Hub manager endpoint}/devices?query={query}

Response

Content-Type: application/json; charset=utf-8

{
    Count: ...
    Items: [
        { device }
        { device }
        { device }
        ...
    ]
    "$metadata": {
        $type: DevicesList;1
        $uri: {IoT Hub manager endpoint}/devices?query={query}
    }
}

Note that the content of the response might change over time, for instance when devices are added or removed, and when device properties change. For instance a query like "all devices with firmware 1.2" would return a different list over time. The UI decides whether to cache and reuse the query result, or whether to repeat the query to refresh the response.

Step 2: Calculate pie chart data

The pie chart represents data about a specific property, e.g. "firmware version", which might have multiple values.

The UI application loops through the devices, looking for the "firmware version" property, and counts the distinct values (= number of slices) and the the occurrences of each distinct value (= size of each slice).