From beb9206d03defdf980877ccb6755f765f6aa7f62 Mon Sep 17 00:00:00 2001
From: leonelrosano <leonelrosano@gmail.com>
Date: Mon, 8 Jul 2019 19:52:40 -0300
Subject: [PATCH] =?UTF-8?q?modificaci=C3=B3nes?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../plotter/graph2D/graph2D.component.ts      | 32 ++++++++++++++++---
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/Frontend Angular 4/src/app/layout/plotter/graph2D/graph2D.component.ts b/Frontend Angular 4/src/app/layout/plotter/graph2D/graph2D.component.ts
index b3c58900..4eb43aff 100755
--- a/Frontend Angular 4/src/app/layout/plotter/graph2D/graph2D.component.ts	
+++ b/Frontend Angular 4/src/app/layout/plotter/graph2D/graph2D.component.ts	
@@ -78,6 +78,7 @@ export class Graph2DComponent {
                 }
                 switch(canvas.tipo) { 
                     case 'graph': {
+                        console.log(canvas.resultado)
                         var jsonCanvas = JSON.parse(canvas.resultado);
                         var conjs = this.obtenerConjunto(jsonCanvas.funs[0]);
     
@@ -99,7 +100,6 @@ export class Graph2DComponent {
                                 funcionString = 'var ' + funs.fun + ' = function('+funs.args+'){\n return ' + this.generarExpresion(funs.bdy) + '}\n' + funcionString;
                             }
                             funcionString = '(x)=>{\n' + funcionString + '}';
-                            console.log(funcionString)
                             obj.conj.sets.fdom = eval(funcionString);
 
 
@@ -158,8 +158,8 @@ export class Graph2DComponent {
                         
                         let fun = eval(funcionGenerada);
 
-                        var colores = ['violet', 'red', 'blue', 'orange', 'green','black','']
-                        var num = this.getRandomArbitrary(0, 4);
+                        var colores = ['violet', 'red', 'blue', 'orange', 'green','black']
+                        var num = this.getRandomArbitrary(0, 5);
                         var color = colores[num];
     
                         var tipoGraf;
@@ -233,6 +233,7 @@ export class Graph2DComponent {
                                 }else{
        
                                         this.funciones.push({
+
                                             id: this.funciones.length,
                                             sampler: 'builtIn',
                                             fn: function(scope) {
@@ -953,7 +954,9 @@ export class Graph2DComponent {
 				exp.fun = 'Math.sin'
 			} else if (exp.fun == 'round') {
 				exp.fun = 'Math.round'
-			}
+			}else if (exp.fun == 'sqrt'){
+                exp.fun = 'Math.sqrt'
+            }
 			expresion = ' ' + exp.fun + '(' + exp.args.map(e => this.generarExpresion(e)).join() + ') ';
 
         } else if (exp.kind == 'tup') {
@@ -1146,6 +1149,13 @@ generateFunctionAndExp = function (exp,graph,namefun6) {
             aux6[0]= aux26;
             aux6[1] = aux16;
             myList.push(aux6);
+        }else if ((exp.fun == 'Math.sqrt') || (exp.fun == 'sqrt')){
+            var aux7 = [];
+            var aux17 = 'Math.sqrt('+ exp.args.map(e => this.generarExpresion(e)).join() +')';
+            var aux27 = 'N'
+            aux7[0]= aux27;
+            aux7[1] = aux17;
+            myList.push(aux7);
         }else{
             if(!namefun6.includes(exp.fun)){
                 var ListnameFNew = namefun6;
@@ -1262,6 +1272,11 @@ createListExp = function (exp) {
             expresion = ' ' + exp.fun + '(' + exp.args.map(e => this.generarExpresion(e)).join() + ') ';
             funcione.push(expresion)
 
+        } else if (exp.fun == 'Math.sqrt') {
+            exp.fun = 'Math.sqrt'
+            expresion = ' ' + exp.fun + '(' + exp.args.map(e => this.generarExpresion(e)).join() + ') ';
+            funcione.push(expresion)
+
         }else{
             expresion = ' ' + exp.fun + '(' + exp.args.map(e => this.generarExpresion(e)).join() + ') ';
             funcione.push(expresion)
@@ -1408,7 +1423,12 @@ createListExp = function (exp) {
                 expresion = ' ' + exp.fun + '(' + exp.args.map(e => this.generarExpresionDisc(e,grap,ListnameF)).join() + ') ';
                 funcione.push(expresion)
 
-			}else{
+            } else if (exp.fun == 'Math.sqrt') {
+                exp.fun = 'Math.sqrt'
+                expresion = ' ' + exp.fun + '(' + exp.args.map(e => this.generarExpresionDisc(e,grap,ListnameF)).join() + ') ';
+                funcione.push(expresion)
+    
+            }else{
 
                 if(!ListnameF.includes(exp.fun)){
 
@@ -1594,6 +1614,8 @@ createListExp = function (exp) {
                 exp.fun = 'Math.sin'
             } else if (exp.fun == 'round') {
                 exp.fun = 'Math.round'
+            }else if (exp.fun == 'sqrt'){
+                exp.fun = 'Math.sqrt'
             }
             expresion = ' ' + exp.fun + '(' + exp.args.map(e => this.generarF(e)).join() + ') ';
         } else if (exp.kind == 'tup') {
-- 
GitLab