當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript d3-array.max函數代碼示例

本文整理匯總了TypeScript中d3-array.max函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript max函數的具體用法?TypeScript max怎麽用?TypeScript max使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了max函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: d3Mean

 const ComponentUsages: GetTargetClusterUsageEx.ComponentUsage[] = tcu.ComponentUsages.ComponentUsage.map(cu => {
     const MachineUsages = cu.MachineUsages.MachineUsage.map(mu => {
         const DiskUsages: GetTargetClusterUsageEx.DiskUsage[] = mu.DiskUsages && mu.DiskUsages.DiskUsage ? mu.DiskUsages.DiskUsage.map(du => {
             return {
                 ...du,
                 Total: du.InUse + du.Available,
                 PercentUsed: 100 - du.PercentAvailable
             };
         }) : [];
         return {
             Name: mu.Name,
             NetAddress: mu.NetAddress,
             Description: mu.Description,
             DiskUsages,
             mean: d3Mean(DiskUsages, du => du.PercentUsed),
             max: d3Max(DiskUsages, du => du.PercentUsed)
         };
     });
     return {
         Type: cu.Type,
         Name: cu.Name,
         Description: cu.Description,
         MachineUsages,
         MachineUsagesDescription: MachineUsages.reduce((prev, mu) => prev + (mu.Description || ""), ""),
         mean: d3Mean(MachineUsages, mu => mu.mean),
         max: d3Max(MachineUsages, mu => mu.max)
     };
 });
開發者ID:GordonSmith,項目名稱:Visualization,代碼行數:28,代碼來源:wsMachine.ts

示例2: accessorReadOnlyMixedObjectToNumOrUndefined

    return datum ? datum.str : undefined;
}

function accessorReadOnlyMixedObjectToNumOrUndefined(datum: MixedObject | undefined, index: number, array: ArrayLike<MixedObject | undefined>): number | undefined | null {
    return datum ? datum.num : undefined;
}

// -----------------------------------------------------------------------------
// Test Statistics
// -----------------------------------------------------------------------------

// max() -----------------------------------------------------------------------

// without accessors

numOrUndefined = d3Array.max(numbersArray);
strOrUndefined = d3Array.max(stringyNumbersArray);
numericOrUndefined = d3Array.max(numericArray);
dateOrUndefined = d3Array.max(dateArray);

// ArrayLike test cases

numOrUndefined = d3Array.max(typedArray);
numOrUndefined = d3Array.max(readonlyNumbersOrUndefinedArray);
strOrUndefined = d3Array.max(readonlyStringyNumbersArray);
numericOrUndefined = d3Array.max(readonlyNumericArray);
dateOrUndefined = d3Array.max(readonlyDateArray);

// with accessors

numOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToNum);
開發者ID:itslenny,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:d3-array-tests.ts

示例3: accessorMixedObjectToStrOrUndefined

    return datum ? datum.num : undefined;
}

function accessorMixedObjectToStrOrUndefined(datum: MixedObject | undefined, index: number, array: MixedObject[]): string | undefined | null {
    return datum ? datum.str : undefined;
}

// -----------------------------------------------------------------------------
// Test Statistics
// -----------------------------------------------------------------------------

// max() -----------------------------------------------------------------------

// without accessors

numOrUndefined = d3Array.max(numbersArray);
strOrUndefined = d3Array.max(stringyNumbersArray);
numericOrUndefined = d3Array.max(numericArray);
dateOrUndefined = d3Array.max(dateArray);

// with accessors

numOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToNum);
strOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToStr);
numericOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToNumeric);
dateOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToDate);
numOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToNumOrUndefined);
strOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToStrOrUndefined);

// min() -----------------------------------------------------------------------
開發者ID:Kroisse,項目名稱:DefinitelyTyped,代碼行數:30,代碼來源:d3-array-tests.ts

