forked from plotly/plotly.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Implement attributes base, offset and width in bar traces (issue 80) #3
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
Closed
Closed
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
03e5072
bar: use descriptive variable names
n-riesco bbdc385
bar: convert closure into function
n-riesco 7b14fcd
bar: refactor code to group bars
n-riesco fe66e3c
bar: rename `barpositions` to `setOffsetAndWidth`
n-riesco d422f67
bar: refactor code into function `setBaseAndSize`
n-riesco 97da55b
bar: replace t.dbar with t.bargroupwidth
n-riesco 93ca66e
bar: Move code for `overlay` mode into a function
n-riesco 80fdfbd
bar: refactor code into functions for each barmode
n-riesco 3b87e85
bar: use Sieve to stack bars in setBaseAndSize
n-riesco a7ca755
bar: add functions stackBars and normalizeBars
n-riesco 1400311
bar: fix image test failure in hist_grouped
n-riesco 4294cad
bar: do not normalise bars with no size
n-riesco 4866cda
bar: Add attributes base, offset and width
n-riesco 79f2e8d
bar: add function sieveBars
n-riesco 10b678b
bar: do not assume initial bar base is zero
n-riesco 23f7415
bar: ensure size axis includes bar bases
n-riesco 6f05b34
bar: do not stack traces that set bar base
n-riesco d4f7747
bar: implement attributes base, offset and width
n-riesco 0e6e0f1
test: add bar charts using base, offset and width
n-riesco e83f4c5
bar: guard against invalid base items
n-riesco f4143e8
bar: guard against invalid offset or width items
n-riesco 125c537
bar: remove use of forEach
n-riesco f0a0c92
bar: set base, offset and width default to null
n-riesco 2ca7605
bar: add note to setGroupPositionsInOverlayMode
n-riesco 497121d
bar: fix expansion of position axis
n-riesco 54a0967
test: bar pinning tests
n-riesco 6f58cd0
test: update bar base tests
n-riesco bb93aba
bar: interpret trace data as sizes
n-riesco 307d955
test: update bar_attrs_* mock images
n-riesco bad5c51
test: update mock bar_attrs_group_norm
n-riesco 6c6d680
test: update bar_attrs_group_norm baseline
n-riesco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,8 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { | |
xa = pointData.xa, | ||
ya = pointData.ya, | ||
barDelta = (hovermode === 'closest') ? | ||
t.barwidth / 2 : t.dbar * (1 - xa._gd._fullLayout.bargap) / 2, | ||
t.barwidth / 2 : | ||
t.bargroupwidth, | ||
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. nice simplification. 👍 |
||
barPos; | ||
|
||
if(hovermode !== 'closest') barPos = function(di) { return di.p; }; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,30 +34,39 @@ module.exports = function plot(gd, plotinfo, cdbar) { | |
.attr('class', 'points') | ||
.each(function(d) { | ||
var t = d[0].t, | ||
trace = d[0].trace; | ||
trace = d[0].trace, | ||
poffset = t.poffset, | ||
poffsetIsArray = Array.isArray(poffset), | ||
barwidth = t.barwidth, | ||
barwidthIsArray = Array.isArray(barwidth); | ||
|
||
arraysToCalcdata(d); | ||
|
||
d3.select(this).selectAll('path') | ||
.data(Lib.identity) | ||
.enter().append('path') | ||
.each(function(di) { | ||
.each(function(di, i) { | ||
// now display the bar | ||
// clipped xf/yf (2nd arg true): non-positive | ||
// log values go off-screen by plotwidth | ||
// so you see them continue if you drag the plot | ||
var p0 = di.p + ((poffsetIsArray) ? poffset[i] : poffset), | ||
p1 = p0 + ((barwidthIsArray) ? barwidth[i] : barwidth), | ||
s0 = di.b, | ||
s1 = s0 + di.s; | ||
|
||
var x0, x1, y0, y1; | ||
if(trace.orientation === 'h') { | ||
y0 = ya.c2p(t.poffset + di.p, true); | ||
y1 = ya.c2p(t.poffset + di.p + t.barwidth, true); | ||
x0 = xa.c2p(di.b, true); | ||
x1 = xa.c2p(di.s + di.b, true); | ||
y0 = ya.c2p(p0, true); | ||
y1 = ya.c2p(p1, true); | ||
x0 = xa.c2p(s0, true); | ||
x1 = xa.c2p(s1, true); | ||
} | ||
else { | ||
x0 = xa.c2p(t.poffset + di.p, true); | ||
x1 = xa.c2p(t.poffset + di.p + t.barwidth, true); | ||
y1 = ya.c2p(di.s + di.b, true); | ||
y0 = ya.c2p(di.b, true); | ||
x0 = xa.c2p(p0, true); | ||
x1 = xa.c2p(p1, true); | ||
y0 = ya.c2p(s0, true); | ||
y1 = ya.c2p(s1, 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. very clean here. 🍻 |
||
} | ||
|
||
if(!isNumeric(x0) || !isNumeric(x1) || | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
To make the fact that these attributes are optional, we usually set the
dflt: null
(e.g. contour tracestart
,end
,size
).Note that,
null
are ignored uponLib.nestedProperty(/**/).set()
, so yourfullTrace.base === undefined
will still work.