-
-
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
Multi-axis-type sploms #2899
Multi-axis-type sploms #2899
Changes from 3 commits
dd563bb
9e1869d
9da5a1b
f3c73db
b3d27bd
9039a8e
ab7d9c6
39b71bb
57ddadb
15efc72
1823904
390f292
adb0004
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 |
---|---|---|
|
@@ -36,19 +36,39 @@ function calc(gd, trace) { | |
// only differ here for log axes, pass ldata to createMatrix as 'data' | ||
var cdata = opts.cdata = []; | ||
var ldata = opts.data = []; | ||
var i, k, dim; | ||
var i, k, dim, xa, ya; | ||
|
||
function makeCalcdata(ax, dim) { | ||
// call makeCalcdata with fake input | ||
var ccol = ax.makeCalcdata({ | ||
v: dim.values, | ||
vcalendar: trace.calendar | ||
}, 'v'); | ||
|
||
for(var i = 0; i < ccol.length; i++) { | ||
ccol[i] = ccol[i] === BADNUM ? NaN : ccol[i]; | ||
} | ||
cdata.push(ccol); | ||
ldata.push(ax.type === 'log' ? Lib.simpleMap(ccol, ax.c2l) : ccol); | ||
} | ||
|
||
for(i = 0; i < dimensions.length; i++) { | ||
dim = dimensions[i]; | ||
|
||
if(dim.visible) { | ||
var axId = trace._diag[i][0] || trace._diag[i][1]; | ||
var ax = AxisIDs.getFromId(gd, axId); | ||
if(ax) { | ||
var ccol = makeCalcdata(ax, trace, dim); | ||
var lcol = ax.type === 'log' ? Lib.simpleMap(ccol, ax.c2l) : ccol; | ||
cdata.push(ccol); | ||
ldata.push(lcol); | ||
xa = AxisIDs.getFromId(gd, trace._diag[i][0]); | ||
ya = AxisIDs.getFromId(gd, trace._diag[i][1]); | ||
|
||
if(xa) { | ||
makeCalcdata(xa, dim); | ||
if(ya && ya.type === 'category') { | ||
ya._categories = xa._categories.slice(); | ||
} | ||
} else if(ya) { | ||
makeCalcdata(ya, dim); | ||
if(xa && xa.type === 'category') { | ||
xa._categories = ya._categories.slice(); | ||
} | ||
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. How could you get here? if But this raises an interesting (if possibly nonsensical) point - what if 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 point. I wrote that up to preserve symmetry, but didn't bother checking. Thanks!
I don't think this can happen on graphs with only 1 splom trace and no Scenarios where
which are things that don't happen by accident. So, I yeah I think skipping that dimension entirely makes the most sense here. Thanks for bringing this up! 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.
Hmm could happen in the editor though. @nicolaskruchten @VeraZab not sure how best to handle this. If we add 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. hoo boy. Well right now we don't support SPLOMs yet, and I'm thinking that when we do we should lock down axes/subplots quite tightly so that people can't break them too much :) 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. Skipping dims with axes of conflicting types in b3d27bd |
||
} | ||
} | ||
} | ||
|
@@ -63,8 +83,8 @@ function calc(gd, trace) { | |
dim = dimensions[i]; | ||
|
||
if(dim.visible) { | ||
var xa = AxisIDs.getFromId(gd, trace._diag[i][0]) || {}; | ||
var ya = AxisIDs.getFromId(gd, trace._diag[i][1]) || {}; | ||
xa = AxisIDs.getFromId(gd, trace._diag[i][0]) || {}; | ||
ya = AxisIDs.getFromId(gd, trace._diag[i][1]) || {}; | ||
|
||
// Reuse SVG scatter axis expansion routine. | ||
// For graphs with very large number of points and array marker.size, | ||
|
@@ -91,20 +111,6 @@ function calc(gd, trace) { | |
return [{x: false, y: false, t: stash, trace: trace}]; | ||
} | ||
|
||
function makeCalcdata(ax, trace, dim) { | ||
// call makeCalcdata with fake input | ||
var ccol = ax.makeCalcdata({ | ||
v: dim.values, | ||
vcalendar: trace.calendar | ||
}, 'v'); | ||
|
||
for(var i = 0; i < ccol.length; i++) { | ||
ccol[i] = ccol[i] === BADNUM ? NaN : ccol[i]; | ||
} | ||
|
||
return ccol; | ||
} | ||
|
||
function sceneUpdate(gd, stash) { | ||
var scene = stash._scene; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"data": [ | ||
{ | ||
"type": "splom", | ||
"opacity": 0.9, | ||
"showupperhalf": false, | ||
"diagonal": {"visible": false }, | ||
"dimensions": [ | ||
{ | ||
"label": "numeric", | ||
"values": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | ||
}, | ||
{ | ||
"label": "decimal", | ||
"values": [-3.3, 2.2, -1.1, 0, 1.1, -2.2, 3.3, 4.4, -5, 6] | ||
}, | ||
{ | ||
"label": "bool", | ||
"values": [false, true, true, true, false, true, false, false, false, true] | ||
}, | ||
{ | ||
"label": "0/1", | ||
"values": [0, 1, 1, 1, 1, 1, 0, 0, 0, 0] | ||
}, | ||
{ | ||
"label": "string", | ||
"values": ["lyndon", "richard", "gerald", "jimmy", "ronald", "george", "bill", "georgeW", "barack", "donald"] | ||
} | ||
] | ||
} | ||
], | ||
"layout": { | ||
"hovermode": "closest", | ||
"margin": { | ||
"b": 80, | ||
"l": 80, | ||
"r": 30, | ||
"t": 30 | ||
}, | ||
"yaxis2": {"type": "category"}, | ||
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 here might be tricky to find for users as e.g. nothing indicates that Perhaps we could include this in the 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.
That's a great idea - 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 went with I'm thinking the extra container might make it cleaner if we add more "splom-generated-axis" settings e.g. I suspect some users would want to set 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. haha exactly my rationale in #2899 (comment) - I should read all your comments before making my own. Anyway, love it. |
||
"yaxis3": {"type": "category"}, | ||
"xaxis3": {"type": "category"}, | ||
"xaxis4": {"type": "category"} | ||
} | ||
} |
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.
Recall that
_diag
is:plotly.js/src/traces/splom/defaults.js
Lines 104 to 124 in def6aa5
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.
ah ok - a little confusing as usually
xa
is a full axis object, an id would bexId
or something... but anyway nice fix!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.
cleaned up in -> f3c73db