本文整理汇总了TypeScript中d3-interpolate.interpolateRound函数的典型用法代码示例。如果您正苦于以下问题:TypeScript interpolateRound函数的具体用法?TypeScript interpolateRound怎么用?TypeScript interpolateRound使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了interpolateRound函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: interpolator
.attrTween('y', (d, i, a) => {
const interpolator = d3Interpolate.interpolateRound(d.data.currentScaledY, HierarchyNodeUtils.getDestinationScaledY(d))
return t => {
d.data.currentScaledY = interpolator(t)
return `${d.data.currentScaledY}`
}
})
示例2: return
.attrTween('y', (d : ProofTreeTypes.Node) : (t : number) => string => {
const destinationScaledY = HierarchyNodeUtils.getHierarchyGoalAncestor(d).caseOf({
nothing : () => HierarchyNodeUtils.getDestinationScaledY(d),
just : (gp : ProofTreeTypes.Node) => HierarchyNodeUtils.getDestinationScaledY(gp),
})
const interpolator = d3Interpolate.interpolateRound(d.data.currentScaledY, destinationScaledY)
return (t : number) => {
d.data.currentScaledY = interpolator(t)
return `${d.data.currentScaledX}`
}
})
示例3: NumCoercible
// Key Value
iKeyVal = d3Interpolate.interpolate({ x: 0, y: 1 }, { x: 1, y: 10, z: 100 });
d3Interpolate.interpolate<NumCoercible>(new NumCoercible(1), new NumCoercible(5));
d3Interpolate.interpolate<NumCoercible>({ a: 1 }, new NumCoercible(5));
// test interpolateNumber(a, b) signature ----------------------------------------------------
iNum = d3Interpolate.interpolateNumber(0, 100);
iNum = d3Interpolate.interpolateNumber(new NumCoercible(0), new NumCoercible(100));
num = iNum(0.5);
// test interpolateNumber(a, b) signature ----------------------------------------------------
iNum = d3Interpolate.interpolateRound(0, 100);
iNum = d3Interpolate.interpolateRound(new NumCoercible(0), new NumCoercible(100));
num = iNum(0.5);
// test interpolateString(a, b) signature ----------------------------------------------------
iString = d3Interpolate.interpolateString('-1', '2');
str = iString(0.5);
// test interpolateDate(a, b) signature ----------------------------------------------------
iDate = d3Interpolate.interpolateDate(new Date(2016, 6, 1), new Date(2016, 6, 31));
// test interpolateArray(a, b) signature ----------------------------------------------------
iArrayNum = d3Interpolate.interpolateArray<Array<number>>([1, 2], [4, 8]); // explicit typing
示例4: divergingScaleNumber
const copiedSequentialScale: d3Scale.ScaleSequential<string> = sequentialScaleColorString.copy();
// -------------------------------------------------------------------------------
// Diverging Scale Factory
// -------------------------------------------------------------------------------
// scaleQuantize() -----------------------------------------------------------------
const interpolateDouble = (t: number) => t * 2;
let divergingScaleNumber: d3Scale.ScaleDiverging<number>;
let divergingScaleString: d3Scale.ScaleDiverging<string>;
// $ExpectError
d3Scale.scaleDiverging(); // fails, Expected 1 arguments, but got 0.
divergingScaleNumber = d3Scale.scaleDiverging<number>(interpolateRound(0, 1));
divergingScaleNumber = d3Scale.scaleDiverging<number>(interpolateDouble);
divergingScaleString = d3Scale.scaleDiverging<string>(interpolateSpectral);
// ScaleDiverging Interface =======================================================
// (...) value mapping from domain to output -----------------------------------
outputNumber = divergingScaleNumber(1);
outputString = divergingScaleString(1);
// domain(...) -----------------------------------------------------------------
let domainDivergingScale: [number, number, number];
divergingScaleNumber = divergingScaleNumber.domain([0, 0.5, 1]);
示例5: NumCoercible
iKeyVal = d3Interpolate.interpolate({ x: 0, y: 1 }, { x: 1, y: 10, z: 100 });
iXyz = d3Interpolate.interpolate({ x: 0, y: 1 }, { x: 1, y: 10, z: 100 });
iXyz = d3Interpolate.interpolate<Xyz>({ x: 0, y: 1 }, { x: 1, y: 10, z: 100 });
d3Interpolate.interpolate<NumCoercible>(new NumCoercible(1), new NumCoercible(5));
d3Interpolate.interpolate<NumCoercible>({ a: 1 }, new NumCoercible(5));
// test interpolateNumber(a, b) signature ----------------------------------------------
iNum = d3Interpolate.interpolateNumber(0, 100);
iNum = d3Interpolate.interpolateNumber(new NumCoercible(0), new NumCoercible(100));
num = iNum(0.5);
// test interpolateNumber(a, b) signature ----------------------------------------------
iNum = d3Interpolate.interpolateRound(0, 100);
iNum = d3Interpolate.interpolateRound(new NumCoercible(0), new NumCoercible(100));
num = iNum(0.5);
// test interpolateString(a, b) signature ----------------------------------------------
iString = d3Interpolate.interpolateString('-1', '2');
str = iString(0.5);
// test interpolateDate(a, b) signature ------------------------------------------------
iDate = d3Interpolate.interpolateDate(new Date(2016, 6, 1), new Date(2016, 6, 31));
// test interpolateArray(a, b) signature -----------------------------------------------
iArrayNum = d3Interpolate.interpolateArray<number[]>([1, 2], [4, 8]); // explicit typing