I could not have put it better. Yes, I am successfully able to generate data from mysql and process it to correctly display it on a dashboard. i also able to successfully use the sample provided by the chart image node example to export an image of a chart to telegram with the provided static data. i want to now incorporate the data extracted by mysql query into the format to generate the chart image. as you correctly said, the chart image needs the data format in a particular syntax, which i am unable to understand.
i need to understand how to modify the code in the circled function node below to get my dynamic data from mysql query.
So put a debug node on the output of the function node (labeled "Vertical Bar Chart") and you will see what the format of the data is that needs to be send to the chart-image.
If you open the 'Help' tab for the chart-image node you will see you need to create a form using chart.js and it provides you a link to Chart.js documentation.
This should give you the knowledge to create a function node to transform the MySQL data into what is needed to create the chart-image.
Since you have an example set of data, you can use that for testing insteading of hitting the mysql server each time you test.
If you run into an issue with the function node you will be building, you can export your flow and show us what you have done so far. That way people can give you suggestions on how to change your code to get the results you want.
I would say let me try, but I would be kidding myself. have zero knowledge in js and the documentation will just fly over my head. thanks for trying to help. really appreciate that.
is there a way i save the data from mysql query to an object using context data (flow.set) and then use the same to get the data in the function node (flow.get) ?
You start long journey by taking the first step. So take a tutorial.
Why? If the data out of the mysql node is going into the function node, why would you want to put it in storage?
Have you watched this playlist: Node-RED Essentials? The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.
the whole problem i am getting into is that i am unable to get a dynamic data into a function node, in the prescribed format. building up an object/array i think what it is called.
thanks for the encouragement, let me take the tutorials and try to understand JS a little bit. project for the weekend i think.
i have seen the node-red essential tutorials and doesn't hurt to go through them once again. will sure do.
i have to replace the data i get from mysql as below, payload[0].data
into payload.data.datasets[0].data
the trouble is this static random data is generated in the function node by a for-loop and push data method (i hope that is what is happening,), the part of the function node i need to replace to get the data from mysql object.
i am not even sure that i am making any sense here using names that i don't undestand.
well it is already doing more than half of the job, i just need to put my dynamic data into it, so i am improvising the node. as i said, i am not even a beginner i am just copying and modifying the node from example to get first the output right, and then see how it works.
by the way , i am now successfully getting the data into the example using flow.get method in the function node, i was able to get the flow.get into the right position in the function node, by trial and error.
this is the chart in the dashboard
same data using chart-image node with
i know i have not followed the path that is correct, but this workaround is easier for me,
store the data into flow context with flow.set and then get the data into function node with flow.get
next step, beautification and turning bars into Horizontal bars.
i am really happy that i did not give up. thanks to you.