summaryrefslogtreecommitdiff
path: root/views/script
diff options
context:
space:
mode:
authorSaloniGoyal2016-06-20 11:34:23 +0530
committerSaloniGoyal2016-06-20 11:34:23 +0530
commitd6bfdfe4fa1a6c420cca4fe08e0205e41ac886a2 (patch)
tree34d6f789abbc61103e32590c6f7a0060033cc75e /views/script
parent2cbb0645b07a1eead605874bc97a989b3fc1d89f (diff)
downloadeSimWebApp-d6bfdfe4fa1a6c420cca4fe08e0205e41ac886a2.tar.gz
eSimWebApp-d6bfdfe4fa1a6c420cca4fe08e0205e41ac886a2.tar.bz2
eSimWebApp-d6bfdfe4fa1a6c420cca4fe08e0205e41ac886a2.zip
Client can pick x-axis and y-axis for plot
Diffstat (limited to 'views/script')
-rw-r--r--views/script/form.js89
-rw-r--r--views/script/gui.js6
2 files changed, 57 insertions, 38 deletions
diff --git a/views/script/form.js b/views/script/form.js
index 11bf6e1..1c9512b 100644
--- a/views/script/form.js
+++ b/views/script/form.js
@@ -4,51 +4,66 @@ socket.on("plotData",function(data){
var keys = Object.keys(data);
var traceObj = {};
var traces = [];
-
+ var abscissa, ordinate;
console.log(Object.keys(data));
+ $('webtronics_plot_keys').innerHTML = "Available keys: " + Object.keys(data);
+
//Dynamically creating traces
- for(var i=0; i<keys.length; i++){
- if(keys[i]=='x-axis'){
- continue;
+ jQuery("#plot_graph").click(function(){
+ abscissa = $('abscissa_value').value;
+ ordinate = $('ordinate_value').value;
+ if(abscissa == "" || ordinate == ""){
+ alert("PLease enter values to plot graph");
}
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 flag = 0;
+ for(var i=0; i<keys.length; i++){
+ if(keys[i]==ordinate){
+ flag=1;
+ var trace = {
+ x: data[evalabscissa],
+ y: data[keys[i]],
+ name: keys[i],
+ type: 'scatter'
+ };
+ traceObj[keys[i]] = trace;
+ }
- 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);
-
+ if(flag == 0){
+ alert("Invalid inputs");
+ }
+ else{
+ 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: 60, b: 35, r: 10, t: 25
+ }
+ };
+ $('plot_details').style.display = "none";
+ $('webtronics_graph_display').style.display = "block";
+ Plotly.newPlot(document.getElementById('webtronics_graph_display'), dataForPlotly, layout);
+ }
+ }
+
+ });
+
}) \ No newline at end of file
diff --git a/views/script/gui.js b/views/script/gui.js
index 70f5067..2793b29 100644
--- a/views/script/gui.js
+++ b/views/script/gui.js
@@ -17,7 +17,7 @@ var webtronics={
tabs:[],
mode:'',
-
+
Vlist:/\s*expression|\s*url|.*script/,
Alist:/^(x|y|x1|y1|x2|y2|dx|dy|cx|cy|r|width|height|style|transform|d|id|xml:space|class|fill|stroke|text-anchor|visibility|fill-opacity|stroke-linejoin|stroke-linecap|stroke-opacity|stroke-width|xmlns|xmlns:wtx|connects|partvalue|flippable|spice|index|font-size|font-weight|font-style|font-family)$/,
Elist:/^(path|circle|rect|line|text|g|tspan|svg|wtx:limitswitch|wtx:irev|wtx:rbreak|wtx:inoffset|wtx:gain|wtx:outoffset|wtx:ingain|wtx:outgain|wtx:denoffset|wtx:dengain|wtx:numoffset|wtx:numgain|wtx:fraction|wtx:dendomain|wtx:denlowerlimit|wtx:outlowerlimit|wtx:outupperlimit|wtx:limitrange|wtx:upperdelta|wtx:lowerdelta|wtx:indomain|wtx:xarr|wtx:yarr|wtx:amodel|wtx:coff|wtx:con|wtx:roff|wtx:ron|wtx:log|wtx:vbreak|wtx:ibreak|wtx:isat|wtx:nfor|wtx:rsource|wtx:rsink|wtx:ilimitsource|wtx:ilimitsink|wtx:vpwr|wtx:isource|wtx:isink|wtx:routdomain|wtx:inlow|wtx:inhigh|wtx:hyst|wtx:outic|wtx:numcoeff|wtx:dencoeff|wtx:intic|wtx:denormfreq|wtx:riseslope|wtx:fallslope|wtx:outlow|wtx:outhigh|wtx:cntlarr|wtx:freqarr|wtx:duty|wtx:risetime|wtx:falltime|wtx:clktrig|wtx:pwarr|wtx:ptrig|wtx:rdelay|wtx:fdelay|wtx:rmax|wtx:rmin|wtx:rinit|wtx:vt|wtx:alpha|wtx:beta|wtx:eval1|wtx:eval2|wtx:eval3|wtx:eval4|wtx:eval5|wtx:eval6|wtx:pwlval1|wtx:pwlval2|wtx:pwlval3|wtx:pwlval4|wtx:pwlval5|wtx:pwlval6|wtx:pwlval7|wtx:pwlval8|wtx:pulval1|wtx:pulval2|wtx:pulval3|wtx:pulval4|wtx:pulval5|wtx:pulval6|wtx:pulval7|wtx:amplitude|wtx:phase|wtx:offsetvoltage|wtx:voltageamplitude|wtx:frequency|wtx:delaytime|wtx:dampingfactor|wtx:part|wtx:pins|wtx:analog|wtx:digital|wtx:node|wtx:id|wtx:type|wtx:name|wtx:category|wtx:value|wtx:label|wtx:spice|wtx:risedelay|wtx:inputload|wtx:falldelay|wtx:flip|wtx:model|wtx:measure|metadata|)$/,
@@ -1416,6 +1416,10 @@ Event.observe($('webtronics_chips_open'), 'click', function() {
Event.observe($('webtronics_netlist_simulate'), 'click', function() {
$('webtronics_plot_box').style.display = "block";
+ $('plot_details').style.display = "block";
+ $('abscissa_value').value = "";
+ $('ordinate_value').value = "";
+ $('webtronics_graph_display').style.display = "none";
webtronics.center($('webtronics_plot_box'));
webtronics.disablepage();
});