Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_getUnique(dataId, attr) {
let uniq;
const items = this._collection[dataId].data;
// if it's an array, it will return a list of unique combinations.
if (utils.isArray(attr)) {
const values = items.map(d => utils.clone(d, attr)); // pick attrs
uniq = utils.unique(values, n => JSON.stringify(n));
} // if it's a string, it will return a list of values
else {
const values = items.map(d => d[attr]);
uniq = utils.unique(values);
}
return uniq;
}
// remove queueItem from queue as it's merged in the current query
return false;
}
}
// otherwise keep it in the queue, so it can be joined with another query
return true;
});
if (!willExecute) return;
// make the promise a collection of all promises of merged queries
// promise = promises.length ? Promise.all(promises) : new Promise.resolve();
// remove double columns from select (resulting from merging)
// no double columns in formatter because it's an object, extend would've overwritten doubles
query.select.value = utils.unique(query.select.value);
// Create a new reader for this query
var readerClass = Reader.get(reader_name);
if (!readerClass) {
throw new Error('Unknown reader: ' + reader_name);
}
var r = new readerClass(reader);
// execute the query with this reader
r.read(query).then(function() {
//success reading
var values = r.getData();
var q = query;
if(values.length == 0) utils.warn("Reader returned empty array for query:", JSON.stringify(q, null, 2))
if(a.sortValue[1] === b.sortValue[1]) {
return d3.descending(a.sortValue[0], b.sortValue[0]);
}
return d3.descending(a.sortValue[1], b.sortValue[1]);
} else {
if (a.aggrLevel != b.aggrLevel) {
return d3.descending(a.aggrLevel, b.aggrLevel);
} else if (a.aggrLevel && b.aggrLevel) {
return d3.descending(a.yMax, b.yMax);
} else {
return 0;
}
}
});
_this.selectList = _this.mountainLabelContainer.selectAll("g.vzb-mc-label")
.data(utils.unique(listData, function (d) {
return d.KEY()
}));
_this.selectList.exit().remove();
_this.selectList = _this.selectList.enter().append("g")
.attr("class", "vzb-mc-label")
.each(function (d, i) {
var label = d3.select(this);
label.append("circle").attr('class', 'vzb-mc-label-legend');
label.append("text").attr("class", "vzb-mc-label-shadow vzb-mc-label-text");
label.append("text").attr("class", "vzb-mc-label-text");
label.append("g").attr("class", "vzb-mc-label-x vzb-label-shadow vzb-invisible")
.on("click", function (d, i) {
if (utils.isTouchDevice()) return;
d3.event.stopPropagation();
_this.model.marker.clearHighlighted();
_this.model.marker.selectMarker(d);
if (a.aggrLevel != b.aggrLevel) {
return d3.descending(a.aggrLevel, b.aggrLevel);
} else if (a.aggrLevel && b.aggrLevel) {
return d3.descending(a.yMax, b.yMax);
} else {
return 0;
}
}
});
*/
var listData = _this.pointers
.filter(function (f) {
return _this.model.marker.isselected(f);
});
_this.selectList = _this.labelListContainer.selectAll("g.vzb-bmc-label")
.data(utils.unique(listData, function (d) {
return d.KEY();
}));
_this.selectList.exit().remove();
_this.selectList = _this.selectList.enter().append("g")
.attr("class", "vzb-bmc-label")
.each(function (d, i) {
var label = d3.select(this);
label.append("circle").attr('class', 'vzb-bmc-label-legend');
label.append("text").attr("class", "vzb-bmc-label-shadow vzb-bmc-label-text");
label.append("text").attr("class", "vzb-bmc-label-text");
label.append("g").attr("class", "vzb-bmc-label-x vzb-label-shadow vzb-invisible")
.on("click", function (d, i) {
if (utils.isTouchDevice()) return;
d3.event.stopPropagation();
_this.model.entities.clearHighlighted();
_this.model.marker.selectMarker(d);
listenFramesQueue(keys, cb) {
const _this = this;
const KEYS = utils.unique(this._getAllDimensions({ exceptType: "time" }));
const TIME = this._getFirstDimension({ type: "time" });
const steps = this._parent.time.getAllSteps();
const preparedFrames = {};
this.getFrames();
const dataIds = [];
const stepsCount = steps.length;
let isDataLoaded = false;
utils.forEach(_this._dataCube, (hook, name) => {
if (!(hook.use === "constant" || KEYS.includes(hook.which) || hook.which === TIME)) {
if (!dataIds.includes(hook._dataId)) {
dataIds.push(hook._dataId);
hook.dataSource.listenFrame(hook._dataId, steps, keys, (dataId, time) => {
const keyName = time.toString();
ready() {
const _this = this;
this.KEYS = utils.unique(this.model.marker._getAllDimensions({ exceptType: "time" }));
this.KEY = this.KEYS.join(",");
this.colorlegendDim = this.KEY;
this.canShowMap = false;
if (this.colorModel.isDiscrete() && this.colorModel.use !== "constant" && this.colorlegendMarker) {
if (!this.colorlegendMarker._ready) return;
this.markerKeys = _this.model.marker.getKeys();
this.KEY = _this.colorModel.getDataKeys()[0];
this.colorlegendDim = this.colorModel.getColorlegendEntities().getDimension();
this.colorlegendMarker.getFrame(this.model.time.value, frame => {
if (!frame) return utils.warn("colorlegend received empty frame in ready()");
_this.frame = frame;
_this.canShowMap = utils.keys((_this.frame || {}).hook_geoshape || {}).length;
readyOnce() {
this._super();
this.KEYS = utils.unique(this.model.state.marker._getAllDimensions({ exceptType: "time" }));
this.resetFilter = {};
const spaceModels = this.model.state.marker._space;
this.KEYS.forEach(key => {
this.resetFilter[key] = utils.find(spaceModels, model => model.dim === key).show;
});
this.parentElement = d3.select(this.parent.element);
this.contentEl = this.element = d3.select(this.element.parentNode);
this.list = this.element.select(".vzb-show-list");
this.input_search = this.parentElement.select(".vzb-find-search");
this.deselect_all = this.parentElement.select(".vzb-show-deselect");
this.apply = this.parentElement.select(".vzb-show-apply");
const _this = this;
var result = [];
var expectedEntities = this.getEntitySetsByQuery(query);
if (typeof expectedEntities === 'string') {
return expectedEntities;
}
if(index) {
index.forEach(function (indexRecord) {
if (expectedEntities.indexOf(indexRecord.key) >= 0) {
result.push(_this.ddfPath + indexRecord.file);
}
});
}
return utils.unique(result);
};
hooksPerKey.forEach((hooks, keyIndex) => {
let keys = [];
hooks.forEach(hook => {
const hookKeys = hook.getDataKeys();
const hookKeyIndex = hookKeys.indexOf(KEYS[keyIndex]);
keys = keys.concat(Object.keys(hook.getNestedItems(hookKeys.concat(TIME))).map(key => [JSON.parse(key)[hookKeyIndex]]));
});
keys = utils.unique(keys);
resultKeys = resultKeys ? d3.cross(resultKeys, keys, (a, b) => a.concat(b)) : keys;
});
this.getPromise = function(query, parsers) {
for (const reader of this.queries) {
if (query.select.value.filter(x => reader.query.select.value.indexOf(x) == -1).length == 0 &&
_parsersCompare(reader.parsers, parsers)) { //check if this query have all needed values
return reader.defer.promise;
}
}
if (!this.query) {
this.query = query;
this.parsers = parsers;
} else {
this.query.select.value = (this.query.select.value) ? utils.unique(this.query.select.value.concat(query.select.value)) : [];
utils.extend(this.parsers, parsers);
}
utils.debounce(() => {
this.runQuery();
}, 10)();
if (!this.defer.promise || !(this.defer.promise instanceof Promise)) {
this.defer.promise = new Promise((resolve, reject) => {
this.defer.resolve = resolve;
this.defer.reject = reject;
});
}
return this.defer.promise;
};
this.runQuery = function() {