本文整理匯總了TypeScript中d3-interpolate.interpolateString函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript interpolateString函數的具體用法?TypeScript interpolateString怎麽用?TypeScript interpolateString使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了interpolateString函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
enterTransition = enterTransition.attrTween('r', function (d, i, g) {
let that: SVGCircleElement = this;
// let that2: HTMLElement = this; // fails, type mismatch
let datum: CircleDatum = d;
let index: number = i;
let group: SVGCircleElement[] | ArrayLike<SVGCircleElement> = g;
console.log(this.r.baseVal.value); // this type is SVGCircleElement
return interpolateString(0, d.r); // datum type is CircleDatum
});
示例2: NumCoercible
// 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
arrNum = iArrayNum(0.5);
iArrayNum = d3Interpolate.interpolateArray<[number, number]>(['1', '2'], [4, 8]); // explicit typing
arrNum = iArrayNum(0.5);
iArrayStr = d3Interpolate.interpolateArray<Array<string>>(['1', '2'], ['4', '8']); // explicit typing
示例3: function
enterTransition = enterTransition.attrTween('r', function (d, i, group) {
console.log(this.r.baseVal.value); // this type is SVGCircleElement
return interpolateString(0, d.r); // datum type is CircleDatum
});