# Simple Chart Assistance

**URL:** <https://community.grafana.com/t/simple-chart-assistance/4498>\
**Category:** Time Series Panel\
**Created:** [December 24, 2017, 8:01pm UTC](https://community.grafana.com/t/simple-chart-assistance/4498 "2017-12-24T20:01:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![snkhan](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/snkhan/32/2433_2.png) [@snkhan](https://community.grafana.com/u/snkhan)\
**Post date:** [December 24, 2017, 8:01pm UTC](https://community.grafana.com/t/simple-chart-assistance/4498/1 "2017-12-24T20:01:06Z")

</div>

Hello there, new Grafana user here.

I am hoping to use Grafana to create dashboards from data that is held on a local Postgres database. The Query Editor is working correctly and returning data as I would expect. However, I am struggling to plot this data in a graph.

One of my queries returns a list of items, and their corresponding count. I want the list of items along the x axis, and the count on the y - fairly standard stuff. I have selected ‘Graph’ as the panel type, but it would appear that this only likes to plot things when the x axis contains a time/date value. I have set the X-Axis mode to ‘Series’ as suggested in the docs, but am really struggling to get the graph to work at all.

Query:

```
SELECT COUNT(items) AS Count, items 
FROM global
GROUP BY items
ORDER BY Count DESC;

```

Would really appreciate some help as how to get this working!

---

<div class="post-metadata">

**Author:** ![snkhan](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/snkhan/32/2433_2.png) [@snkhan](https://community.grafana.com/u/snkhan)\
**Post date:** [December 26, 2017, 5:14pm UTC](https://community.grafana.com/t/simple-chart-assistance/4498/2 "2017-12-26T17:14:47Z")

</div>

I am trying to plot a chart using some Time Series data, however, the graph is not plotting as I would expect.

I am doing a count on the time column exclusively, and wanting to plot data per hour. The timestamp is a standard format, e.g., `2017-12-10 05:07:12`.

The SQL query I have is:

```
SELECT observation_date AS time, COUNT(date_trunc('hour', observation_date))
FROM global
GROUP BY time;

```

However, this is generating a very unusual chart:

 ![03](https://us1.discourse-cdn.com/grafana/original/2X/4/485d42890d5c8cd242f9528de1146c65b51e04f9.png)

I also wondered how I could format the date/time x values in the UK format, namely DD/MM, rather than MM/DD. I have set the unit as `locale format`, which does not appear to have helped.

This is what I am hoping to plot:

![16](https://us1.discourse-cdn.com/grafana/original/2X/3/30a5d0ce9e431f21703af2e25938b7525ecc9050.png)

Other things I have tried is also wrapping the query with the macro as follows:

```
SELECT $__time(observation_date)

```

and also

```
COUNT(date_trunc('day', observation_date)) AS metric

```

However these don’t seem to help, with the latter returning a `Column metric must be of type char,varchar or text` error.

Would really appreciate your help!

---

<div class="post-metadata">

**Author:** ![jitans](https://avatars.discourse-cdn.com/v4/letter/j/5f9b8f/32.png) [@jitans](https://community.grafana.com/u/jitans)\
**Post date:** [March 11, 2018, 4:08pm UTC](https://community.grafana.com/t/simple-chart-assistance/4498/3 "2018-03-11T16:08:19Z")

</div>

You need to add: “SORT BY time”
