Hello guys,
This is my first post on the forum. I want to print a highchart
Problem : I am facing issue with use of array in mustache format of template node.
If my msg.payload = [[0,1],[2,3]]
this turns {{payload}} into 0,1,2,3 removing any character in payload just leaving comma
[
{
"id": "78a6fa27.cac624",
"type": "function",
"z": "4d76d926.b15d48",
"name": "Object to Array",
"func": "\n\tmsg.payload = [[110, 1],[1, 2],[2, 10]]\n\t\n\t\treturn msg",
"outputs": 1,
"noerr": 0,
"x": 440,
"y": 1940,
"wires": [
[
"9cab8967.24c438",
"63c23958.bb1fc8"
]
]
},
{
"id": "9cab8967.24c438",
"type": "template",
"z": "4d76d926.b15d48",
"name": "",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "<!DOCTYPE html>\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n<meta charset=\"utf-8\" />\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n<script src=\"https://code.highcharts.com/stock/highstock.js\"></script>\n<script src=\"https://code.highcharts.com/stock/modules/data.js\"></script>\n<script src=\"https://code.highcharts.com/stock/modules/exporting.js\"></script>\n<script src=\"https://code.highcharts.com/stock/modules/export-data.js\"></script>\n\n</head>\n<body>\n<script src=\"https://code.highcharts.com/highcharts.js\"></script>\n<div id=\"container\"></div> \n<script>\n \n Highcharts.stockChart('container', {\n\n title: {\n text: 'AAPL Stock Price'\n },\n\n series: [{\n name: 'AAPL',\n // data: {{payload}},\n data: [[0,1],[1,2],[2,10]],\n tooltip: {\n valueDecimals: 2\n }\n }],\n \n rangeSelector: {\n enabled: true\n },\n });\n </script>\n</body>\n</html>\n",
"output": "str",
"x": 720,
"y": 1920,
"wires": [
[
"b254c6a7.1b5818"
]
]
},
{
"id": "7d99e933.ac36b8",
"type": "http in",
"z": "4d76d926.b15d48",
"name": "",
"url": "/chart123",
"method": "get",
"upload": false,
"swaggerDoc": "",
"x": 250,
"y": 1940,
"wires": [
[
"78a6fa27.cac624"
]
]
},
{
"id": "b254c6a7.1b5818",
"type": "http response",
"z": "4d76d926.b15d48",
"name": "",
"statusCode": "",
"headers": {},
"x": 710,
"y": 2020,
"wires": []
},
{
"id": "63c23958.bb1fc8",
"type": "debug",
"z": "4d76d926.b15d48",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 580,
"y": 2100,
"wires": []
}
]