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

Fixes global chart title selection #6654

Merged
merged 10 commits into from
Apr 1, 2016
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 = d3.select($(this).parents('.vis-wrapper')[0]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need to be wrapped in d3.select? can we use only jquery, or d3 instead?


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.select('.x-axis-chart-title').remove();
} else {
d3.select('.y-axis-chart-title').remove();
parent.select('.y-axis-chart-title').remove();
}

return div;
Expand Down