-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix uniformtext and enable coloraxis for sunburst and treemap as well as pathbar.textfont #4444
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
Changes from 8 commits
869b97b
b129c5d
c630060
3737ca9
f6b91e8
ef6a952
2cf7def
6a4b451
16848b3
79ea1cc
2a7721c
ba1ae6f
599de22
0e3e6e2
a827bff
a9c9589
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 |
---|---|---|
|
@@ -58,8 +58,8 @@ function getXY(di, xa, ya, isHorizontal) { | |
return isHorizontal ? [s, p] : [p, s]; | ||
} | ||
|
||
function transition(selection, opts, makeOnCompleteCallback) { | ||
if(hasTransition(opts)) { | ||
function transition(selection, fullLayout, opts, makeOnCompleteCallback) { | ||
if(!fullLayout.uniformtext.mode && hasTransition(opts)) { | ||
var onComplete; | ||
if(makeOnCompleteCallback) { | ||
onComplete = makeOnCompleteCallback(); | ||
|
@@ -91,6 +91,9 @@ function plot(gd, plotinfo, cdModule, traceLayer, opts, makeOnCompleteCallback) | |
gap: fullLayout.bargap, | ||
groupgap: fullLayout.bargroupgap | ||
}; | ||
|
||
// don't clear bar when this is called from waterfall or funnel | ||
clearMinTextSize('bar', fullLayout); | ||
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. Wait. Here you're clearing the min-text-size stash during the plot step. So what's happens when a style-only edit (e.g. To me, this logic should probably be somewhere in the calc step. 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. Restyle works. Considering interactions (e.g. zoom and selection) this should be cleared after calc and at the stat of plot. 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.
Can you explain a bit more here? To me, sounds like we should not clear 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. Or let me rephrase my question: if you do move 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. Yes. In that case the react tests would fail. 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. Can you share the branch you used to test that? 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. Summing up a private convo:
|
||
} | ||
|
||
var bartraces = Lib.makeTraceGroups(traceLayer, cdModule, 'trace bars').each(function(cd) { | ||
|
@@ -209,13 +212,13 @@ function plot(gd, plotinfo, cdModule, traceLayer, opts, makeOnCompleteCallback) | |
y1 = fixpx(y1, y0); | ||
} | ||
|
||
var sel = transition(Lib.ensureSingle(bar, 'path'), opts, makeOnCompleteCallback); | ||
var sel = transition(Lib.ensureSingle(bar, 'path'), fullLayout, opts, makeOnCompleteCallback); | ||
sel | ||
.style('vector-effect', 'non-scaling-stroke') | ||
.attr('d', 'M' + x0 + ',' + y0 + 'V' + y1 + 'H' + x1 + 'V' + y0 + 'Z') | ||
.call(Drawing.setClipUrl, plotinfo.layerClipId, gd); | ||
|
||
if(hasTransition(opts)) { | ||
if(!fullLayout.uniformtext.mode && hasTransition(opts)) { | ||
var styleFns = Drawing.makePointStyleFns(trace); | ||
Drawing.singlePointStyle(di, sel, trace, styleFns, gd); | ||
} | ||
|
@@ -409,7 +412,7 @@ function appendBarText(gd, plotinfo, bar, cd, i, x0, x1, y0, y1, opts, makeOnCom | |
recordMinTextSize(trace.type, transform, fullLayout); | ||
calcBar.transform = transform; | ||
|
||
transition(textSelection, opts, makeOnCompleteCallback) | ||
transition(textSelection, fullLayout, opts, makeOnCompleteCallback) | ||
.attr('transform', Lib.getTextTransform(transform)); | ||
} | ||
|
||
|
@@ -419,7 +422,7 @@ function recordMinTextSize( | |
fullLayout // inout | ||
) { | ||
if(fullLayout.uniformtext.mode) { | ||
var minKey = '_' + traceType + 'Text_minsize'; | ||
var minKey = getMinKey(traceType); | ||
var minSize = fullLayout.uniformtext.minsize; | ||
var size = transform.scale * transform.fontSize; | ||
|
||
|
@@ -435,6 +438,18 @@ function recordMinTextSize( | |
} | ||
} | ||
|
||
function clearMinTextSize( | ||
traceType, // in | ||
fullLayout // inout | ||
) { | ||
var minKey = getMinKey(traceType); | ||
fullLayout[minKey] = undefined; | ||
} | ||
|
||
function getMinKey(traceType) { | ||
return '_' + traceType + 'Text_minsize'; | ||
} | ||
|
||
function getRotateFromAngle(angle) { | ||
return (angle === 'auto') ? 0 : angle; | ||
} | ||
|
@@ -750,5 +765,6 @@ function calcTextinfo(cd, index, xa, ya) { | |
module.exports = { | ||
plot: plot, | ||
toMoveInsideBar: toMoveInsideBar, | ||
recordMinTextSize: recordMinTextSize | ||
recordMinTextSize: recordMinTextSize, | ||
clearMinTextSize: clearMinTextSize | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,7 +97,7 @@ module.exports = function drawAncestors(gd, cd, entry, slices, opts) { | |
} | ||
|
||
updateSlices.each(function(pt) { | ||
pt._hoverX = viewX(pt.x1 - height / 2); | ||
pt._hoverX = viewX(pt.x1 - Math.min(width, height) / 2); | ||
pt._hoverY = viewY(pt.y1 - height / 2); | ||
|
||
var sliceTop = d3.select(this); | ||
|
@@ -141,7 +141,9 @@ module.exports = function drawAncestors(gd, cd, entry, slices, opts) { | |
s.attr('data-notex', 1); | ||
}); | ||
|
||
var font = Lib.ensureUniformFontSize(gd, helpers.determineTextFont(trace, pt, fullLayout.font, trace.pathdir)); | ||
var font = Lib.ensureUniformFontSize(gd, helpers.determineTextFont(trace, pt, fullLayout.font, { | ||
onPathbar: true | ||
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. Can you explain why this commit made three existing mocks change ( 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 question. |
||
})); | ||
|
||
sliceText.text(pt._text || ' ') // use one space character instead of a blank string to avoid jumps during transition | ||
.classed('slicetext', true) | ||
|
@@ -151,22 +153,11 @@ module.exports = function drawAncestors(gd, cd, entry, slices, opts) { | |
|
||
pt.textBB = Drawing.bBox(sliceText.node()); | ||
pt.transform = toMoveInsideSlice(pt, { | ||
fontSize: font.size, | ||
onPathbar: true | ||
}); | ||
|
||
pt.transform.fontSize = font.size; | ||
|
||
if(helpers.isOutsideText(trace, pt)) { | ||
// consider in/out diff font sizes | ||
var outsideFont = helpers.getOutsideTextFontKey('size', trace, pt, fullLayout.font); | ||
var insideFont = helpers.getInsideTextFontKey('size', trace, pt, fullLayout.font); | ||
|
||
var diffFontSize = outsideFont - insideFont; | ||
|
||
pt.transform.targetY -= diffFontSize; | ||
pt.transform.fontSize -= diffFontSize; | ||
} | ||
|
||
if(hasTransition) { | ||
sliceText.transition().attrTween('transform', function(pt2) { | ||
var interp = makeUpdateTextInterpolator(pt2, onPathbar, refRect, [width, height]); | ||
|
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.
Why? I thought you said this transitions looked fine
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.
They did not apply a uniform text size during and after smooth transition.