Hi,
I tried to build input object for the chart using official documentation. I read CSV file as one playload and using this function for creating data object from payload:
var dataval = [];
var i;
for (i = 0; i < msg.payload.length;i++){
// Convert to date
var s = msg.payload[i].Datum;
var sa = s.trim().replace(/\s/g,'').replace(" ","").split(".");
var fordat = sa[2] + "-" + sa[1] + "-" + sa[0];
var dat = new Date(fordat).getTime(); // Final date
// Create X,Y object
var one = {"X": dat, "Y": parseFloat(msg.payload[i].Hodnota)};
dataval.push(one);
}
var chart = [{"data": dataval,"labels": ["XXX"],"series": ["X"]}];
return chart;
Final object looks like this:
But there still aren't any visible data in chart. What is wrong?
EDIT:
- I am using NR v0.20.8
- I am using basic chart node for official Dashboard to create a line chart
3)Here is my flow:
[{"id":"d47a8733.87bbc","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"dd032bb.dcde4d8","type":"csv","z":"d47a8733.87bbc","name":"","sep":";","hdrin":true,"hdrout":"","multi":"mult","ret":"\\n","temp":"","skip":"0","x":459,"y":80,"wires":[["ac1074c7.b17b28"]]},{"id":"9ec7fb30.54dd3","type":"http request","z":"d47a8733.87bbc","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"https://www.csob.cz/portal/lide/investicni-produkty/podilove-fondy/vsechny-fondy/detail-fondu?p_p_id=etnpwfundsdetail_WAR_etnpwfunds&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=exportData&p_p_cacheability=cacheLevelPage&p_p_col_id=column-main&p_p_col_pos=1&p_p_col_count=10&_etnpwfundsdetail_WAR_etnpwfunds_dateToMillis=1568844000000&_etnpwfundsdetail_WAR_etnpwfunds_dateFromMillis=1253311200000&_etnpwfundsdetail_WAR_etnpwfunds_resources=1&_etnpwfundsdetail_WAR_etnpwfunds_isin=BE0174398892&_etnpwfundsdetail_WAR_etnpwfunds_groupId=4","tls":"","proxy":"","authType":"","x":294,"y":80,"wires":[["dd032bb.dcde4d8"]]},{"id":"7f236b29.fb8f44","type":"inject","z":"d47a8733.87bbc","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":123,"y":80,"wires":[["9ec7fb30.54dd3"]]},{"id":"fffe42b4.aeb9f","type":"ui_button","z":"d47a8733.87bbc","name":"","group":"46f66c9e.fd4ffc","order":0,"width":0,"height":0,"passthru":false,"label":"Start","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":134,"y":126,"wires":[["9ec7fb30.54dd3"]]},{"id":"ac1074c7.b17b28","type":"function","z":"d47a8733.87bbc","name":"","func":"\nvar dataval = [];\nvar i;\n\nfor (i = 0; i < msg.payload.length;i++){\n \n // Convert to date\n var s = msg.payload[i].Datum;\n var sa = s.trim().replace(/\\s/g,'').replace(\" \",\"\").split(\".\");\n var fordat = sa[2] + \"-\" + sa[1] + \"-\" + sa[0];\n var dat = new Date(fordat).getTime(); // Final date\n \n // Create X,Y object\n var one = {\"X\": dat, \"Y\": parseFloat(msg.payload[i].Hodnota)};\n dataval.push(one);\n \n}\n\nvar chart = [{\"data\": dataval,\"labels\": [\"XXX\"],\"series\": [\"X\"]}];\nreturn chart;","outputs":1,"noerr":0,"x":620,"y":79,"wires":[["a1525685.afb1a8","91e8ca0c.333eb8"]]},{"id":"a1525685.afb1a8","type":"debug","z":"d47a8733.87bbc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":792,"y":196,"wires":[]},{"id":"91e8ca0c.333eb8","type":"ui_chart","z":"d47a8733.87bbc","name":"","group":"46f66c9e.fd4ffc","order":1,"width":0,"height":0,"label":"RĹŻstovĂ˝","chartType":"line","legend":"true","xformat":"auto","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":809,"y":81,"wires":[[]]},{"id":"46f66c9e.fd4ffc","type":"ui_group","z":"","name":"ÄŚSOB","tab":"aa5ace90.58f6d8","disp":true,"width":"6","collapse":false},{"id":"aa5ace90.58f6d8","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]