Skip to content

Commit 523f61b

Browse files
committed
PR feedback: disuse in favor of Lib.nestedProperty getter/setter
1 parent aa70e4c commit 523f61b

File tree

2 files changed

+10
-28
lines changed

2 files changed

+10
-28
lines changed

src/plots/plots.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,9 @@ function applyTransforms(fullTrace, fullData, layout) {
816816

817817
Lib.crawl(trace._module.attributes, callback);
818818

819-
return arraySplitAttributes;
819+
return arraySplitAttributes.map(function(path) {
820+
return path.join('.');
821+
});
820822
});
821823

822824
for(var i = 0; i < container.length; i++) {

src/transforms/groupby.js

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -98,36 +98,16 @@ exports.transform = function(data, state) {
9898
return newData;
9999
};
100100

101-
function getDeepProp(thing, propArray) {
102-
var result = thing;
103-
var i;
104-
for(i = 0; i < propArray.length; i++) {
105-
result = result[propArray[i]];
106-
if(result === void(0)) {
107-
return result;
108-
}
109-
}
110-
return result;
111-
}
112-
113-
function setDeepProp(thing, propArray, value) {
114-
var current = thing;
115-
var i;
116-
for(i = 0; i < propArray.length - 1; i++) {
117-
if(current[propArray[i]] === void(0)) {
118-
current[propArray[i]] = {};
119-
}
120-
current = current[propArray[i]];
121-
}
122-
current[propArray[propArray.length - 1]] = value;
123-
}
124-
125101
function initializeArray(newTrace, a) {
126-
setDeepProp(newTrace, a, []);
102+
Lib.nestedProperty(newTrace, a).set([]);
127103
}
128104

129105
function pasteArray(newTrace, trace, j, a) {
130-
getDeepProp(newTrace, a).push(getDeepProp(trace, a)[j]);
106+
Lib.nestedProperty(newTrace, a).set(
107+
Lib.nestedProperty(newTrace, a).get().concat([
108+
Lib.nestedProperty(trace, a).get()[j]
109+
])
110+
);
131111
}
132112

133113
function transformOne(trace, state, attributeSet) {
@@ -149,7 +129,7 @@ function transformOne(trace, state, attributeSet) {
149129
var style = opts.style || {};
150130

151131
var arrayAttributes = attributeSet
152-
.filter(function(array) {return Array.isArray(getDeepProp(trace, array));});
132+
.filter(function(array) {return Array.isArray(Lib.nestedProperty(trace, array).get());});
153133

154134
// fixme the O(n**3) complexity
155135
for(var i = 0; i < groupNames.length; i++) {

0 commit comments

Comments
 (0)