-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3641 from stormpython/clickable-legends
Clickable legends
- Loading branch information
Showing
17 changed files
with
257 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/kibana/components/vislib/components/labels/pie/get_pie_names.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
define(function (require) { | ||
var _ = require('lodash'); | ||
|
||
return function GetPieNames(Private) { | ||
var returnNames = Private(require('components/vislib/components/labels/pie/return_pie_names')); | ||
|
||
return function (data, columns) { | ||
var slices = data.slices; | ||
|
||
if (slices.children) { | ||
return _(returnNames(slices.children, 0, columns)) | ||
.sortBy(function (obj) { | ||
return obj.index; | ||
}) | ||
.pluck('key') | ||
.unique() | ||
.value(); | ||
} | ||
}; | ||
}; | ||
}); |
26 changes: 26 additions & 0 deletions
26
src/kibana/components/vislib/components/labels/pie/pie_labels.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
define(function (require) { | ||
var _ = require('lodash'); | ||
|
||
return function PieLabels(Private) { | ||
var removeZeroSlices = Private(require('components/vislib/components/labels/pie/remove_zero_slices')); | ||
var getNames = Private(require('components/vislib/components/labels/pie/get_pie_names')); | ||
|
||
return function (obj) { | ||
if (!_.isObject(obj)) { throw new TypeError('PieLabel expects an object'); } | ||
|
||
var data = obj.columns || obj.rows || [obj]; | ||
var names = []; | ||
|
||
data.forEach(function (obj) { | ||
var columns = obj.raw ? obj.raw.columns : undefined; | ||
obj.slices = removeZeroSlices(obj.slices); | ||
|
||
getNames(obj, columns).forEach(function (name) { | ||
names.push(name); | ||
}); | ||
}); | ||
|
||
return _.uniq(names); | ||
}; | ||
}; | ||
}); |
17 changes: 17 additions & 0 deletions
17
src/kibana/components/vislib/components/labels/pie/remove_zero_slices.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
define(function (require) { | ||
var _ = require('lodash'); | ||
|
||
return function RemoveZeroSlices() { | ||
return function removeZeroSlices(slices) { | ||
if (!slices.children) return slices; | ||
|
||
slices = _.clone(slices); | ||
slices.children = slices.children.reduce(function (children, child) { | ||
if (child.size !== 0) { children.push(removeZeroSlices(child)); } | ||
return children; | ||
}, []); | ||
|
||
return slices; | ||
}; | ||
}; | ||
}); |
19 changes: 19 additions & 0 deletions
19
src/kibana/components/vislib/components/labels/pie/return_pie_names.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
define(function () { | ||
return function ReturnPieNames() { | ||
return function returnNames(array, index, columns) { | ||
var names = []; | ||
|
||
array.forEach(function (obj) { | ||
names.push({ key: obj.name, index: index }); | ||
|
||
if (obj.children) { | ||
returnNames(obj.children, (index + 1), columns).forEach(function (namedObj) { | ||
names.push(namedObj); | ||
}); | ||
} | ||
}); | ||
|
||
return names; | ||
}; | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.