From e791787c834fcb153fc37a11414a8fd4b9f54157 Mon Sep 17 00:00:00 2001 From: Spencer Alger Date: Mon, 2 Feb 2015 15:27:04 -0700 Subject: [PATCH 1/2] [vislib/columnChart] use the series class to denote the series wrapper el --- src/kibana/components/vislib/visualizations/column_chart.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kibana/components/vislib/visualizations/column_chart.js b/src/kibana/components/vislib/visualizations/column_chart.js index 4df03e59f06ad..d97fed63728fe 100644 --- a/src/kibana/components/vislib/visualizations/column_chart.js +++ b/src/kibana/components/vislib/visualizations/column_chart.js @@ -77,7 +77,7 @@ define(function (require) { .data(layers) .enter().append('g') .attr('class', function (d, i) { - return i; + return 'series ' + i; }); bars = layer.selectAll('rect') From ff1fdc28a38231210408daedcdef072ac072670f Mon Sep 17 00:00:00 2001 From: Spencer Alger Date: Mon, 2 Feb 2015 15:30:12 -0700 Subject: [PATCH 2/2] [vislib/columnChart] count elements in the .series element rather than all rects --- .../specs/vislib/visualizations/column_chart.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/test/unit/specs/vislib/visualizations/column_chart.js b/test/unit/specs/vislib/visualizations/column_chart.js index 924e99bfb6b6b..bfb1b15a07052 100644 --- a/test/unit/specs/vislib/visualizations/column_chart.js +++ b/test/unit/specs/vislib/visualizations/column_chart.js @@ -90,11 +90,7 @@ define(function (require) { numOfSeries = chart.chartData.series.length; numOfValues = chart.chartData.series[0].values.length; product = numOfSeries * numOfValues; - - // remove brushing el before counting rects - $(chart.chartEl).find('g.brush').remove(); - - expect($(chart.chartEl).find('rect')).to.have.length(product); + expect($(chart.chartEl).find('.series rect')).to.have.length(product); }); }); }); @@ -112,13 +108,12 @@ define(function (require) { describe('addBarEvents method', function () { function checkChart(chart) { - var rect = $(chart.chartEl).find('rect')[4]; - var d3selectedRect = d3.select(rect)[0][0]; + var rect = $(chart.chartEl).find('.series rect').get(0); // check for existance of stuff and things return { - click: !!d3selectedRect.__onclick, - mouseOver: !!d3selectedRect.__onmouseover, + click: !!rect.__onclick, + mouseOver: !!rect.__onmouseover, // D3 brushing requires that a g element is appended that // listens for mousedown events. This g element includes // listeners, however, I was not able to test for the listener