Create chart reading data from database

Hello, I'm new in Node-red programming.I must create a dashboard with charts reading data from a database, I have everything installed on Docker. I had a lot of issues to connect the database, the result it's always "ETIMEDOUT". So my tutor suggested me to create a page in node-red (http in) and I have inserted all the data in this page. How can I let the charts reading the data from this page?Thank you very much

Can someone help me please?

Which bit don't you know how to do? Fetching the data from the db or displaying it in a chart?

I cannot in anyway connect to the database, [the error message is always etimedout, even my tutor couldn't solve the problem I installed everything on docker], and then I don't know how I can display data in a chart
Thank you very much

Sorry, I misread your post, I thought you were still trying to get it from the database (the problem there is probably Docker related I expect, you could try installing without Docker if you want to try that again).

I don't know what you mean by that, but assuming you have got the data into node-red then I don't need to understand. Feed that data into a debug node and show us what it looks like.
This page - https://github.com/node-red/node-red-dashboard/blob/master/Charts.md - shows you how you have to structure the data for feeding to that chart. If you don't know how to do that have a look at the node red docs page Working with Messages.

Hello, thank you very much. I have success in show the data in the chart with this method, but I haven't success reading the data from the database, perhaps I'm wrong with the nodes and the query, but I didn't understand where. Is there a detailed guide explain every single step? I didn't find anything could help me completely.
Thank you very much

As I suggested, I imagine the database connection issue was probably a Docker related issue. Did you try doing a normal node-red install or are you not able to do that?

Finally I had success to connect the database, the problem that I still have is reading the data and let the chart show them, I have no error in debug, so I don't understand where I'm wrong, if I used wrong nodes, wrong function or query.

What type of dB is it?
What db node are you using?
Show us what the message you are sending to the node looks like, and what the message coming out looks like, using debug nodes of course.

I'm using the Template Mysql on Docker, and the node Stackhero MySql. I tried a lot of solutions with function, template ecc...nothing I don't know how and where make the write query, I dind't saw a complete guide about making query where and how and which node use.
Thank you

[{"id":"cca6fe3.d61d","type":"tab","label":"Dashboard","disabled":false,"info":""},{"id":"9ebeafa7.d93068","type":"ui_chart","z":"cca6fe3.d61d","name":"Line chart","group":"be095263.b9616","order":2,"width":0,"height":0,"label":"Line chart","chartType":"line","legend":"true","xformat":"auto","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1240,"y":420,"wires":[[]]},{"id":"41ee70cf.286498","type":"ui_chart","z":"cca6fe3.d61d","name":"Radar Chart","group":"1d6a585.01f5d28","order":2,"width":0,"height":0,"label":"Radar Chart","chartType":"radar","legend":"true","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":true,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1230,"y":540,"wires":[[]]},{"id":"5f69e98b.37ba48","type":"ui_chart","z":"cca6fe3.d61d","name":"Bar Chart ","group":"b8a66ed1.d5bbc8","order":1,"width":0,"height":0,"label":"Bar Chart","chartType":"bar","legend":"true","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1240,"y":480,"wires":[[]]},{"id":"769f93e1.d7ed44","type":"ui_chart","z":"cca6fe3.d61d","name":"Pie Chart","group":"be095263.b9616","order":1,"width":0,"height":0,"label":"Pie Chart","chartType":"pie","legend":"true","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"20","ymax":"60","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":"30","useOneColor":true,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1200,"y":660,"wires":[[]]},{"id":"ab6b12bf.113d78","type":"ui_button","z":"cca6fe3.d61d","name":"","group":"f4be6707.b57a28","order":3,"width":0,"height":0,"passthru":false,"label":"Sesso","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":370,"y":640,"wires":[["924ac8be.aae73"]]},{"id":"82b668a5.1c50d8","type":"ui_button","z":"cca6fe3.d61d","name":"","group":"f4be6707.b57a28","order":4,"width":0,"height":0,"passthru":false,"label":"Hobbies","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":380,"y":560,"wires":[["3123c853.94a7d"]]},{"id":"e9b98bb.d9aab78","type":"ui_button","z":"cca6fe3.d61d","name":"","group":"f4be6707.b57a28","order":5,"width":0,"height":0,"passthru":false,"label":"Azzera i dati","tooltip":"","color":"","bgcolor":"","icon":"","payload":"[]","payloadType":"json","topic":"","x":910,"y":180,"wires":[["9ebeafa7.d93068","41ee70cf.286498","5f69e98b.37ba48","769f93e1.d7ed44","b0a10471.575af8","efbfabd.0f6c558"]]},{"id":"844c00c4.7f5458","type":"ui_button","z":"cca6fe3.d61d","name":"","group":"f4be6707.b57a28","order":2,"width":0,"height":0,"passthru":false,"label":"Professione","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"num","topic":"","x":390,"y":480,"wires":[["798cce81.1d7f98"]]},{"id":"b0a10471.575af8","type":"ui_chart","z":"cca6fe3.d61d","name":"Polar area chart","group":"1d6a585.01f5d28","order":1,"width":0,"height":0,"label":"Polar area chart","chartType":"polar-area","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1220,"y":720,"wires":[[]]},{"id":"3123c853.94a7d","type":"function","z":"cca6fe3.d61d","name":"","func":"var m={};\nm.labels = [\"Musica\", \"Cinema\", \"Arte\", \"Sport\", \"Fai da te\", \"Teatro\"];\nm.series = ['Donne', 'Uomini'];\nm.data = [\n   [16, 29, 10, 21, 2, 12],\n    [6, 19, 5, 30,20, 2]\n  ];\nreturn {payload:[m]};\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":560,"y":580,"wires":[["9ebeafa7.d93068","41ee70cf.286498","5f69e98b.37ba48","769f93e1.d7ed44","b0a10471.575af8","efbfabd.0f6c558"]]},{"id":"efbfabd.0f6c558","type":"ui_chart","z":"cca6fe3.d61d","name":"Horizontal Bar ","group":"b8a66ed1.d5bbc8","order":2,"width":0,"height":0,"label":"Horizontal Bar ","chartType":"horizontalBar","legend":"true","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":1240,"y":600,"wires":[[]]},{"id":"924ac8be.aae73","type":"function","z":"cca6fe3.d61d","name":"","func":"var m={};\nm.labels = [\"Sesso\"];\nm.series = ['Donne', 'Uomini'];\nm.data = [\n   [33],\n    [37]\n  ];\nreturn {payload:[m]};\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":560,"y":660,"wires":[["5f69e98b.37ba48","efbfabd.0f6c558"]]},{"id":"798cce81.1d7f98","type":"function","z":"cca6fe3.d61d","name":"","func":"var m={};\nm.labels = [\"Medico\", \"Insegnante\", \"Studente\", \"Atleta\", \"Attore\", \"Impiegato\", \"Muratore\", \"Scrittore\"];\nm.series = ['Donne', 'Uomini'];\nm.data = [\n   [10, 9, 8, 3, 4, 8, 4, 4],\n    [5, 11, 7, 4, 3, 7, 6, 8]\n  ];\nreturn {payload:[m]};\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":560,"y":500,"wires":[["9ebeafa7.d93068","5f69e98b.37ba48","41ee70cf.286498","769f93e1.d7ed44","b0a10471.575af8","efbfabd.0f6c558"]]},{"id":"113ed435.8a49ec","type":"Stackhero-MySQL","z":"cca6fe3.d61d","server":"e96c13a0.7a485","name":"","x":830,"y":280,"wires":[["9ebeafa7.d93068"]]},{"id":"6bf5ea1f.013e7c","type":"function","z":"cca6fe3.d61d","name":"Inserisci i dati","func":"var id = msg.payload.id;\n\nvar nome = msg.payload.nome;\n\nvar sesso = msg.payload.sesso;\n\nvar cittadinanza = msg.payload.cittadinanza;\n\nvar professione = msg.payload.professione;\n\nvar hobbies = msg.payload.hobbies; \n\n\nmsg.topic = \"INSERT INTO `test`.`partecipanti` (`Id`, `Nome`, 'Sesso', 'Cittadinanza', 'Professione', 'Hobbies') VALUES (\" +id+  \",\" +nome+ \",\" +sesso+ \",\" +cittadinanza+ \",\" +professione+ \",\" +hobbies+ \")\";\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":360,"y":160,"wires":[[]]},{"id":"f6e7f0d1.35cec","type":"inject","z":"cca6fe3.d61d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":160,"wires":[["6bf5ea1f.013e7c"]]},{"id":"2f211bc.69b7a64","type":"inject","z":"cca6fe3.d61d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"INSERT INTO test (id,nome, sesso, cittadinanza, professione, hobbies) VALUES (?,?,?,?,?,?)","payload":"","payloadType":"date","x":170,"y":240,"wires":[["8c917735.e650f8"]]},{"id":"8c917735.e650f8","type":"json","z":"cca6fe3.d61d","name":"","property":"payload","action":"","pretty":false,"x":320,"y":240,"wires":[[]]},{"id":"970bb585.3d40f","type":"debug","z":"cca6fe3.d61d","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1250,"y":240,"wires":[]},{"id":"5f9f9a44.33c2ec","type":"ui_button","z":"cca6fe3.d61d","name":"","group":"f4be6707.b57a28","order":1,"width":0,"height":0,"passthru":false,"label":"Cittadinanza","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"num","topic":"","x":390,"y":400,"wires":[["344a2d10.098f7a"]]},{"id":"344a2d10.098f7a","type":"template","z":"cca6fe3.d61d","name":"Select","field":"payload","fieldType":"msg","format":"sql","syntax":"mustache","template":"msg.topic = 'SELECT cittadinanza FROM test.partecipanti Group by Cittadinanza with rollup';\nreturn = chart; ","output":"str","x":630,"y":400,"wires":[["113ed435.8a49ec","970bb585.3d40f"]]},{"id":"3fa6c868.9256d8","type":"inject","z":"cca6fe3.d61d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":460,"y":320,"wires":[["344a2d10.098f7a"]]},{"id":"be095263.b9616","type":"ui_group","name":"Charts","tab":"fffa5e09.2e08e8","order":2,"disp":false,"width":"6","collapse":false},{"id":"1d6a585.01f5d28","type":"ui_group","name":"Charts 3","tab":"fffa5e09.2e08e8","order":4,"disp":false,"width":"6","collapse":false},{"id":"b8a66ed1.d5bbc8","type":"ui_group","name":"Charts2","tab":"fffa5e09.2e08e8","order":3,"disp":false,"width":"6","collapse":false},{"id":"f4be6707.b57a28","type":"ui_group","name":"Input","tab":"fffa5e09.2e08e8","order":1,"disp":false,"width":"4","collapse":false},{"id":"e96c13a0.7a485","type":"Stackhero-MySQL-Server","name":"","host":"172.17.0.4","port":"3306","tls":false,"database":"test"},{"id":"fffa5e09.2e08e8","type":"ui_tab","name":"Home","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

I have no idea what that means

I don't know that node, but presumably you have a reason that you are using that one rather than node-red-node-mysql. I have looked at the nodes readme (https://flows.nodered.org/node/node-red-contrib-stackhero-mysql) and it tells you there how to pass it a query and gives an example of how to do it. So what exactly is it that you don't know how to do?

I have used that node, coz the teacher wanted that.
I followed different examples, as you posted me last time. If I post static data in the function, my charts show me all the data, but if I try to read the data from the database (and here it's the problem) I don't get anything when I open the dashboard and ask the chart showing me the data.
Are the nodes correctly chosen? The order? where I must put the select query?

Actually I wrote it into the template select...but when I open the dashboard nothing happens when I click on the node button "Cittadinanza"

Yes that looks ok, except that, of course, you won't be able to feed the data straight out of the db and into the chart, you will need to reorganise the data into the correct format for the chart. The first thing to do is to make sure that you are getting the right data out of the database.

Is it correct?

Well if you are getting the right data out of the database (as checked in a debug node) then obviously it is correct.

So why I cannot see anything in the chart connected?

Is the data you are sending in the correct format for a chart as described in the link I posted 5 days ago? https://github.com/node-red/node-red-dashboard/blob/master/Charts.md We seem to be going round in circles here.

In the static function (those I tried before I had success in connecting the tb) yes and I saw everything in the charts, but I thought I didn't need static data when I must read them from database , so I didn't understand how I must use this function when I'm connected to the database.
Sorry

You need to structure the data to the form expected by the chart. If you just throw random data at it then it doesn't know what to do with it.

I don't want take more of your precious time, I don't put random data. I will study again this function and study the structure. Sorry I disturbed you too much. And thank you again