本文整理汇总了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)
};
});
示例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);
示例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() -----------------------------------------------------------------------
示例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'));
}
示例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;