From 81a9f29b364c99aef39c407e580c540169948815 Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Tue, 22 Mar 2016 14:44:17 -0700 Subject: [PATCH 1/5] Troubleshooting --- .../splits/column_chart/chart_title_split.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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 22d5e5a3c94e..fa1ae0bba592 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 @@ -14,19 +14,20 @@ define(function () { var div = d3.select(this); if (!data.series) { - div.selectAll('.chart-title') - .append('div') + var splits = div.selectAll('.chart-title') + // .append('div') .data(function (d) { return d.rows ? d.rows : d.columns; - }) - .enter() - .append('div') + }); + + splits.exit().remove(); + splits.enter().append('div') .attr('class', 'chart-title'); if (data.rows) { - d3.select('.x-axis-chart-title').remove(); + div.select('.x-axis-chart-title').remove(); } else { - d3.select('.y-axis-chart-title').remove(); + div.select('.y-axis-chart-title').remove(); } return div; From 152f2b6f380d57e1f06b5ba4ed94a15e356cdc9a Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Thu, 24 Mar 2016 10:13:01 -0700 Subject: [PATCH 2/5] troubleshooting --- .../layout/splits/column_chart/chart_title_split.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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 fa1ae0bba592..2a99ee276004 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,4 +1,6 @@ import d3 from 'd3'; +import $ from 'jquery'; + define(function () { return function ChartTitleSplitFactory() { @@ -12,6 +14,7 @@ define(function () { return function (selection) { selection.each(function (data) { var div = d3.select(this); + var parent = $(this).parents('.vis-wrapper')[0]; if (!data.series) { var splits = div.selectAll('.chart-title') @@ -21,13 +24,13 @@ define(function () { }); splits.exit().remove(); - splits.enter().append('div') - .attr('class', 'chart-title'); + splits.enter().append('div'); + splits.attr('class', 'chart-title'); if (data.rows) { - div.select('.x-axis-chart-title').remove(); + d3.select(parent).select('.x-axis-chart-title').remove(); } else { - div.select('.y-axis-chart-title').remove(); + d3.select(parent).select('.y-axis-chart-title').remove(); } return div; From 2ffbb76d7a49a8b3b35f9a6ef6a95f40f03e620f Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Thu, 24 Mar 2016 15:44:54 -0700 Subject: [PATCH 3/5] Closes #6556. Fixes issue with global x and y axis selection. --- .../layout/splits/column_chart/chart_title_split.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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 2a99ee276004..dc98333a10d5 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 @@ -18,14 +18,12 @@ define(function () { if (!data.series) { var splits = div.selectAll('.chart-title') - // .append('div') .data(function (d) { return d.rows ? d.rows : d.columns; - }); - - splits.exit().remove(); - splits.enter().append('div'); - splits.attr('class', 'chart-title'); + }) + .enter() + .append('div') + .attr('class', 'chart-title'); if (data.rows) { d3.select(parent).select('.x-axis-chart-title').remove(); From b2f26e7924e23c471044d240404ef18637839ab5 Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Fri, 25 Mar 2016 09:55:30 -0700 Subject: [PATCH 4/5] fixing tests --- .../lib/layout/splits/column_chart/splits.js | 14 ++++++++------ .../splits/column_chart/chart_title_split.js | 6 +++--- 2 files changed, 11 insertions(+), 9 deletions(-) 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 7b16c4e53f34..94656e34d055 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 @@ -173,18 +173,20 @@ describe('Vislib Split Function Test Suite', function () { }); describe('chart title split function', function () { + var visEl; var newEl; var 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 dc98333a10d5..166d48a3b7b7 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 @@ -14,7 +14,7 @@ define(function () { return function (selection) { selection.each(function (data) { var div = d3.select(this); - var parent = $(this).parents('.vis-wrapper')[0]; + var parent = d3.select($(this).parents('.vis-wrapper')[0]); if (!data.series) { var splits = div.selectAll('.chart-title') @@ -26,9 +26,9 @@ define(function () { .attr('class', 'chart-title'); if (data.rows) { - d3.select(parent).select('.x-axis-chart-title').remove(); + parent.select('.x-axis-chart-title').remove(); } else { - d3.select(parent).select('.y-axis-chart-title').remove(); + parent.select('.y-axis-chart-title').remove(); } return div; From b42f5bfa2f2bd87dc7315e2219302cffbaacdb11 Mon Sep 17 00:00:00 2001 From: Shelby Sturgis Date: Fri, 25 Mar 2016 14:43:59 -0700 Subject: [PATCH 5/5] refactoring --- .../lib/layout/splits/column_chart/chart_title_split.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 166d48a3b7b7..d81a2ec43b66 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 @@ -14,7 +14,7 @@ define(function () { return function (selection) { selection.each(function (data) { var div = d3.select(this); - var parent = d3.select($(this).parents('.vis-wrapper')[0]); + var parent = $(this).parents('.vis-wrapper'); if (!data.series) { var splits = div.selectAll('.chart-title') @@ -26,9 +26,9 @@ define(function () { .attr('class', 'chart-title'); if (data.rows) { - parent.select('.x-axis-chart-title').remove(); + parent.find('.x-axis-chart-title').remove(); } else { - parent.select('.y-axis-chart-title').remove(); + parent.find('.y-axis-chart-title').remove(); } return div;