本文整理匯總了TypeScript中d3-array.mean函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript mean函數的具體用法?TypeScript mean怎麽用?TypeScript mean使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了mean函數的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: commonValues
// Exclude any major outliers for legend calculation (they will be relegated to open-ended bins)
@computed get commonValues(): number[] {
const {sortedNumericValues} = this
if (!sortedNumericValues.length) return []
const sampleMean = mean(sortedNumericValues) as number
const sampleDeviation = deviation(sortedNumericValues) as number
return sortedNumericValues.filter(d => Math.abs(d-sampleMean) <= sampleDeviation*2)
}
示例3:
numericOrUndefinedExtent = d3Array.extent(readonlyNumericArray);
dateOrUndefinedExtent = d3Array.extent(readonlyDateArray);
// 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);
numOrUndefinedExtent = d3Array.extent(readonlyMixedObjectOrUndefinedArray, accessorReadOnlyMixedObjectToNumOrUndefined);
// mean() ----------------------------------------------------------------------
numOrUndefined = d3Array.mean(numbersArray);
numOrUndefined = d3Array.mean(numericArray);
numOrUndefined = d3Array.mean(numbersOrUndefinedArray);
numOrUndefined = d3Array.mean(typedArray);
numOrUndefined = d3Array.mean(readonlyNumbersOrUndefinedArray);
numOrUndefined = d3Array.mean(readonlyNumericArray);
numOrUndefined = d3Array.mean(readonlyNumbersOrUndefinedArray);
numOrUndefined = d3Array.mean(mixedObjectArray, accessorMixedObjectToNum);
numOrUndefined = d3Array.mean(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined);
numOrUndefined = d3Array.mean(readonlyMixedObjectOrUndefinedArray, accessorReadOnlyMixedObjectToNumOrUndefined);
// median() --------------------------------------------------------------------
numOrUndefined = d3Array.median(numbersArray);
示例4:
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() ----------------------------------------------------------------------
numOrUndefined = d3Array.mean(numbersArray);
numOrUndefined = d3Array.mean(numericArray);
numOrUndefined = d3Array.mean(numbersOrUndefinedArray);
numOrUndefined = d3Array.mean(mixedObjectArray, accessorMixedObjectToNum);
numOrUndefined = d3Array.mean(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined);
// median() --------------------------------------------------------------------
numOrUndefined = d3Array.median(numbersArray);
numOrUndefined = d3Array.median(numericArray);
numOrUndefined = d3Array.median(numbersOrUndefinedArray);
numOrUndefined = d3Array.median(mixedObjectArray, accessorMixedObjectToNum);
numOrUndefined = d3Array.median(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined);
示例5: function
let d: MixedObject = datum;
let i: number = index;
let arr: Array<MixedObject> = array;
return datum.numeric;
});
extentDateMixed = d3Array.extent(mixedObjectArray, function (datum, index, array) {
let d: MixedObject = datum;
let i: number = index;
let arr: Array<MixedObject> = array;
return datum.date;
});
// mean() ----------------------------------------------------------------------
num = d3Array.mean(numbersArray);
num = d3Array.mean(mixedObjectArray, function (datum, index, array) {
let d: MixedObject = datum;
let i: number = index;
let arr: Array<MixedObject> = array;
return datum.num;
});
// median() --------------------------------------------------------------------
num = d3Array.median(numbersArray);
num = d3Array.median(mixedObjectArray, function (datum, index, array) {
let d: MixedObject = datum;
let i: number = index;