本文整理汇总了TypeScript中d3-array.extent函数的典型用法代码示例。如果您正苦于以下问题:TypeScript extent函数的具体用法?TypeScript extent怎么用?TypeScript extent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了extent函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: domainExtent
export function domainExtent(numValues: number[], scaleType: 'linear' | 'log'): [number, number] {
const filterValues = scaleType === 'log' ? numValues.filter(v => v > 0) : numValues
const [minValue, maxValue] = extent(filterValues)
if (minValue !== undefined && maxValue !== undefined && isFinite(minValue) && isFinite(maxValue)) {
if (minValue !== maxValue) {
return [minValue, maxValue]
} else {
// Only one value, make up a reasonable default
return scaleType === 'log' ? [minValue/10, minValue*10] : [minValue-1, maxValue+1]
}
} else {
return scaleType === 'log' ? [1, 100] : [-1, 1]
}
}
示例2: constructor
constructor(xSource: DataFrame, scaleConfig: ScaleConfig) {
super(xSource, scaleConfig);
var props = this.scaleConfig;
var vars = d3.extent(this.vars);
var min = Number.isFinite(props.min) ? props.min : vars[0];
var max = Number.isFinite(props.max) ? props.max : vars[1];
this.vars = [
Math.min(...[min, vars[0]].filter(Number.isFinite)),
Math.max(...[max, vars[1]].filter(Number.isFinite))
];
this.addField('scaleType', 'size');
this.addField('funcType', scaleConfig.func || 'sqrt');
}
示例3:
// with accessors
numOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToNum);
strOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToStr);
numericOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToNumeric);
dateOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToDate);
numOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToNumOrUndefined);
strOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToStrOrUndefined);
numOrUndefined = d3Array.min(readonlyMixedObjectOrUndefinedArray, accessorReadOnlyMixedObjectToNumOrUndefined);
// extent() --------------------------------------------------------------------
// without accessors
numOrUndefinedExtent = d3Array.extent(numbersArray);
strOrUndefinedExtent = d3Array.extent(stringyNumbersArray);
numericOrUndefinedExtent = d3Array.extent(numericArray);
dateOrUndefinedExtent = d3Array.extent(dateArray);
// ArrayLike test cases
numOrUndefinedExtent = d3Array.extent(typedArray);
numOrUndefinedExtent = d3Array.extent(readonlyNumbersOrUndefinedArray);
strOrUndefinedExtent = d3Array.extent(readonlyStringyNumbersArray);
numericOrUndefinedExtent = d3Array.extent(readonlyNumericArray);
dateOrUndefinedExtent = d3Array.extent(readonlyDateArray);
// with accessors
numOrUndefinedExtent = d3Array.extent(mixedObjectArray, accessorMixedObjectToNum);
示例4:
dateOrUndefined = d3Array.min(dateArray);
// with accessors
numOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToNum);
strOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToStr);
numericOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToNumeric);
dateOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToDate);
numOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToNumOrUndefined);
strOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToStrOrUndefined);
// extent() --------------------------------------------------------------------
// without accessors
numOrUndefinedExtent = d3Array.extent(numbersArray);
strOrUndefinedExtent = d3Array.extent(stringyNumbersArray);
numericOrUndefinedExtent = d3Array.extent(numericArray);
dateOrUndefinedExtent = d3Array.extent(dateArray);
// with accessors
numOrUndefinedExtent = d3Array.extent(mixedObjectArray, accessorMixedObjectToNum);
strOrUndefinedExtent = d3Array.extent(mixedObjectArray, accessorMixedObjectToStr);
mixedOrUndefinedExtent = d3Array.extent(mixedObjectArray, accessorMixedObjectToNumeric);
dateMixedOrUndefined = d3Array.extent(mixedObjectArray, accessorMixedObjectToDate);
numOrUndefinedExtent = d3Array.extent(mixedObjectArray, accessorMixedObjectToNumOrUndefined);
strOrUndefinedExtent = d3Array.extent(mixedObjectArray, accessorMixedObjectToStrOrUndefined);
// mean() ----------------------------------------------------------------------
示例5: extent
const mergeContinuousDomains: MergeDomainsFn = (domain, items) => {
const newDomain = extent([...domain, ...items]);
return rangesEqual(newDomain as any, domain as any) ? domain : newDomain;
};
示例6: function
let arr: Array<MixedObject> = array;
return datum.numeric;
});
date = d3Array.min(mixedObjectArray, function (datum, index, array) {
let d: MixedObject = datum;
let i: number = index;
let arr: Array<MixedObject> = array;
return datum.date;
});
// extent() --------------------------------------------------------------------
// without accessors
extentNum = d3Array.extent(numbersArray);
extentStr = d3Array.extent(stringyNumbersArray);
extentNumeric = d3Array.extent(numericArray);
extentDate = d3Array.extent(dateArray);
extentMixed = d3Array.extent<NumCoercible>([new NumCoercible(10), 13, '12', true]);
// with accessors
extentNum = d3Array.extent(mixedObjectArray, function (datum, index, array) {
let d: MixedObject = datum;
let i: number = index;
let arr: Array<MixedObject> = array;
return datum.num;
});
extentStr = d3Array.extent(mixedObjectArray, function (datum, index, array) {