mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Merge pull request #6766 from stormpython/backport/6654-4.5
Backporting 6654 to 4.5
This commit is contained in:
commit
6ef64bd699
2 changed files with 12 additions and 9 deletions
|
@ -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');
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue