Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backporting PR #6654 to 4.x - Fixes global chart title selection #6763

Merged
merged 1 commit into from
Apr 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
})
Expand All @@ -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;
Expand Down