Pie chart Influxdb and Grafana

Hi there,
I am new to grafana and influxdb
I want to create a pie chart for stringValues that are changing by time

simple example:

from my server I receive string data to indicate the name of the city that I am currently in, that would be changing by time (travelling). I want to make a pie chart that can show me how much time I spent in each city for the last 5hours.

I tried this:
SELECT last(“stringValue”) FROM “navigation.state” WHERE (“source” = ‘python_script’) AND $timeFilter GROUP BY time($__interval) fill(previous)

and it didn’t work, could you please help me.