From 0421ea341fc01e2c9427f1796669ecb4be09bc9f Mon Sep 17 00:00:00 2001 From: fahimkhan Date: Mon, 29 Aug 2016 16:20:47 +0530 Subject: Refactor code to add stack plot functionality --- routes/routes.js | 7 ++++--- views/index.html | 48 ++++++++++++++++++++++++------------------------ 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/routes/routes.js b/routes/routes.js index cd00754..04fb6cc 100644 --- a/routes/routes.js +++ b/routes/routes.js @@ -24,7 +24,7 @@ module.exports = function(express,app,fs,os,io,PythonShell,scriptPath){ //Plotting List plotList = data['plotList']; - console.log("PlotList----------->"+plotList); + // console.log("PlotList----------->"+plotList); plotOption = plotList.join(" "); //Space is required between two plot @@ -116,6 +116,7 @@ module.exports = function(express,app,fs,os,io,PythonShell,scriptPath){ function parsePlotData(){ console.log("Ngspice netlist executed successfully "+fileName); + console.log("PlotList----------->"+plotList); //socket.emit('serverMessage','Ngspice netlist executed successfully: '); //var analysisInfo = grep('.tran|.dc|.ac', fileName); //Not reliable var analysisInfo = getAnalysisInfo(fileName); @@ -132,10 +133,10 @@ module.exports = function(express,app,fs,os,io,PythonShell,scriptPath){ if (err) throw err; // results is an array consisting of messages collected during execution // console.log('results: %j', results); - var resultString = results[0]; + var outData = results[0]; //Emitting Data Points to client - socket.emit('plotData',resultString); + socket.emit('plotData',{"outData":outData,"plotList":plotList}); }); } diff --git a/views/index.html b/views/index.html index 1d45ab1..748b587 100644 --- a/views/index.html +++ b/views/index.html @@ -81,10 +81,7 @@ v1 in gnd pwl(0m 0 0.5m 5 50m 5 50.5m 0 100m 0)

Plots:

- - +
@@ -221,12 +218,28 @@ v(in) v(out) }); socket.on("plotData",function(data){ - var keys = Object.keys(data); - var traceObj = {}; - var traces = []; + var outData = data['outData']; + plotList = data['plotList']; + console.log("PlotList---->"+plotList); + var keys = Object.keys(outData); + + + nonStackPlot(keys,outData); + - console.log(Object.keys(data)); + }); + + + function destroyClickedElement(event) + { + // remove the link from the DOM + document.body.removeChild(event.target); + } + function nonStackPlot(keys,outData) + { + var traceObj = {}; + var traces = []; //Dynamically creating traces for(var i=0; i