diff --git a/src/ui/public/vislib/__tests__/lib/layout/splits/column_chart/splits.js b/src/ui/public/vislib/__tests__/lib/layout/splits/column_chart/splits.js index f83b8320d21d..4ef36bfac09d 100644 --- a/src/ui/public/vislib/__tests__/lib/layout/splits/column_chart/splits.js +++ b/src/ui/public/vislib/__tests__/lib/layout/splits/column_chart/splits.js @@ -169,18 +169,20 @@ describe('Vislib Split Function Test Suite', function () { }); describe('chart title split function', function () { + let visEl; let newEl; let fixture; beforeEach(ngMock.inject(function () { - el.append('div').attr('class', 'x-axis-chart-title'); - el.append('div').attr('class', 'y-axis-chart-title'); - d3.select('.x-axis-chart-title').call(chartTitleSplit); - d3.select('.y-axis-chart-title').call(chartTitleSplit); + visEl = el.append('div').attr('class', 'vis-wrapper'); + visEl.append('div').attr('class', 'x-axis-chart-title'); + visEl.append('div').attr('class', 'y-axis-chart-title'); + visEl.select('.x-axis-chart-title').call(chartTitleSplit); + visEl.select('.y-axis-chart-title').call(chartTitleSplit); newEl = d3.select('body').append('div') - .attr('class', 'series') - .datum({ series: []}); + .attr('class', 'vis-wrapper') + .datum({ series: [] }); newEl.append('div').attr('class', 'x-axis-chart-title'); newEl.append('div').attr('class', 'y-axis-chart-title'); diff --git a/src/ui/public/vislib/lib/layout/splits/column_chart/chart_title_split.js b/src/ui/public/vislib/lib/layout/splits/column_chart/chart_title_split.js index 03c80a66b114..133b9d8e4157 100644 --- a/src/ui/public/vislib/lib/layout/splits/column_chart/chart_title_split.js +++ b/src/ui/public/vislib/lib/layout/splits/column_chart/chart_title_split.js @@ -1,6 +1,7 @@ define(function () { return function ChartTitleSplitFactory() { var d3 = require('d3'); + var $ = require('jquery'); /* * Adds div DOM elements to either the `.y-axis-chart-title` element or the @@ -12,10 +13,10 @@ define(function () { return function (selection) { selection.each(function (data) { var div = d3.select(this); + var parent = $(this).parents('.vis-wrapper'); if (!data.series) { div.selectAll('.chart-title') - .append('div') .data(function (d) { return d.rows ? d.rows : d.columns; }) @@ -24,9 +25,9 @@ define(function () { .attr('class', 'chart-title'); if (data.rows) { - d3.select('.x-axis-chart-title').remove(); + parent.find('.x-axis-chart-title').remove(); } else { - d3.select('.y-axis-chart-title').remove(); + parent.find('.y-axis-chart-title').remove(); } return div;