Build charts with data from mysql database

hello,

I am trying to build a chart with some data from mysql database.
I have a query to the database and it returns a object with temperatures that I want to send to a chart and make a line chart. So that I can see the change of temperature through the last 30 days.

This is the output of the query:
image

I receive the month and the respective average temperature. Ou is it possible to put it in a line chart?

It should certainly be possible. The help info in the ui_chart node signposts you to the correct data formatting. I don't use it often enough to remember off the top of my head.

The UI charts, at least the line chart, generally anticipates that the X axis will be JavaScript date/time values I think? So you may have to pass an additional parameter to change to your simple month number - though don't take that as gospel, again the help info should give you the right format.

1 Like

Have a look at


as a start.
How do you want your x-axis labels to be? You might want to convert the_month to a timestamp?
2 Likes

@cinhcet The x-axis should have the months number and the y-axis should have temperature values.

I am trying to do as the example in end of that github page you sent but no luck yet:

in the x axis theres some timestamp, and I wanted the month and in the y axis I don't know where it is found. I found that guide not very well explained, could have at least a graphical example.

But that is the chart I am getting and the flow is this:

I know it is confusing but, I used those change flows to get the average from the object, there's the average of each month and then join them in an array that I use in the function and send to the chart

The label and topic flows I got from the example, but I don't understand how they work.

The data function as the following code:

var m={
    "series":["X"],
    "data": msg.payload,
    "labels":["Jul","Aug","Sept", "Oct", "Nov"]
};
return {payload:[m]};

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.