diff options
author | SaloniGoyal | 2016-06-16 11:52:24 +0530 |
---|---|---|
committer | SaloniGoyal | 2016-06-16 11:52:24 +0530 |
commit | 2cbb0645b07a1eead605874bc97a989b3fc1d89f (patch) | |
tree | 0467c5837901401f0a8fb0a54df350ed3fb9fea1 /views/script/form.js | |
parent | 988150262d52426070d892ddb7e8af09c1c60c90 (diff) | |
download | eSimWebApp-2cbb0645b07a1eead605874bc97a989b3fc1d89f.tar.gz eSimWebApp-2cbb0645b07a1eead605874bc97a989b3fc1d89f.tar.bz2 eSimWebApp-2cbb0645b07a1eead605874bc97a989b3fc1d89f.zip |
plot generated using plotly.js
Diffstat (limited to 'views/script/form.js')
-rw-r--r-- | views/script/form.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/views/script/form.js b/views/script/form.js index 42be640..11bf6e1 100644 --- a/views/script/form.js +++ b/views/script/form.js @@ -1 +1,54 @@ var socket = io(); + +socket.on("plotData",function(data){ + var keys = Object.keys(data); + var traceObj = {}; + var traces = []; + + + console.log(Object.keys(data)); + + //Dynamically creating traces + for(var i=0; i<keys.length; i++){ + if(keys[i]=='x-axis'){ + continue; + } + else{ + var trace = { + x: data['x-axis'], + y: data[keys[i]], + name:keys[i], + type: 'scatter' + }; + traceObj[keys[i]] = trace; + } + } + + var traceKey = Object.keys(traceObj); + + for (var i=0;i<traceKey.length;i++) { + var value = traceObj[traceKey[i]]; + traces.push(value); + } + + console.log("traces :"+traces); + + var dataForPlotly = traces; + + var layout = { + title:'Simulation Output', + yaxis: { title: "Voltage(Volts) / Current(Amp)"}, // set the y axis title + xaxis: { + title:"time(Sec) / Frequency(Hz)", + showgrid: true // remove the x-axis grid lines + }, + margin: { // update the left, bottom, right, top margin + l: 40, b: 25, r: 10, t: 25 + } + }; + + Plotly.newPlot(document.getElementById('webtronics_graph_display'), dataForPlotly, layout); + + + +})
\ No newline at end of file |