Skip to content

Commit

Permalink
Merge pull request #6654 from stormpython/issue/6556
Browse files Browse the repository at this point in the history
Fixes global chart title selection
  • Loading branch information
stormpython committed Apr 1, 2016
2 parents 698086b + 7f96a11 commit 52d3fbc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,20 @@ describe('Vislib Split Function Test Suite', function () {
});

describe('chart title split function', function () {
let newEl;
let fixture;
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');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import d3 from 'd3';
import $ from 'jquery';

define(function () {
return function ChartTitleSplitFactory() {

Expand All @@ -12,10 +14,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')
var splits = div.selectAll('.chart-title')
.data(function (d) {
return d.rows ? d.rows : d.columns;
})
Expand All @@ -24,9 +26,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;
Expand Down

0 comments on commit 52d3fbc

Please sign in to comment.