Templating with postgres Data source

I am using a postgres datasource. Lets say I have a query that looks like the below in the simplestic form

timestamp as time,
count(1) as count
where account=$account
and to_char(timestamp,‘YYYY-MM-DD’) in ($time_var )
group by time, count

In the above query, account and time_var are variables.
[ *** account is a variable and can have multiple values ]
[ ***time_var is a variable and can have multiple values ]

What I wanted to achieve is to be able to plot the graphs in a single panel ( for one or multiple account variables ). The graph is a line graph that will plot “count” v/s timestamp. Is that possible? Also, I want to see the “account” as a display for each corresponding graph plotted along with the “count” value so that the graphs can be uniquely identified.