当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript d3-array.extent函数代码示例

本文整理汇总了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]
    }
}
开发者ID:OurWorldInData,项目名称:owid-grapher,代码行数:15,代码来源:Util.ts

示例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');
    }
开发者ID:TargetProcess,项目名称:tauCharts,代码行数:18,代码来源:size.ts

示例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);
开发者ID:itslenny,项目名称:DefinitelyTyped,代码行数:30,代码来源:d3-array-tests.ts

示例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() ----------------------------------------------------------------------
开发者ID:Kroisse,项目名称:DefinitelyTyped,代码行数:30,代码来源:d3-array-tests.ts

示例5: extent

const mergeContinuousDomains: MergeDomainsFn = (domain, items) => {
  const newDomain = extent([...domain, ...items]);
  return rangesEqual(newDomain as any, domain as any) ? domain : newDomain;
};
开发者ID:MaximKudriavtsev,项目名称:devextreme-reactive,代码行数:4,代码来源:computeds.ts

示例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) {
开发者ID:DmitryEfimenko,项目名称:DefinitelyTyped,代码行数:31,代码来源:d3-array-tests.ts


注:本文中的d3-array.extent函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。