本文整理匯總了TypeScript中d3.set函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript set函數的具體用法?TypeScript set怎麽用?TypeScript set使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了set函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
return function(tags: string[]): Category[] {
let remaining: d3.Set = d3.set(tags);
let userSpecified = rules.map((def: CategoryDefinition) => {
let tags: string[] = [];
remaining.each((t: string) => {
if (def.matches(t)) {
tags.push(t);
}
});
let cat = {name: def.name, tags: tags.sort(compareTagNames)};
return cat;
});
let defaultCategories = fallback(remaining.values());
return userSpecified.concat(defaultCategories);
};
示例2: function
scale.ticks = function(m) {
var [domainStart, domainEnd] = backingLinearScale.domain();
var start = Math.max(Math.ceil(domainStart), 0);
var end = Math.min(Math.floor(domainEnd), index.length - 1);
// console.log(index.length, domainStart, domainEnd, start, end)
var newM = ((end - start) / (domainEnd - domainStart)) * m;
// newM = newM <= 0 ? m : newM;
var target = Math.round((end - start + 1) * interval / newM);
// var subList = index.slice(start, end + 1);
var levelIndex = tickLevelBisector(tickLevels, target);
// console.log(target, levelIndex)
var { level } = tickLevels[levelIndex];
// console.log(target, level);
var backingTicks = backingLinearScale.ticks(m);
var distance = backingTicks.length > 0
? (last(backingTicks) - head(backingTicks)) / (backingTicks.length - 1) / 4
: 1;
var ticks = []
for (var i = start; i < end + 1; i++) {
if (index[i].level >= level) ticks.push(index[i].index);
};
// subList.filter(each => each.level >= level).map(d => d.index);
var ticksSet = d3.set(ticks);
for (var i = 0; i < ticks.length - 1; i++) {
for (var j = i + 1; j < ticks.length; j++) {
if (ticks[j] - ticks[i] < distance) {
ticksSet.remove(index[ticks[i]].level >= index[ticks[j]].level ? ticks[j] : ticks[i])
}
}
}
return ticksSet.values().map(d => parseInt(d, 10));
};