Skip to content

Handle special bar insidetext case on log size axes #3762

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

Merged
merged 1 commit into from
Apr 11, 2019

Conversation

etpinard
Copy link
Contributor

@etpinard etpinard added bug something broken status: reviewable labels Apr 11, 2019
@@ -226,6 +226,21 @@ function appendBarText(gd, bar, calcTrace, i, x0, x1, y0, y1) {
var insideTextFont = style.getInsideTextFont(trace, i, layoutFont, barColor);
var outsideTextFont = style.getOutsideTextFont(trace, i, layoutFont);

// Special case: don't use the c2p(v, true) value on log size axes,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See

function toLog(v, clip) {
if(v > 0) return Math.log(v) / Math.LN10;
else if(v <= 0 && clip && ax.range && ax.range.length === 2) {
// clip NaN (ie past negative infinity) to LOG_CLIP axis
// length past the negative edge
var r0 = ax.range[0];
var r1 = ax.range[1];
return 0.5 * (r0 + r1 - 2 * LOG_CLIP * Math.abs(r0 - r1));
}
else return BADNUM;
}

for more info that true option.

@antoinerg
Copy link
Contributor

Thanks for the fix! Looks good to me 💃

@etpinard etpinard merged commit 5d051e7 into master Apr 11, 2019
@etpinard etpinard deleted the fix-bar-inside-text-log-size-axes branch April 11, 2019 20:44
etpinard added a commit that referenced this pull request Apr 15, 2019
... a follow-up from my lazy attempt in
    #3762
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inside texts in stacked bar charts are cut off for log scale
2 participants