Display over a 24 hour period whether a machine is off, idle or on

I’m new to influx and grafana and want to know in terms of percentage over a 24 hour period on whether the machine is off, idle or on. The data is stored in influx under state value, either 0 = off, 1 = idle and 2 = on. How can I achieve this in influx query or grafana? Any pointers or help is appreciated.