-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Treemap new trace type #4185
Treemap new trace type #4185
Changes from 1 commit
ec6a9de
52ded31
320f81a
06d93ae
6cc8590
6a595b6
671e864
648167d
6dad958
cceee49
f3d38b8
088b0e0
e23a577
eb54f24
0e3185f
fdd69e7
a7b6074
4c85360
65c0e02
ca4b385
0012fa1
544977e
13e0449
57dec38
65f0213
ad24987
36fb510
284bf6d
4e2c328
0cf5bf6
2405ba4
19c7a61
4e3b7f3
e5181ac
e9c0202
e4bc91e
a54ca9c
d7b06a1
c91f9db
ceb13f7
1270d67
35ea4b3
1de80d9
e7e22c6
6130f96
e3a8e91
14674d6
01c5f68
4c7a092
1860826
d2b07b5
1fdf574
3004a9a
4d790a1
1c6e47b
e339bf5
1309bfd
217c0f4
8416883
c918da9
7d67c7a
f8cef49
3c12bf6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -487,10 +487,31 @@ exports.formatSliceLabel = function(pt, entry, trace, cd, fullLayout) { | |||||||||
var cd0 = cd[0]; | ||||||||||
var cdi = pt.data.data; | ||||||||||
var hierarchy = cd0.hierarchy; | ||||||||||
var isRoot = helpers.isHierarchyRoot(pt); | ||||||||||
var isEntry = helpers.isEntry(pt); | ||||||||||
var parent = isEntry ? pt._parent : pt.parent; | ||||||||||
|
||||||||||
var ref; | ||||||||||
var getLabel = function(d) { | ||||||||||
if(d.hasOwnProperty('hierarchy')) return d.hierarchy.label; | ||||||||||
if(!(d.data && d.data.data)) return ''; | ||||||||||
var id = helpers.getPtId(d); | ||||||||||
for(var q = 0; q < cd.length; q++) { | ||||||||||
if(cd[q].label === id) { | ||||||||||
return id; | ||||||||||
} | ||||||||||
} | ||||||||||
return ''; | ||||||||||
}; | ||||||||||
|
||||||||||
var getVal = function(d) { | ||||||||||
if(d.hasOwnProperty('hierarchy')) return d.hierarchy.value; | ||||||||||
return d.hasOwnProperty('v') ? d.v : d.value; | ||||||||||
}; | ||||||||||
|
||||||||||
var calcPercent = function() { | ||||||||||
return (trace.branchvalues ? cdi.v : cdi.value) / (ref.value || ref.v); | ||||||||||
var result = (trace.branchvalues ? cdi.v : cdi.value) / getVal(ref); | ||||||||||
return isFinite(result) ? result : 1; | ||||||||||
}; | ||||||||||
|
||||||||||
if(trace.type === 'treemap' && helpers.isHeader(pt, trace)) { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need this
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... with the plotly.js/src/traces/treemap/draw_descendants.js Lines 167 to 169 in 217c0f4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call. Moved to |
||||||||||
|
@@ -510,8 +531,6 @@ exports.formatSliceLabel = function(pt, entry, trace, cd, fullLayout) { | |||||||||
var hasFlag = function(flag) { return parts.indexOf(flag) !== -1; }; | ||||||||||
var thisText = []; | ||||||||||
var tx; | ||||||||||
var parent = helpers.isEntry(pt) ? pt._parent : pt.parent; | ||||||||||
var isRoot = helpers.isHierarchyRoot(pt); | ||||||||||
|
||||||||||
if(hasFlag('label') && cdi.label) { | ||||||||||
thisText.push(cdi.label); | ||||||||||
|
@@ -580,28 +599,26 @@ exports.formatSliceLabel = function(pt, entry, trace, cd, fullLayout) { | |||||||||
|
||||||||||
obj.currentPath = helpers.getPath(pt.data); | ||||||||||
|
||||||||||
if(pt.parent) { | ||||||||||
ref = pt.parent; | ||||||||||
obj.percentParent = calcPercent(); | ||||||||||
obj.percentParentLabel = helpers.formatPercent( | ||||||||||
obj.percentParent, separators | ||||||||||
); | ||||||||||
obj.parent = ref.data.data.label; | ||||||||||
} | ||||||||||
ref = parent; | ||||||||||
obj.percentParent = calcPercent(); | ||||||||||
obj.percentParentLabel = helpers.formatPercent( | ||||||||||
obj.percentParent, separators | ||||||||||
); | ||||||||||
obj.parent = helpers.getLabelString(getLabel(ref)); | ||||||||||
|
||||||||||
ref = entry; | ||||||||||
obj.percentEntry = calcPercent(); | ||||||||||
obj.percentEntryLabel = helpers.formatPercent( | ||||||||||
obj.percentEntry, separators | ||||||||||
); | ||||||||||
obj.entry = ref.data.data.label; | ||||||||||
obj.entry = helpers.getLabelString(getLabel(ref)); | ||||||||||
|
||||||||||
ref = hierarchy; | ||||||||||
obj.percentRoot = calcPercent(); | ||||||||||
obj.percentRootLabel = helpers.formatPercent( | ||||||||||
obj.percentRoot, separators | ||||||||||
); | ||||||||||
obj.root = ref.data.data.label; | ||||||||||
obj.root = helpers.getLabelString(getLabel(ref)); | ||||||||||
|
||||||||||
if(cdi.hasOwnProperty('color')) { | ||||||||||
obj.color = cdi.color; | ||||||||||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -507,7 +507,7 @@ describe('Test sunburst hover:', function() { | |||
curveNumber: 0, | ||||
pointNumber: 0, | ||||
label: 'Eve', | ||||
parent: '' | ||||
parent: '"root"' | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't look right. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK if we return an empty string here? plotly.js/src/traces/sunburst/helpers.js Line 154 in 217c0f4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are the side-effects? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simply getting blank string (nothing) referring to the dummy root label in hover; which I think is fine. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 8416883. |
||||
} | ||||
} | ||||
}] | ||||
|
@@ -1344,10 +1344,7 @@ describe('Test sunburst texttemplate without `values` should work:', function() | |||
['text: %{text}', ['text: sixty-five', 'text: fourteen', 'text: twelve', 'text: ten', 'text: two', 'text: six', 'text: six', 'text: one', 'text: four']], | ||||
['%{percentRoot} of %{root}', ['100% of Eve', '33% of Eve', '17% of Eve', '17% of Eve', '17% of Eve', '17% of Eve', '17% of Eve', '17% of Eve', '17% of Eve']], | ||||
['%{percentEntry} of %{entry}', ['100% of Eve', '33% of Eve', '17% of Eve', '17% of Eve', '17% of Eve', '17% of Eve', '17% of Eve', '17% of Eve', '17% of Eve']], | ||||
['%{percentParent} of %{parent}', [ | ||||
'%{percentParent} of %{parent}', // TODO: what should be printed for the parent of root? | ||||
'100% of Seth', '33% of Eve', '17% of Eve', '17% of Eve', '17% of Eve', '17% of Eve', '50% of Seth', '100% of Awan' | ||||
]], | ||||
['%{percentParent} of %{parent}', ['100% of "root"', '100% of Seth', '33% of Eve', '17% of Eve', '17% of Eve', '17% of Eve', '17% of Eve', '50% of Seth', '100% of Awan']], | ||||
[ | ||||
[ | ||||
'label: %{label}', | ||||
|
@@ -1390,10 +1387,7 @@ describe('Test sunburst texttemplate with *total* `values` should work:', functi | |||
['text: %{text}', ['text: sixty-five', 'text: fourteen', 'text: twelve', 'text: ten', 'text: two', 'text: six', 'text: six', 'text: one', 'text: four']], | ||||
['%{percentRoot} of %{root}', ['100% of Eve', '22% of Eve', '18% of Eve', '9% of Eve', '9% of Eve', '6% of Eve', '15% of Eve', '3% of Eve', '2% of Eve']], | ||||
['%{percentEntry} of %{entry}', ['100% of Eve', '22% of Eve', '18% of Eve', '9% of Eve', '9% of Eve', '6% of Eve', '15% of Eve', '3% of Eve', '2% of Eve']], | ||||
['%{percentParent} of %{parent}', [ | ||||
'%{percentParent} of %{parent}', // TODO: what should be printed for the parent of root? | ||||
'22% of Eve', '18% of Eve', '9% of Eve', '9% of Eve', '6% of Eve', '83% of Seth', '17% of Seth', '17% of Awan' | ||||
]], | ||||
['%{percentParent} of %{parent}', ['100% of "root"', '22% of Eve', '18% of Eve', '9% of Eve', '9% of Eve', '6% of Eve', '83% of Seth', '17% of Seth', '17% of Awan']], | ||||
[ | ||||
[ | ||||
'label: %{label}', | ||||
|
@@ -1436,10 +1430,7 @@ describe('Test sunburst texttemplate with *remainder* `values` should work:', fu | |||
['text: %{text}', ['text: sixty-five', 'text: fourteen', 'text: twelve', 'text: ten', 'text: two', 'text: six', 'text: six', 'text: one', 'text: four']], | ||||
['%{percentRoot} of %{root}', ['54% of Eve', '10% of Eve', '12% of Eve', '5% of Eve', '5% of Eve', '3% of Eve', '8% of Eve', '2% of Eve', '1% of Eve']], | ||||
['%{percentEntry} of %{entry}', ['54% of Eve', '10% of Eve', '12% of Eve', '5% of Eve', '5% of Eve', '3% of Eve', '8% of Eve', '2% of Eve', '1% of Eve']], | ||||
['%{percentParent} of %{parent}', [ | ||||
'%{percentParent} of %{parent}', // TODO: what should be printed for the parent of root? | ||||
'10% of Eve', '12% of Eve', '5% of Eve', '5% of Eve', '3% of Eve', '42% of Seth', '8% of Seth', '14% of Awan' | ||||
]], | ||||
['%{percentParent} of %{parent}', ['100% of "root"', '10% of Eve', '12% of Eve', '5% of Eve', '5% of Eve', '3% of Eve', '42% of Seth', '8% of Seth', '14% of Awan']], | ||||
[ | ||||
[ | ||||
'label: %{label}', | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does
d
get ahierarchy
key?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here:
plotly.js/src/traces/treemap/plot.js
Lines 90 to 93 in 217c0f4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed in 8416883.