Skip to content

Commit b831cbc

Browse files
committed
misc. fixups for appendArrayPointValue
1 parent 1c2e71e commit b831cbc

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

src/components/fx/helpers.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,26 @@ function quadrature(dx, dy) {
8787

8888
/** Appends values inside array attributes corresponding to given point number
8989
*
90-
* @param {object} pointData : point data object (gets mutated here
90+
* @param {object} pointData : point data object (gets mutated here)
9191
* @param {object} trace : full trace object
92-
* @param {number} ptNumber : point number
92+
* @param {number} pointNumber : point number
9393
*/
94-
exports.appendArrayPointValue = function(pointData, trace, ptNumber) {
94+
exports.appendArrayPointValue = function(pointData, trace, pointNumber) {
9595
var arrayAttrs = trace._arrayAttrs;
9696

9797
for(var i = 0; i < arrayAttrs.length; i++) {
9898
var astr = arrayAttrs[i];
9999
var key;
100100

101101
if(astr === 'ids') key = 'id';
102-
else if(astr === 'location') key = 'location';
102+
else if(astr === 'locations') key = 'location';
103103
else key = astr;
104104

105105
if(pointData[key] === undefined) {
106-
pointData[key] = Lib.nestedProperty(trace, astr).get()[ptNumber];
106+
var val = Lib.nestedProperty(trace, astr).get();
107+
pointData[key] = Array.isArray(pointNumber) ?
108+
val[pointNumber[0]][pointNumber[1]] :
109+
val[pointNumber];
107110
}
108111
}
109112
};

src/components/fx/hover.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -447,19 +447,17 @@ function _hover(gd, evt, subplot) {
447447
pointNumber: pt.index
448448
};
449449

450-
// could maybe :hocho: _module.eventData
451450
if(pt.trace._module.eventData) out = pt.trace._module.eventData(out, pt);
452451
else {
453452
out.x = pt.xVal;
454453
out.y = pt.yVal;
455-
456454
out.xaxis = pt.xa;
457455
out.yaxis = pt.ya;
458456

459457
if(pt.zLabelVal !== undefined) out.z = pt.zLabelVal;
460458
}
461459

462-
helpers.appendArrayPointValue(out, trace, pt.index);
460+
helpers.appendArrayPointValue(out, pt.trace, pt.index);
463461
newhoverdata.push(out);
464462
}
465463

src/plot_api/plot_schema.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ exports.findArrayAttributes = function(trace) {
157157
}
158158

159159
exports.crawl(baseAttributes, callback);
160-
exports.crawl(trace._module.attributes, callback);
160+
if(trace._module && trace._module.attributes) {
161+
exports.crawl(trace._module.attributes, callback);
162+
}
161163

162164
if(trace.transforms) {
163165
var transforms = trace.transforms;
@@ -177,9 +179,8 @@ exports.findArrayAttributes = function(trace) {
177179
// At the moment, we need this block to make sure that
178180
// ohlc and candlestick 'open', 'high', 'low', 'close' can be
179181
// used with filter ang groupby transforms.
180-
if(trace._fullInput) {
182+
if(trace._fullInput && trace._fullInput._module && trace._fullInput._module.attributes) {
181183
exports.crawl(trace._fullInput._module.attributes, callback);
182-
183184
arrayAttributes = Lib.filterUnique(arrayAttributes);
184185
}
185186

src/plots/gl3d/scene.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function render(scene) {
112112
pointNumber: ptNumber
113113
};
114114

115-
Fx.appendArrayPointValue(pointData);
115+
Fx.appendArrayPointValue(pointData, trace, ptNumber);
116116

117117
var eventData = {points: [pointData]};
118118

0 commit comments

Comments
 (0)