From 3666bb6f91d4b212202215798e4d45a8792e96dc Mon Sep 17 00:00:00 2001 From: Diego Rey <diego.despaux@izundo.com> Date: Thu, 20 Sep 2018 19:57:28 -0300 Subject: [PATCH] Added polygon and line shapes --- Frontend Angular 4/package-lock.json | 2 +- .../plotter/graph2D/graph2D.component.ts | 78 +++++++++---------- 2 files changed, 37 insertions(+), 43 deletions(-) diff --git a/Frontend Angular 4/package-lock.json b/Frontend Angular 4/package-lock.json index e451e26..28f4903 100644 --- a/Frontend Angular 4/package-lock.json +++ b/Frontend Angular 4/package-lock.json @@ -4139,7 +4139,7 @@ "dev": true }, "function-plot": { - "version": "git://github.com/diego-rey/function-plot.git#81713c85f1fb90ff0f41a3dade1bcd831e80b6fa", + "version": "git://github.com/diego-rey/function-plot.git#ecc44bb412db00356cb3dda42ea4c981eaad7bd6", "from": "git://github.com/diego-rey/function-plot.git#feature/integration-multigraf-shape", "requires": { "array-range": "^1.0.1", 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 bd6a9ff..7282c89 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 @@ -163,7 +163,6 @@ export class Graph2DComponent { }); } let bounding = this.getBounding(); - console.log(bounding); this.instance = functionPlot({ target: '#graph2D-container', width: bounding.width, @@ -274,10 +273,6 @@ export class Graph2DComponent { } } - onClickMe(event) { - console.log('click'); - } - /** * @name getBounding * @desc get the measures of the container of the graph @@ -562,43 +557,42 @@ export class Graph2DComponent { * @param {Object} lineData Data of Line 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'; + 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'; - // return $lineNormalized; - // } + return $lineNormalized; + } /** * @name normalizePolygonData * @desc Normalize Polygon data for Function Plot Library * @param {Object} textData Data of Polygon 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'; + 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'; - // return $textNormalized; - // } + return $polygonNormalized; + } /** * @name normalizeShapesData @@ -622,14 +616,14 @@ export class Graph2DComponent { normalized.push(this.normalizeTextData(shape)); break; } - // case 'line': { - // normalized.push(this.normalizeLineData(shape)); - // break; - // } - // case 'polygon': { - // normalized.push(this.normalizePolygonData(shape)); - // break; - // } + case 'line': { + normalized.push(this.normalizeLineData(shape)); + break; + } + case 'poly': { + normalized.push(this.normalizePolygonData(shape)); + break; + } } } return normalized; -- GitLab