Skip to content

Commit e3a8e91

Browse files
committed
check for falsy 0 numbers when searching for level and ids
1 parent 6130f96 commit e3a8e91

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/traces/sunburst/helpers.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ var Color = require('../../components/color');
1313
var setCursor = require('../../lib/setcursor');
1414
var pieHelpers = require('../pie/helpers');
1515

16-
function hasLabel(label) {
17-
return label || label === 0;
16+
function labelStr(label) {
17+
return (label || label === 0) ? label + '' : '';
1818
}
1919

2020
exports.findEntryWithLevel = function(hierarchy, level) {
2121
var out;
22-
if(level) {
22+
var key = labelStr(level);
23+
if(key) {
2324
hierarchy.eachAfter(function(pt) {
24-
if(exports.getPtId(pt) === level) {
25+
if(exports.getPtId(pt) === key) {
2526
return out = pt.copy();
2627
}
2728
});
@@ -31,11 +32,12 @@ exports.findEntryWithLevel = function(hierarchy, level) {
3132

3233
exports.findEntryWithChild = function(hierarchy, childId) {
3334
var out;
35+
var key = labelStr(childId);
3436
hierarchy.eachAfter(function(pt) {
3537
var children = pt.children || [];
3638
for(var i = 0; i < children.length; i++) {
3739
var child = children[i];
38-
if(exports.getPtId(child) === childId) {
40+
if(exports.getPtId(child) === key) {
3941
return out = pt.copy();
4042
}
4143
}
@@ -144,7 +146,7 @@ exports.isHeader = function(pt, trace) { // it is only used in treemap.
144146
};
145147

146148
exports.getLabelStr = function(label) {
147-
return hasLabel(label) ? label.split('<br>').join(' ') : '';
149+
return labelStr(label).split('<br>').join(' ');
148150
};
149151

150152
exports.getLabelString = function(label) { // used in hover to reference to the "root"

0 commit comments

Comments
 (0)