Hi Andrea welcome to the forum
Which part are you stuck on querying the database or building the chart?
There are quite a few examples of mySQL to chart in the forum already if you search.
E.g. this one works pretty much without modification: Dynamic series identification from message, send data to Chart - #5 by Steve-Mcl