Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2k
Bug fix - do not display empty bars when line.width is zero#4056
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
60f71a19d4a4bf3ee7dbf579a1b5File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -10,6 +10,7 @@ | ||
| var isNumeric = require('fast-isnumeric'); | ||
| var tinycolor = require('tinycolor2'); | ||
| var isArrayOrTypedArray = require('../../lib').isArrayOrTypedArray; | ||
| exports.coerceString = function(attributeDefinition, value, defaultValue) { | ||
| if(typeof value === 'string') { | ||
| @@ -64,3 +65,12 @@ exports.getValue = function(arrayOrScalar, index) { | ||
| else if(index < arrayOrScalar.length) value = arrayOrScalar[index]; | ||
| return value; | ||
| }; | ||
| exports.getLineWidth = function(trace, di) { | ||
Contributor 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. Bars don't have | ||
| var w = | ||
| (0 < di.mlw) ? di.mlw : | ||
| !isArrayOrTypedArray(trace.marker.line.width) ? trace.marker.line.width : | ||
| 0; | ||
| return w; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -69,7 +69,7 @@ function plot(gd, plotinfo, cdModule, traceLayer, opts) { | ||
| var isWaterfall = (trace.type === 'waterfall'); | ||
| var isFunnel = (trace.type === 'funnel'); | ||
| var isBar = (trace.type === 'bar'); | ||
| var shouldDisplayZeros = isBar || isFunnel; | ||
| var shouldDisplayZeros = (isBar || isFunnel); | ||
| var adjustPixel = 0; | ||
| if(isWaterfall && trace.connector.visible && trace.connector.mode === 'between') { | ||
| @@ -102,12 +102,19 @@ function plot(gd, plotinfo, cdModule, traceLayer, opts) { | ||
| var y0 = xy[1][0]; | ||
| var y1 = xy[1][1]; | ||
| var isBlank = di.isBlank = !( | ||
| isNumeric(x0) && isNumeric(x1) && | ||
| isNumeric(y0) && isNumeric(y1) && | ||
| (x0 !== x1 || (shouldDisplayZeros && isHorizontal)) && | ||
| (y0 !== y1 || (shouldDisplayZeros && !isHorizontal)) | ||
| var isBlank = ( | ||
| x0 === x1 || | ||
| y0 === y1 || | ||
| !isNumeric(x0) || | ||
| !isNumeric(x1) || | ||
| !isNumeric(y0) || | ||
| !isNumeric(y1) | ||
| ); | ||
| // display zeros if line.width > 0 | ||
| if(isBlank && shouldDisplayZeros && helpers.getLineWidth(trace, di) && (isHorizontal ? x1 - x0 === 0 : y1 - y0 === 0)) { | ||
| isBlank = false; | ||
| } | ||
| di.isBlank = isBlank; | ||
| // in waterfall mode `between` we need to adjust bar end points to match the connector width | ||
| if(adjustPixel) { | ||
| @@ -130,8 +137,7 @@ function plot(gd, plotinfo, cdModule, traceLayer, opts) { | ||
| mc = cont.color; | ||
| } | ||
| } else { | ||
| lw = (di.mlw + 1 || trace.marker.line.width + 1 || | ||
| (di.trace ? di.trace.marker.line.width : 0) + 1) - 1; | ||
etpinard marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| lw = helpers.getLineWidth(trace, di); | ||
| mc = di.mc || trace.marker.color; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
I wonder what's faster
or
No need to change anything, I'm just thinking out-loud.
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.
Interesting question. And I like the minimalist version with
Lib.noop!That may depend on the browser.
Having two loops may also be fast.