Skip to content
Snippets Groups Projects
Commit fd629073 authored by Diego Rey's avatar Diego Rey
Browse files

Added ghciServiceSub unsubscribe handler

parent 68c4fc59
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,8 @@ import { Animation } from './graph2D.helper';
})
export class Graph2DComponent {
private ghciServiceSub: any;
private instance: null;
private animation: Animation = {
......@@ -25,7 +27,7 @@ export class Graph2DComponent {
};
public constructor(private ghciService: GHCIService) {
ghciService.messages.subscribe(
this.ghciServiceSub = ghciService.messages.subscribe(
canvas => {
switch(canvas.tipo) {
case 'graph': {
......@@ -251,7 +253,7 @@ export class Graph2DComponent {
return $circleNormalized;
}
/**
/**
* @name normalizeTextData
* @desc Normalize Text data for Function Plot Library
* @param {Object} textData Data of Text to be normalized
......@@ -273,6 +275,49 @@ export class Graph2DComponent {
return $textNormalized;
}
/**
* @name normalizeTextData
* @desc Normalize Text data for Function Plot Library
* @param {Object} textData Data of Text to be normalized
* @returns {Object}
*/
// 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.color = $lineData.color;
// $lineNormalized.rotation = $lineData.rot;
// $lineNormalized.fnType = 'points';
// $lineNormalized.polylineType = 'line';
// $lineNormalized.graphType = 'polyline';
// return $lineNormalized;
// }
/**
* @name normalizeTextData
* @desc Normalize Text data for Function Plot Library
* @param {Object} textData Data of Text to be normalized
* @returns {Object}
*/
// public normalizePolygonData = function ($textData) {
// var $PoligonNormalized: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 normalizeShapesData
......@@ -295,7 +340,15 @@ export class Graph2DComponent {
case 'text': {
normalized.push(this.normalizeTextData(shape));
break;
}
}
// case 'line': {
// normalized.push(this.normalizeLineData(shape));
// break;
// }
// case 'polygon': {
// normalized.push(this.normalizePolygonData(shape));
// break;
// }
}
}
return normalized;
......@@ -518,5 +571,11 @@ export class Graph2DComponent {
return funcionString;
}
ngOnDestroy() {
if (this.ghciServiceSub) {
this.ghciServiceSub.unsubscribe();
}
}
}
......@@ -6,3 +6,28 @@ export interface Animation {
playing: boolean,
init: boolean
}
// export function toJSON(data: any) : string {
// var $points = data.pts;
// var $pointsJson = [];
// for (var p of $points) {
// $pointsJson.push([p[0],p[1]]);
// }
// var dataJson = data;
// dataJson.pts
// }
// return jsonString
// .replace(
// regexRot, (match, x, y, z) => {
// return `"rot": { "x": ${x}, "y": ${y}, "z": ${z} }`
// }
// )
// .replace(
// regexPts, (match, x1, y1, z1, x2, y2, z2) => {
// return `"pts": [{ "x": ${x1}, "y": ${y1}, "z": ${z1} },{ "x": ${x2}, "y": ${y2}, "z": ${z2} }]`
// }
// )
// }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment