Is there a way to display aggregate device data in Pie Chart widget?

Is there a way to display aggregate device data in Pie Chart widget?

I'd like to display device statistics on a Pie Chart widget, like the number of online devices, the total number of device errors, an average value of a metric for all devices visible to the current user, etc.

Example: I have two variables (status_online and status_offline which are either 0 or 1, depending on the device status). I'd like to count these two for all devices visible to the user currently logged in, and show them as data sources in a pie chart widget.

What would be the easiest way to do this?

I assume I could create a custom pie chart widget which uses queries from Account.AccessManagement and Account.Devices, but that sounds complex, and I'd also have a consistent look with the build-in Pie Chart widget. Is there a built-in way to run such queries and display the result in a chart?