示例4: update

    public update(data: any[]) {
        let propertyX = this.config.get('propertyX'),
            propertyY = this.config.get('propertyY'),
            propertyZ = this.config.get('propertyZ'),
            colorScale = this.config.get('colorScale'),
            xStep: number = this.config.get('xStep'),
            yStep: number = this.config.get('yStep'),
            yAxisType = this.config.get('yAxisType'),
            xAxisType = this.config.get('xAxisType'),
            x = this.x.xAxis.scale(),
            y = this.y.yAxis.scale(),
            width: number = 0,
            heigth: number = 0,
            minX = +min(data, (d) => +d[propertyX]),
            minY = +min(data, (d) => +d[propertyY]),
            maxX = +max(data, (d) => +d[propertyX]),
            maxY = +max(data, (d) => +d[propertyY]);

        colorScale.domain([min(data, (d) => +d[propertyZ]), max(data, (d) => +d[propertyZ])]);

        if (xAxisType === 'linear') {
            this.x.updateDomainByMinMax(minX, maxX + xStep);
            this.x.transition();
            width = x(xStep) - x(0);
        } else if (xAxisType === 'categorical') {
            width = x.step();
        }
        if (yAxisType === 'linear') {
            this.y.updateDomainByMinMax(minY, maxY + yStep);
            this.y.transition();
            heigth = y(0) - y(yStep);
        } else if (yAxisType === 'categorical') {
            heigth = y.step();
        }

        // Data join
        let tiles = this.svg.selectAll('.tile')
            .data(data);

        // Update
        tiles.attr('class', 'tile')
            .attr('x', (d) => x(d[propertyX]))
            .attr('y', (d) => {
                if (yAxisType === 'linear') {
                    return y(+d[propertyY] + yStep);
                } else {
                    return y(d[propertyY]);
                }
            })
            .attr('width', width)
            .attr('height', heigth)
            .attr('fill-opacity', 1)
            .style('fill', (d) => colorScale(d[propertyZ]));

        // Enter
        let entering = tiles
            .enter().append('rect')
            .attr('class', 'tile')
            .attr('x', (d) => x(d[propertyX]))
            .attr('y', (d) => {
                if (yAxisType === 'linear') {
                    return y(+d[propertyY] + yStep);
                } else {
                    return y(d[propertyY]);
                }
            })
            .attr('width', width)
            .attr('height', heigth)
            .style('fill', (d) => colorScale(d[propertyZ]))
            .attr('fill-opacity', 0)
            .attr('fill-opacity', 1);

        // Exit
        tiles.exit().remove();

        tiles
            .on('mousedown.user', this.config.get('onDown'))
            .on('mouseup.user', this.config.get('onUp'))
            .on('mouseleave.user', this.config.get('onLeave'))
            .on('mouseover.user', this.config.get('onHover'))
            .on('click.user', this.config.get('onClick'));
    }
開發者ID:proteus-h2020,項目名稱:proteus-charts,代碼行數:82,代碼來源:TileSet.ts

示例5: MixedObject

    new MixedObject(20, new Date(2016, 7, 30)),
    new MixedObject(30, new Date(2015, 3, 15)),
    new MixedObject(40, new Date(2014, 3, 15)),
    new MixedObject(50, new Date(2017, 4, 15))
];


// -----------------------------------------------------------------------------
// Test Statistics
// -----------------------------------------------------------------------------

// max() -----------------------------------------------------------------------

// without accessors

num = d3Array.max(numbersArray);
str = d3Array.max(stringyNumbersArray);
numeric = d3Array.max(numericArray);
date = d3Array.max(dateArray);

// with accessors

num = d3Array.max(mixedObjectArray, function (datum, index, array) {
    let d: MixedObject = datum;
    let i: number = index;
    let arr: Array<MixedObject> = array;
    return datum.num;
});

str = d3Array.max(mixedObjectArray, function (datum, index, array) {
    let d: MixedObject = datum;
開發者ID:DmitryEfimenko,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:d3-array-tests.ts


注:本文中的d3-array.max函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。