-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Transform react #2577
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
Transform react #2577
Changes from 1 commit
bbe3533
ed24765
fcc459d
7044a13
88b7b43
cf4c9c3
e84d4b9
b436d52
2a41f9e
965bcfb
6fae229
79295f1
5e9aa65
690eb95
a244cec
92bd5d2
dc6de2f
03956e1
f439e41
e47e6a9
aa30ad6
4c70826
7279b55
3e250df
cd08479
0414147
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 |
---|---|---|
|
@@ -13,24 +13,16 @@ var Lib = require('../../lib'); | |
var BADNUM = require('../../constants/numerical').BADNUM; | ||
|
||
module.exports = function convertColumnData(trace, ax1, ax2, var1Name, var2Name, arrayVarNames) { | ||
var col1 = trace[var1Name].slice(), | ||
col2 = trace[var2Name].slice(), | ||
textCol = trace.text, | ||
colLen = Math.min(col1.length, col2.length), | ||
hasColumnText = (textCol !== undefined && !Array.isArray(textCol[0])), | ||
col1Calendar = trace[var1Name + 'calendar'], | ||
col2Calendar = trace[var2Name + 'calendar']; | ||
var colLen = trace._length; | ||
var col1 = trace[var1Name].slice(0, colLen); | ||
var col2 = trace[var2Name].slice(0, colLen); | ||
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. Oh so nice to |
||
var textCol = trace.text; | ||
var hasColumnText = (textCol !== undefined && Lib.is1D(textCol)); | ||
var col1Calendar = trace[var1Name + 'calendar']; | ||
var col2Calendar = trace[var2Name + 'calendar']; | ||
|
||
var i, j, arrayVar, newArray, arrayVarName; | ||
|
||
for(i = 0; i < arrayVarNames.length; i++) { | ||
arrayVar = trace[arrayVarNames[i]]; | ||
if(arrayVar) colLen = Math.min(colLen, arrayVar.length); | ||
} | ||
|
||
if(colLen < col1.length) col1 = col1.slice(0, colLen); | ||
if(colLen < col2.length) col2 = col2.slice(0, colLen); | ||
|
||
for(i = 0; i < colLen; i++) { | ||
col1[i] = ax1.d2c(col1[i], 0, col1Calendar); | ||
col2[i] = ax2.d2c(col2[i], 0, col2Calendar); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,9 @@ module.exports = function handleXYZDefaults(traceIn, traceOut, coerce, layout, x | |
y = coerce(yName); | ||
|
||
// column z must be accompanied by xName and yName arrays | ||
if(!x || !y) return 0; | ||
if(!(x && x.length && y && y.length)) return 0; | ||
|
||
traceOut._length = Math.min(x.length, y.length, z.length); | ||
} | ||
else { | ||
x = coordDefaults(xName, coerce); | ||
|
@@ -37,12 +39,14 @@ module.exports = function handleXYZDefaults(traceIn, traceOut, coerce, layout, x | |
if(!isValidZ(z)) return 0; | ||
|
||
coerce('transpose'); | ||
|
||
traceOut._length = null; | ||
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. What if instead of 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 could imagine that being helpful but it sounds like a bit of a project in itself - not quite sure how it would mesh with the logic you linked for example, which may be at least partially after reshaping from columns to a grid. Anyway we can add that later, so I'd like to defer it for now. 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.
Sounds good. |
||
} | ||
|
||
var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults'); | ||
handleCalendarDefaults(traceIn, traceOut, [xName, yName], layout); | ||
|
||
return traceOut.z.length; | ||
return true; | ||
}; | ||
|
||
function coordDefaults(coordStr, coerce) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,8 +22,10 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout | |
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt); | ||
} | ||
|
||
var x = coerce('x'), | ||
y = coerce('y'); | ||
var x = coerce('x'); | ||
var y = coerce('y'); | ||
var hasX = x && x.length; | ||
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 suspect 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.
Ah hmm, before I do that, I want to check this against our previous behavior for trace types that don't necessarily need both coordinates specified - like scatter, which can use 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. When I looked at empty-array behavior in more detail 6fae229 some of these went away. So I've not created |
||
var hasY = y && y.length; | ||
|
||
var cumulative = coerce('cumulative.enabled'); | ||
if(cumulative) { | ||
|
@@ -33,22 +35,27 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout | |
|
||
coerce('text'); | ||
|
||
var orientation = coerce('orientation', (y && !x) ? 'h' : 'v'), | ||
sample = traceOut[orientation === 'v' ? 'x' : 'y']; | ||
var orientation = coerce('orientation', (hasY && !hasX) ? 'h' : 'v'); | ||
var sampleLetter = orientation === 'v' ? 'x' : 'y'; | ||
var aggLetter = orientation === 'v' ? 'y' : 'x'; | ||
var sample = traceOut[sampleLetter]; | ||
|
||
if(!(sample && sample.length)) { | ||
var len = (hasX && hasY) ? Math.min(x.length && y.length) : (sample || []).length; | ||
|
||
if(!len) { | ||
traceOut.visible = false; | ||
return; | ||
} | ||
|
||
traceOut._length = len; | ||
|
||
var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults'); | ||
handleCalendarDefaults(traceIn, traceOut, ['x', 'y'], layout); | ||
|
||
var hasAggregationData = traceOut[orientation === 'h' ? 'x' : 'y']; | ||
var hasAggregationData = traceOut[aggLetter]; | ||
if(hasAggregationData) coerce('histfunc'); | ||
|
||
var binDirections = (orientation === 'h') ? ['y'] : ['x']; | ||
handleBinDefaults(traceIn, traceOut, coerce, binDirections); | ||
handleBinDefaults(traceIn, traceOut, coerce, [sampleLetter]); | ||
|
||
handleStyleDefaults(traceIn, traceOut, coerce, defaultColor, layout); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,4 +86,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout | |
} | ||
|
||
coerce('text'); | ||
|
||
// disable 1D transforms | ||
traceOut._length = null; | ||
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. Actually, 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. Ah nevermind, i/j/k and x/y/z lengths don't match for |
||
}; |
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.
This could be
hasX
.