本文整理汇总了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));
};