I have a working example of generating a chart, creating a chart image and sending to email as attachment.
what i need is to embed the chart image in the body of the mail.
how do i do that ?
or
how do i convert the chart image into html content ?
[{"id":"e284de4.fc6a12","type":"function","z":"7ca35fb6225bb9ac","name":"Line Chart","func":"function getGetOrdinal(n) {\n var s=[\"th\",\"st\",\"nd\",\"rd\"],\n v=n%100;\n return n+(s[(v-20)%10]||s[v]||s[0]);\n }\n\nvar dL = [\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"];\nvar dS = [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"];\nvar mL = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];\nvar mS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'];\n\nlet now = new Date();\n\n// Create the chart object\nlet m = {\n type: 'line',\n options: {\n title: {\n display:true,\n text:'Line chart example'\n },\n legend: {\n display:false\n },\n chartArea: {\n backgroundColor: 'white'\n },\n plugins: {\n datalabels: {\n display:true,\n backgroundColor:'whitesmoke',\n borderRadius:1,\n padding:1,\n align: 'right',\n anchor: function(context) {\n //node.send({debug:{dataindex:context.dataIndex}});\n if (context.dataIndex == context.dataset.data.length - 1) {\n return 'center';\n } else {\n return 'end';\n }\n },\n offset:8,\n formatter:function(value) {\n return value > 0 ? value.toLocaleString() : '';\n }\n }\n }\n },\n data: {\n labels:[],\n datasets: [\n {\n label:\"Sample data\",\n borderColor:'rgba(57,97,184,0.8)',\n fill:false,\n data:[]\n }\n ]\n }\n}\n\nlet l = Math.floor(Math.random()*50);\n\nfor (let i=0; i<10; i++) {\n l = l + Math.floor(Math.random()*6)-3;\n m.data.datasets[0].data.push(l);\n var d = new Date();\n d.setTime(now.getTime()-1000*60*60*24*(10-i));\n m.data.labels.push(dL[d.getDay()]+\", \"+getGetOrdinal(d.getDate()));\n}\n\nmsg.payload = m;\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":330,"y":1580,"wires":[["f7e11042.f96d9"]]},{"id":"f7e11042.f96d9","type":"chart-image","z":"7ca35fb6225bb9ac","name":"","width":500,"height":"500","x":550,"y":1580,"wires":[["62271758.c63728","fac75646.ed0358"]]},{"id":"f9531538.ab1988","type":"inject","z":"7ca35fb6225bb9ac","name":"Line Chart","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":1580,"wires":[["e284de4.fc6a12"]]},{"id":"fac75646.ed0358","type":"change","z":"7ca35fb6225bb9ac","name":"Set up the email","rules":[{"t":"set","p":"attachments","pt":"msg","to":"{}","tot":"msg"},{"t":"set","p":"attachments.content","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"attachments.filename","pt":"msg","to":"chart.jpg","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Chart example","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"This is the auto generated chart","tot":"str"},{"t":"set","p":"to","pt":"msg","to":"someone@somewhere.com","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":1580,"wires":[["fdcdbc42e7c7b83d"]]}]