How to plot Line Chart Using Dates and Values from a table

Hi Grafana Community,

This is my first post and I am new to Grafana and learning each day.
I have a question regarding creating a dashboard with a line chart.
My data is from a PostgreSQL table. The data is like:

Date | A | B | C
2020-03-02 | 21 | 0 | 3
2020-03-09 | 37 | 4 | 2
2020-03-23 | 83 | 6 | 8
2020-03-30 | 57 | 10 | 10
2020-04-06 | 33 | 2 | 10
2020-04-13 | 37 | 7 | 6
2020-04-20 | 103 | 20 | 16

How can I show a line chart with Column A and Column Date. And another line chart with Column A,B, C with respect to the Column Date?
Regards,
Sudeep

Hi and welcome in the Grafana Community! :slight_smile:

First of all, if you don’t know how to add your PostgreSQL datasource or create a graph panel, I encourage you to follow this great tutorial on Grafana fundamentals:

But if you know how to do all of this and your question is on the query part, you can write your query by selecting the different fields in the Query Editor like this:

Where time_date_time will be your Date column, value_float will be A and value_double will be B. To add columns, just click on the “+” button and select “column”.

Does it answer your question?

@agnestoulet1
Thank you for your kind reply.
Yes, I am able to configure my data source successfully, and I am able to show my required dashboard in tabular formats. The problem I am facing is one with a line/bar chart.

In the database, my date column is of ‘date’ type not timestamp.
And, in my Query editor, I have ‘Time Column’ not ‘time_date_time’. Also, I am not able to find my date column from the table in the list to select. But, it is showing all other columns which are of integer type in the database.
Below is the screenshot for reference.
Many thanks again for your time and help. Kindly suggest.

Capture2

Regards,
Sudeep

@agnestoulet1

After I changed my database column type date to timestamp, I can see the column in the Time column list and able to select it. Thanks!

If you don’t want to change your data type you can also click on “toggle text edit mode” (the little pen on the top bar of the query) and here you can write the name of the column you want. It will work with date type.
image

Hi @agnestoulet1,

Thank you for the insight. I am able to plot my line chart successfully. Many thanks.