Skip to content
Snippets Groups Projects
Commit 8bec96cb authored by jose.ignacio.fagian's avatar jose.ignacio.fagian
Browse files

Merge branch 'feature/integration-graph-2d-3d' of...

Merge branch 'feature/integration-graph-2d-3d' of https://gitlab.fing.edu.uy/matefun/Frontend into feature/integration-graph-2d-3d

# Conflicts:
#	Frontend Angular 4/src/app/layout/plotter/graph2D/graph2D.component.ts
parents 0cb6281d dc98f9e9
Branches
Tags
No related merge requests found
<div class="card"> <div class="card">
<div class="card-block contenedor-canvas" > <div class="card-block contenedor-canvas" >
<button ngbPopover="Zoom +" triggers="mouseenter:mouseleave" data-placement="bottom" class="btn btn-sm btn-secondary" style="float:right; margin-right: 165px; margin-top: -55px" (click)=zoomMas() ><i class="fa fa-plus"></i></button>
<button ngbPopover="Zoom -" data-placement="bottom" triggers="mouseenter:mouseleave" class="btn btn-sm btn-secondary" style="float:right; margin-right: 132px; margin-top: -55px" (click)=zoomMenos() ><i class="fa fa-minus"></i></button>
<div id="graph2D-container" style="height: 100%; width: 100%;"> <div id="graph2D-container" style="height: 100%; width: 100%;">
</div> </div>
</div> </div>
......
...@@ -11,6 +11,9 @@ import functionPlot from 'function-plot'; ...@@ -11,6 +11,9 @@ import functionPlot from 'function-plot';
} }
}) })
export class Graph2DComponent { export class Graph2DComponent {
private instance: {};
public constructor(private ghciService: GHCIService) { public constructor(private ghciService: GHCIService) {
ghciService.messages.subscribe( ghciService.messages.subscribe(
canvas => { canvas => {
...@@ -18,8 +21,6 @@ export class Graph2DComponent { ...@@ -18,8 +21,6 @@ export class Graph2DComponent {
if (canvas.tipo == 'graph') { if (canvas.tipo == 'graph') {
var jsonCanvas = JSON.parse(canvas.resultado); var jsonCanvas = JSON.parse(canvas.resultado);
let fun = eval(this.generarFuncion(jsonCanvas)); let fun = eval(this.generarFuncion(jsonCanvas));
var conjs = this.obtenerConjunto(jsonCanvas.funs[0]); var conjs = this.obtenerConjunto(jsonCanvas.funs[0]);
var d = conjs + "}"; var d = conjs + "}";
...@@ -66,7 +67,7 @@ export class Graph2DComponent { ...@@ -66,7 +67,7 @@ export class Graph2DComponent {
}else{ }else{
tipoGraf = 'polyline'; tipoGraf = 'polyline';
} }
functionPlot({ this.instance = functionPlot({
target: '#graph2D-container', target: '#graph2D-container',
width: 620, width: 620,
height: 450, height: 450,
...@@ -78,8 +79,41 @@ export class Graph2DComponent { ...@@ -78,8 +79,41 @@ export class Graph2DComponent {
}, },
graphType: tipoGraf, graphType: tipoGraf,
color: color color: color
}] }],
plugins: [
functionPlot.plugins.zoomBox()
]
}) })
// EXAMPLE - SHAPE
// this.instance = functionPlot({
// target: '#graph2D-container',
// width: 700,
// height: 700,
// xAxis: {
// label: 'x - axis',
// scale: 'linear',
// domain: {
// initial: [-10, 10],
// type: 'discrete'
// }
// },
// data: [{
// shape: {
// w : 6.0,
// h : 3.0,
// x : 0,
// y : 0,
// color :"red",
// rotation : 0.125
// },
// graphType: 'shape',
// shapeType: 'rect'
// }],
// plugins: [
// functionPlot.plugins.zoomBox()
// ]
// })
} }
}, },
error => { error => {
...@@ -87,10 +121,18 @@ export class Graph2DComponent { ...@@ -87,10 +121,18 @@ export class Graph2DComponent {
}) })
} }
public zoomMenos = function () {
this.instance.zoomOut();
}
public zoomMas = function () {
this.instance.zoomIn();
}
getRandomArbitrary = function (min, max) { getRandomArbitrary = function (min, max) {
return Math.round(Math.random() * (max - min) + min); return Math.round(Math.random() * (max - min) + min);
} }
generarFuncion = function (graph) { generarFuncion = function (graph) {
var funcionString = ''; var funcionString = '';
var grafica; var grafica;
...@@ -124,6 +166,7 @@ export class Graph2DComponent { ...@@ -124,6 +166,7 @@ export class Graph2DComponent {
} else if (exp.kind == 'uop') { } else if (exp.kind == 'uop') {
expresion = ' ' + exp.op + ' ' + this.generarExpresion(exp.exp) + ' '; expresion = ' ' + exp.op + ' ' + this.generarExpresion(exp.exp) + ' ';
} else if (exp.kind == 'app') { } else if (exp.kind == 'app') {
if (exp.fun == 'cos') { if (exp.fun == 'cos') {
exp.fun = 'Math.cos' exp.fun = 'Math.cos'
} else if (exp.fun == 'sin') { } else if (exp.fun == 'sin') {
...@@ -132,6 +175,7 @@ export class Graph2DComponent { ...@@ -132,6 +175,7 @@ export class Graph2DComponent {
exp.fun = 'Math.round' exp.fun = 'Math.round'
} }
expresion = ' ' + exp.fun + '(' + exp.args.map(e => this.generarExpresion(e)).join() + ') '; expresion = ' ' + exp.fun + '(' + exp.args.map(e => this.generarExpresion(e)).join() + ') ';
} else if (exp.kind == 'tup') { } else if (exp.kind == 'tup') {
expresion = ' (' + exp.exps.map(e => this.generarExpresion(e)).join() + ') '; expresion = ' (' + exp.exps.map(e => this.generarExpresion(e)).join() + ') ';
} else if (exp.kind == 'lit') { } else if (exp.kind == 'lit') {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment