I am currently working on integrating w2ui
multi select feature into a d3 chart project.
You can find a sample showcasing the issue in this jsfiddle link.
There are three functions that I have:
// Retrieve a column from an array
Array.prototype.getColumn = function(name) {
return this.map(function(el) {
// Obtain the specified 'column'
if (el.hasOwnProperty(name)) return el[name];
// Remove undefined values
}).filter(function(el) {
return typeof el != 'undefined';
});
};
// Check for duplicates in an array
Array.prototype.contains = function(v) {
for (var i = 0; i < this.length; i++) {
if (this[i] === v) return true;
}
return false;
};
Array.prototype.unique = function() {
var arr = [];
for (var i = 0; i < this.length; i++) {
if (!arr.contains(this[i])) {
arr.push(this[i]);
}
}
return arr;
}
I need to incorporate these functions into one of my methods.
The problem arises when I try to use these functions with Array.prototype
, as the multiselect items display as "undefined"
. The number of "undefined"
elements is directly related to the number of Array.prototype
functions.
If I remove these functions, the multi-select functionality works correctly (although not the entire chart). I'm struggling to identify the root cause of this error.
Any assistance on resolving this issue would be greatly appreciated. Thank you.