Newer
Older
import { Component, ViewChild, ElementRef } from '@angular/core';
import { GHCIService } from '../../../shared/services/ghci.service';
import { Animation, Setting, toJSON, triggerDownload } from './graph2D.helper';
import { TranslateService } from '@ngx-translate/core';
@Component({
moduleId: module.id,
selector: 'graph2D-component',
templateUrl: './graph2D.component.html',
styleUrls: ['./graph2D.component.scss'],
'(window:resize)': 'onResize($event)'
// Ghci Service
// Chart Container - DOM Element
@ViewChild('graph2DContainer')
private graph2DRef: ElementRef;
// Chart Instance
private instance: any;
// Settings
settings: Setting = {
axis: true,
grid: true,
tip: true
}
private funciones= [];
private id = 0;
// Animation state
animation: Animation = {
timeout: null,
animationFrame: null,
speedX: 10,
public easeInOutCubic = function(fps) {
var t = fps < 6 ? 6 : fps;
var k = t/60;
var animation = k<.5 ? 60*(4*k*k*k) : 60*((k-1)*(2*k-2)*(2*k-2)+1);
console.log(animation);
return animation;
}
this.animation.zoo = this.animation.zoo ;
}
public multiGraf = () => {
this.animation.boton = !this.animation.boton;
}
public constructor(private ghciService: GHCIService, public translate: TranslateService) {
this.ghciServiceSub = ghciService.messages.subscribe(
// Stop Animation
if (this.animation.init) {
this.stopAnimation();
}
switch(canvas.tipo) {
case 'graph': {
// var jsonCanvas = JSON.parse(JSONRepair(canvas.resultado));
var jsonCanvas = JSON.parse(canvas.resultado);
var conjs = this.obtenerConjunto(jsonCanvas.funs[0]);
//Para las funciones
if (obj.conj.sets.fdom == "function(x)") {
var nom = jsonCanvas.funs[0].dom;
var elemento1 = this.recursionfuncion(jsonCanvas.funs[0].sets, nom);
var funcionString = '';
funcionString ="var "+nom+" = function(x){\nreturn "+elemento1+"}\n"
funcionString += 'return ' + nom + '(x);\n'
for (var funs of jsonCanvas.funs) {
funcionString = 'var ' + funs.fun + ' = function('+funs.args+'){\n return ' + this.generarExpresion(funs.bdy) + '}\n' + funcionString;
}
funcionString = '(x)=>{\n' + funcionString + '}';
obj.conj.sets.fdom = eval(funcionString);
if (obj.conj.sets.fcod == "function(x)") {
var nom = jsonCanvas.funs[0].cod;
var elemento2 = this.recursionfuncion(jsonCanvas.funs[0].sets, nom);
obj.conj.sets.fcod = function (x) { return (eval(elemento2)) }
var funcionString = '';
funcionString ="var "+nom+" = function(x){\nreturn "+elemento2+"}\n"
funcionString += 'return ' + nom + '(x);\n'
for (var funs of jsonCanvas.funs) {
funcionString = 'var ' + funs.fun + ' = function('+funs.args+'){\n return ' + this.generarExpresion(funs.bdy) + '}\n' + funcionString;
}
funcionString = '(x)=>{\n' + funcionString + '}';
obj.conj.sets.fdom = eval(funcionString);
var funcionGenerada = this.generarFuncion(jsonCanvas);
//para Enumerados
if (obj.conj.dom == 'Numer') {
var j = 0;
for (var f of obj.conj.sets.fdom) {
var expresionDom = new RegExp('( '+f+' )', 'g');
funcionGenerada = funcionGenerada.replace(expresionDom, j.toString());
j += 1;
}
}
if (obj.conj.cod == 'Numer') {
var j2 = 0;
for (var f2 of obj.conj.sets.fcod) {
var expresionCod = new RegExp(f2, 'g');
funcionGenerada = funcionGenerada.replace(expresionCod, j2.toString());
j2 += 1;
if (obj.conj.baseDom == 'R'){
obj.conj.baseCod = 'R';
if (obj.conj.cod != 'Func'){
obj.conj.cod = 'R';
obj.conj.fcod = 'R';
}
}
let fun = eval(funcionGenerada);
var colores = ['violet', 'red', 'blue', 'orange', 'green','black']
var num = this.getRandomArbitrary(0, 5);
var color = colores[num];
var tipoGraf;
if (obj.conj.baseDom != 'R'){
tipoGraf = 'scatter';
}else{
tipoGraf = 'polyline';
}
if(this.animation.boton && obj.conj.cod != 'Numer' && obj.conj.dom != 'Numer'){
Leonel Rosano Montero
committed
if(this.conjunto.length == 1 && (this.conjunto[0].cod == 'Numer' || this.conjunto[0].dom == 'Numer')){
this.conjunto = [];
this.conjunto.push(obj.conj);
this.id = 0;
this.funciones = [];
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
if(obj.conj.baseDom == 'R'){
this.valores = [];
var funcionGenerada2 = this.generarFuncionDisc(jsonCanvas);
var funcionesVer2019 = this.createListFunction(jsonCanvas);
var listValores = [];
for (var k of this.valores){
listValores.push(parseInt(k))
}
for (var i of this.valores){
for(var t of this.valores){
var aux = parseInt(t);
var aux2 = parseInt(i);
var mul = aux * aux2;
listValores.push(mul)
}
}
for (i = -999; i < 1000; i++) {
listValores.push(i)
}
let sinRepetidos = listValores.filter((valor, indiceActual, arreglo) => arreglo.indexOf(valor) === indiceActual);
for (var fun2 of funcionesVer2019){
let fun3 = eval(fun2);
var insertar = false;
var punto1 = [];
if (sinRepetidos.length){
for (var p of sinRepetidos){
var pn= parseInt(p) - 0.001
var pp= parseInt(p) + 0.001
insertar = (((fun3(pp) != undefined) ) || ((fun3(pn) != undefined)) || insertar)
if((fun3(pp) != undefined)){
punto1.push(pp);
}else if ((fun3(pn) != undefined)){
punto1.push(p);
}
}
}else{
insertar = true;
}
if (insertar){
this.funciones.push({
id: 0,
sampler: 'builtIn',
fn: function(scope) {
return fun3(scope.x)
},
graphType: tipoGraf,
point:punto1[0],
color: color,
});
}
}
}else{
this.funciones.push({
id: this.funciones.length,
sampler: 'builtIn',
fn: function(scope) {
return fun(scope.x)
},
graphType: tipoGraf,
color: color
})
}
Leonel Rosano Montero
committed
}else{
if(this.conjunto.length == 1){
this.id = 1;
Leonel Rosano Montero
committed
this.conjunto.unshift({radio: 2, dom:this.conjunto[0].baseDom, cod:this.conjunto[0].baseCod, baseCod:this.conjunto[0].baseCod, baseDom:this.conjunto[0].baseDom, sets:{fdom:this.conjunto[0].baseDom,fcod:this.conjunto[0].baseCod}});
this.funciones[0].id = this.id;
Leonel Rosano Montero
committed
if (this.conjunto.length != 0){
if (obj.conj.baseDom == 'R'){
this.conjunto[0].baseDom = 'R';
this.conjunto[0].dom = 'R';
this.conjunto[0].sets.fdom = 'R';
}
if (obj.conj.baseCod == 'R'){
this.conjunto[0].baseCod = 'R';
this.conjunto[0].cod = 'R';
this.conjunto[0].sets.fcod = 'R';
}
}
this.conjunto.push(obj.conj);
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
var identificador=0;
if (this.conjunto.length > 1){
identificador=this.conjunto.length - 2 + this.id;
}
if(obj.conj.baseDom == 'R'){
this.valores = [];
var funcionGenerada2 = this.generarFuncionDisc(jsonCanvas);
var funcionesVer2019 = this.createListFunction(jsonCanvas);
var listValores = [];
for (var k of this.valores){
listValores.push(parseInt(k))
}
for (var i of this.valores){
for(var t of this.valores){
var aux = parseInt(t);
var aux2 = parseInt(i);
var mul = aux * aux2;
listValores.push(mul)
}
}
for (i = -999; i < 1000; i++) {
listValores.push(i)
}
let sinRepetidos = listValores.filter((valor, indiceActual, arreglo) => arreglo.indexOf(valor) === indiceActual);
for (var fun2 of funcionesVer2019){
let fun3 = eval(fun2);
var insertar = false;
var punto1 = [];
if (sinRepetidos.length){
for (var p of sinRepetidos){
var pn= parseInt(p) - 0.001
var pp= parseInt(p) + 0.001
insertar = (((fun3(pp) != undefined) ) || ((fun3(pn) != undefined)) || insertar)
if((fun3(pp) != undefined)){
punto1.push(pp);
}else if ((fun3(pn) != undefined)){
punto1.push(p);
}
}
}else{
insertar = true;
}
if (insertar){
this.funciones.push({
id: identificador,
sampler: 'builtIn',
fn: function(scope) {
return fun3(scope.x)
},
graphType: tipoGraf,
point:punto1[0],
color: color,
});
}
}
}else{
this.funciones.push({
id: identificador,
sampler: 'builtIn',
fn: function(scope) {
return fun(scope.x)
},
graphType: tipoGraf,
color: color
});
}
}
}else{
this.conjunto = [];
this.conjunto.push(obj.conj);
this.id = 0;
this.funciones = [];
if(obj.conj.baseDom == 'R'){
this.valores = [];
var funcionGenerada2 = this.generarFuncionDisc(jsonCanvas);
var funcionesVer2019 = this.createListFunction(jsonCanvas);
var listValores = [];
for (var k of this.valores){
listValores.push(parseInt(k))
}
for (var i of this.valores){
for(var t of this.valores){
var aux = parseInt(t);
var aux2 = parseInt(i);
var mul = aux * aux2;
listValores.push(mul)
}
}
for (i = -999; i < 1000; i++) {
listValores.push(i)
}
let sinRepetidos = listValores.filter((valor, indiceActual, arreglo) => arreglo.indexOf(valor) === indiceActual);
for (var fun2 of funcionesVer2019){
let fun3 = eval(fun2);
var insertar = false;
var punto1 = [];
if (sinRepetidos.length){
for (var p of sinRepetidos){
var pn= parseInt(p) - 0.001
var pp= parseInt(p) + 0.001
insertar = (((fun3(pp) != undefined) ) || ((fun3(pn) != undefined)) || insertar)
if((fun3(pp) != undefined)){
punto1.push(pp);
}else if ((fun3(pn) != undefined)){
punto1.push(p);
}
}
}else{
insertar = true;
}
if (insertar){
this.funciones.push({
id: 0,
sampler: 'builtIn',
fn: function(scope) {
return fun3(scope.x)
},
graphType: tipoGraf,
point:punto1[0],
color: color,
});
}
}
Leonel Rosano Montero
committed
Leonel Rosano Montero
committed
this.funciones.push({
id: this.funciones.length,
Leonel Rosano Montero
committed
sampler: 'builtIn',
fn: function(scope) {
return fun(scope.x)
},
graphType: tipoGraf,
color: color
});
let bounding = this.getBounding();
this.instance = functionPlot({
target: '#graph2D-container',
width: bounding.width,
height: bounding.height,
scale: 'linear',
domain: { initial: [-4, 4],
type: 'discrete' },
yAxis: { domain: [-4, 4] }
},
conj:this.conjunto,
data: this.funciones,
zoom:this.animation.zoo,
plugins: [
functionPlot.plugins.zoomBox()
]
})
break;
var shapesData = JSON.parse(canvas.resultado);
var shapesDataNormalized = this.normalizeShapesData(shapesData);
let bounding = this.getBounding();
this.cleanPlot();
this.instance = functionPlot({
target: '#graph2D-container',
width: bounding.width,
height: bounding.height,
grid: true,
xAxis: {
scale: 'linear',
domain: {
initial: [-10, 10],
type: 'discrete'
}
},
data: shapesDataNormalized,
plugins: [
functionPlot.plugins.zoomBox()
]
})
break;
jose.ignacio.fagian
committed
}
case 'animacion': {
this.cleanPlot();
var animationData = canvas.resultado.map(res => JSON.parse(res));
for (var frame of animationData) {
this.animation.data.push(this.normalizeShapesData(frame));
this.runAnimation();
this.animation.init = true;
/**
* Angular lifecycle hook.
* called after Angular has fully initialized a component's view.
*/
ngAfterViewInit() {
if (!this.instance) {
let bounding = this.getBounding();
this.instance = functionPlot({
target: '#graph2D-container',
width: bounding.width,
height: bounding.height,
grid: true,
xAxis: {
scale: 'linear',
domain: {
initial: [-10, 10],
type: 'discrete'
}
},
})
}
}
/**
* Angular lifecycle hook.
* called when a directive, pipe, or service is destroyed.
*/
ngOnDestroy() {
if (this.ghciServiceSub) {
this.ghciServiceSub.unsubscribe();
}
}
/**
* On Resize Event.
*/
onResize(event){
let instance = this.instance;
let bounding = this.getBounding();
if (bounding.width > 0) {
instance.options.width = bounding.width;
instance.options.height = bounding.height;
instance.build();
}
/**
* @name getBounding
* @desc get the measures of the container of the graph
*/
private getBounding = function() {
var {width, height} = this.graph2DRef.nativeElement.getBoundingClientRect();
if (width === 0) {
width = document.getElementById('graph2D-container').querySelector('svg').width.baseVal.value;
height = document.getElementById('graph2D-container').querySelector('svg').height.baseVal.value;
}
return {width, height}
}
/**
* @name updateFrame
* @desc update data for Function Plot and redraw the graph
*/
public updateFrame = function() {
var $this = this;
var $data = $this.animation.data[$this.animation.currentFrame];
if ($this.instance) {
$this.instance.options.data = $data;
$this.instance.draw();
let bounding = $this.getBounding();
$this.instance = functionPlot({
width: bounding.width,
height: bounding.height,
xAxis: {
label: 'x - axis',
scale: 'linear',
domain: {
initial: [-10, 10],
type: 'discrete'
}
},
$this.animation.timeout = setTimeout(function() {
$this.animation.currentFrame = ($this.animation.currentFrame + 1) % $this.animation.data.length;
$this.animation.animationFrame = requestAnimationFrame($this.updateFrame.bind($this));
}, 1000/ this.easeInOutCubic($this.animation.fps));
/**
* @name runAnimation
* @desc Run Shapes Animation
*/
public runAnimation = function() {
if (this.animation.playing) return;
var $this = this;
$this.animation.playing = true;
/**
* @name pauseAnimation
* @desc Pause Shapes Animation
*/
public pauseAnimation = function() {
var $this = this;
cancelAnimationFrame($this.animation.animationFrame);
clearTimeout($this.animation.timeout);
$this.animation.timeout = null;
/**
* @name stopAnimation
* @desc Stop Shapes Animation
*/
public stopAnimation = function() {
var $this = this;
$this.animation.data = [];
$this.animation.currentFrame = 0;
/**
* @name decreaseSpeed
* @desc Decrease Speed Animation
*/
public decreaseSpeed = function() {
var decrease = false;
if (this.animation.fps > 6) {
decrease = true;
}
if (decrease) {
if (this.animation.fps > 10) {
this.animation.fps -= 1;
this.animation.speedX = this.animation.fps / 10;
} else {
this.animation.fps -= 1;
this.animation.speedX = this.animation.fps / 10;
}
this.pauseAnimation();
this.runAnimation();
}
}
/**
* @name restoreSpeed
* @desc Increase Speed Animation
*/
public restoreSpeed = function() {
this.animation.speedX = 1;
this.pauseAnimation();
this.runAnimation();
}
* @name increaseSpeed
* @desc Increase Speed Animation
*/
public increaseSpeed = function() {
var increase = false;
if (this.animation.fps < 60) {
increase = true;
}
if (increase) {
if (this.animation.fps >= 10) {
this.animation.fps += 1;
this.animation.speedX = this.animation.fps / 10;
} else {
this.animation.fps += 1;
this.animation.speedX = this.animation.fps / 10;
}
this.pauseAnimation();
this.runAnimation();
}
}
/**
* @name toggleGrid
* @desc Show and Hide Grid
*/
public toggleGrid = function () {
this.instance.toggleGrid();
}
/**
* @name toggleAxis
* @desc Show and Hide Axis
*/
public toggleAxis = function () {
this.instance.toggleAxis();
}
/**
* @name toggleTip
* @desc Show and Hide Tip
*/
public toggleTip = function () {
this.instance.toggleTip();
}
/**
* @name zoomOut
* @desc Zoom Out Button Control
*/
public zoomOut = function () {
/**
* @name zoomIn
* @desc Zoom In Button Control
*/
public zoomIn = function () {
/**
* @name recenterPlot
* @desc center the plot and it returns to the initial state.
*/
public recenterPlot = function () {
this.instance.recenter();
}
/**
* @name cleanPlot
* @desc remove all the graph from the instance.
*/
public cleanPlot = function () {
if (this.animation.playing) {
this.stopAnimation();
} else {
this.funciones = [];
this.conjunto = [];
this.id = 0;
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
}
/**
* @name exportPlot
* @desc Download Plot as an SVG image.
*/
public exportPlot = function() {
// Objects
var svg = document.querySelector('svg');
var canvas = document.createElement("canvas");
// Set dimensions of the image
var svgSize = svg.getBoundingClientRect();
canvas.width = svgSize.width;
canvas.height = svgSize.height;
// Convert SVG DOM structure to xml
var ctx = canvas.getContext('2d');
var data = new XMLSerializer().serializeToString(svg);
// URL Object used to parse, construct, normalise, and encode URLs.
var DOMURL = window.URL || (<any>window).webkitURL || window;
var img = new Image();
var svgBlob = new Blob([data], { type: 'image/svg+xml;charset=utf-8' });
var url = DOMURL.createObjectURL(svgBlob);
img.onload = function () {
ctx.drawImage(img, 0, 0);
DOMURL.revokeObjectURL(url);
var imgURI = canvas
.toDataURL('image/png')
.replace('image/png', 'image/octet-stream');
triggerDownload(imgURI);
};
img.src = url;
}
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
/**
* @name normalizeRectData
* @desc Normalize Rectangle data for Function Plot Library
* @param {Object} rectData Data of Rectangle to be normalized
* @returns {Object}
*/
public normalizeRectData = function ($rectData) {
var $rectNormalized:any = {};
var $shape:any = {};
$shape.w = $rectData.w;
$shape.h = $rectData.h;
$shape.x = $rectData.x;
$shape.y = $rectData.y;
$rectData.color && ($shape.fill = $rectData.color);
$rectData.rot !== 'undefined' && ($shape.rotation = $rectData.rot);
$rectNormalized.shape = $shape;
$rectNormalized.graphType = 'shape';
$rectNormalized.shapeType = 'rect';
return $rectNormalized;
}
/**
* @name normalizeCircleData
* @desc Normalize Circle data for Function Plot Library
* @param {Object} circleData Data of Circle to be normalized
* @returns {Object}
*/
public normalizeCircleData = function ($circleData) {
var $circleNormalized:any = {};
var $shape:any = {};
$shape.r = $circleData.r;
$shape.x = $circleData.x;
$shape.y = $circleData.y;
$circleData.color && ($shape.fill = $circleData.color);
$circleData.rot !== 'undefined' && ($shape.rotation = $circleData.rot);
$circleNormalized.shape = $shape;
$circleNormalized.graphType = 'shape';
$circleNormalized.shapeType = 'circle';
return $circleNormalized;
}
* @name normalizeTextData
* @desc Normalize Text data for Function Plot Library
* @param {Object} textData Data of Text to be normalized
* @returns {Object}
*/
public normalizeTextData = function ($textData) {
var $textNormalized:any = {};
var $shape:any = {};
$shape.text = $textData.text;
$shape.size = $textData.size;
$shape.x = $textData.x;
$shape.y = $textData.y;
$textData.color && ($shape.fill = $textData.color);
$textData.rot !== 'undefined' && ($shape.rotation = $textData.rot);
$textNormalized.shape = $shape;
$textNormalized.graphType = 'shape';
$textNormalized.shapeType = 'text';
return $textNormalized;
}
/**
* @name normalizeLineData
* @desc Normalize Line data for Function Plot Library
* @param {Object} lineData Data of Line to be normalized
public normalizeLineData = function ($lineData) {
var $lineNormalized:any = {};
var $points = []
for (var p of $lineData.pts) {
$points.push([p[0],p[1]]);
}
$lineNormalized.points = $points;
$lineNormalized.stroke = $lineData.color;
$lineNormalized.rotation = $lineData.rot;
$lineNormalized.fnType = 'points';
$lineNormalized.polylineType = 'line';
$lineNormalized.graphType = 'polyline';
/**
* @name normalizePolygonData
* @desc Normalize Polygon data for Function Plot Library
* @param {Object} textData Data of Polygon to be normalized
public normalizePolygonData = function ($polygonData) {
var $polygonNormalized:any = {};
var $points = []
for (var p of $polygonData.pts) {
$points.push([p[0],p[1]]);
}
$polygonNormalized.points = $points;
$polygonNormalized.fill = $polygonData.color;
$polygonNormalized.rotation = $polygonData.rot;
$polygonNormalized.fnType = 'points';
$polygonNormalized.polylineType = 'polygon';
$polygonNormalized.graphType = 'polyline';
/**
* @name normalizeShapesData
* @desc Normalize Shapes data for Function Plot Library
* @param {Array} shapesData Data of Shapes to be normalized
* @returns {Array}
*/
public normalizeShapesData = function (shapesData) {
var normalized:Array<Object> = [];
for (var shape of shapesData) {
switch(shape.kind) {
case 'rect': {
normalized.push(this.normalizeRectData(shape));
break;
}
case 'circle': {
normalized.push(this.normalizeCircleData(shape));
break;
}
case 'text': {
normalized.push(this.normalizeTextData(shape));
break;
case 'line': {
normalized.push(this.normalizeLineData(shape));
break;
}
case 'poly': {
normalized.push(this.normalizePolygonData(shape));
break;
}
}
}
return normalized;
}
return Math.round(Math.random() * (max - min) + min);
}
generarFuncion = function (graph) {
var funcionString = '';
var grafica;
for (var fun of graph.funs) {
funcionString = 'var ' + fun.fun + ' = function(' + fun.args.join() + '){\n return ' + this.generarExpresion(fun.bdy) + '}\n' + funcionString;
if (fun.fun == graph.graph) {
funcionString += 'return ' + fun.fun + '(' + fun.args.join() + ');\n'
grafica = fun;
funcionString = '(' + grafica.args.join() + ')=>{\n' + funcionString + '}';
var expresion = '';
if (exp.kind == 'cnd') {
expresion = ' (' + this.generarExpresion(exp.cond) + '?' + this.generarExpresion(exp.exp1) + ':' + this.generarExpresion(exp.exp2) + ') ';
} else if (exp.kind == 'bop') {
expresion = ' Math.abs((' + this.generarExpresion(exp.exp1) + ') - (' + this.generarExpresion(exp.exp2) + ')) == 0 ';
expresion = ' Math.abs((' + this.generarExpresion(exp.exp1) + ') - (' + this.generarExpresion(exp.exp2) + ')) != 0';
} else if (exp.op == '^') {
expresion = ' Math.pow(' + this.generarExpresion(exp.exp1) + ',' + this.generarExpresion(exp.exp2) + ') ';
} else {
expresion = ' (' + this.generarExpresion(exp.exp1) + ')' + exp.op + '(' + this.generarExpresion(exp.exp2) + ') ';
}
} else if (exp.kind == 'uop') {
expresion = ' ' + exp.op + ' ' + this.generarExpresion(exp.exp) + ' ';
} else if (exp.kind == 'app') {
if (exp.fun == 'cos') {
exp.fun = 'Math.cos'
} else if (exp.fun == 'sin') {
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') {
expresion = ' (' + exp.exps.map(e => this.generarExpresion(e)).join() + ') ';
} else if (exp.kind == 'lit') {
} else if (exp.kind == 'var') {
return expresion;
}
// nueva
createListFunction = function (graph) {
var funcionString = '';
var grafica;
var funciones = [];
var j = 0;
while (graph.funs[j].fun != graph.graph) {
j += 1;
}
var fun1 = graph.funs[j];
var arrayFunction = [];