Any idea why only wrapper would return an array with the intended object? How might I fix this and whats the best way to create a name space like this one?
const bubble = {}
bubble.Name = {
mainDivId: "bubble",
svgId: "bubble-svg",
firstSvgG: "bubble-g-space",
nodeClass: "nodes",
}
bubble.Element = {
wrapper: d3.select('#' bubble.Name.mainDivId),
svgOuter: d3.select('#' bubble.Name.svgId),
svgInner: d3.select('#' bubble.Name.firstSvgG),
nodes: d3.selectAll('.' bubble.Name.nodeClass),
}
CodePudding user response:
const bubble = {}
bubble.Name = {
baseDivId: "bubble",
outerSvgId: "bubble-svg",
innerSvgId: "bubble-g-space",
nodeClass: "nodes",
}
bubble.Element = new function() {
this.wrapper = () => {
return d3.select('#' bubble.Name.baseDivId);
}
this.svgOuter = () => {
return d3.select('#' bubble.Name.outerSvgId);
}
this.svgInner = () => {
return d3.select('#' bubble.Name.innerSvgId);
}
this.nodes = () => {
return d3.select('#' bubble.Name.nodeClass);
}
}
