mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-26 13:29:05 +01:00
simplify bins return
This commit is contained in:
parent
68f5b0bba4
commit
b52330ebf0
@ -350,31 +350,16 @@ export function binsFromFootprint(weights, scope, values, numBins) {
|
|||||||
scopeWeights = weights.nodeHours
|
scopeWeights = weights.nodeHours
|
||||||
}
|
}
|
||||||
|
|
||||||
const bins = new Array(numBins).fill(0)
|
const rawBins = new Array(numBins).fill(0)
|
||||||
for (let i = 0; i < values.length; i++)
|
for (let i = 0; i < values.length; i++)
|
||||||
bins[Math.floor(((values[i] - min) / (max - min)) * numBins)] += scopeWeights ? scopeWeights[i] : 1
|
bins[Math.floor(((values[i] - min) / (max - min)) * numBins)] += scopeWeights ? scopeWeights[i] : 1
|
||||||
|
|
||||||
// Manual Canvas Original
|
const bins = rawBins.map((count, idx) => ({
|
||||||
// return {
|
value: Math.floor(min + ((idx + 1) / numBins) * (max - min)),
|
||||||
// label: idx => {
|
count: count
|
||||||
// let start = min + (idx / numBins) * (max - min)
|
}))
|
||||||
// let stop = min + ((idx + 1) / numBins) * (max - min)
|
|
||||||
// return `${formatNumber(start)} - ${formatNumber(stop)}`
|
|
||||||
// },
|
|
||||||
// bins: bins.map((count, idx) => ({ value: idx, count: count })),
|
|
||||||
// min: min,
|
|
||||||
// max: max
|
|
||||||
// }
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
bins: bins.map((count, idx) => ({
|
bins: bins
|
||||||
value: idx => { // Use bins' max value instead of mean
|
|
||||||
// let start = min + (idx / numBins) * (max - min)
|
|
||||||
let stop = min + ((idx + 1) / numBins) * (max - min)
|
|
||||||
// return `${formatNumber(Math.floor((start+stop)/2))}`
|
|
||||||
return Math.floor(stop)
|
|
||||||
},
|
|
||||||
count: count
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user