From d38f0a110aedcad816a2c74397d4eb65edb4da30 Mon Sep 17 00:00:00 2001 From: Bruno Trecenti Date: Tue, 25 Feb 2014 10:48:44 -0300 Subject: [PATCH] plotting horizontal line in the center --- src/graphing/radar.js | 7 +++++++ test/graphing/radar-spec.js | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/graphing/radar.js b/src/graphing/radar.js index 2f472f9..0b97019 100644 --- a/src/graphing/radar.js +++ b/src/graphing/radar.js @@ -10,6 +10,13 @@ tr.graphing.Radar = function (svg, size, radar) { .attr('x2', size / 2) .attr('y2', size) .attr('stroke-width', 5); + + svg.append('line') + .attr('x1', 0) + .attr('y1', size / 2) + .attr('x2', size) + .attr('y2', size / 2) + .attr('stroke-width', 5); }; self.plot = function () { diff --git a/test/graphing/radar-spec.js b/test/graphing/radar-spec.js index f5747c6..7608988 100644 --- a/test/graphing/radar-spec.js +++ b/test/graphing/radar-spec.js @@ -30,5 +30,22 @@ describe('tr.graphing.Radar', function () { expect(svg.attr).toHaveBeenCalledWith('y2', 500); expect(svg.attr).toHaveBeenCalledWith('stroke-width', 5); }); + + it('plots a horizontal line in the center', function () { + var svg = buildSvg(); + spyOn(svg, 'append').andReturn(svg); + spyOn(svg, 'attr').andReturn(svg); + + var radarGraph = new tr.graphing.Radar(svg, 500); + + radarGraph.plot(); + + expect(svg.append).toHaveBeenCalledWith('line'); + expect(svg.attr).toHaveBeenCalledWith('x1', 0); + expect(svg.attr).toHaveBeenCalledWith('y1', 500 / 2); + expect(svg.attr).toHaveBeenCalledWith('x2', 500); + expect(svg.attr).toHaveBeenCalledWith('y2', 500 / 2); + expect(svg.attr).toHaveBeenCalledWith('stroke-width', 5); + }); }) }); -- 2.39.2