Use Iris' improved approach for determine most common cell sizes
parent
330188c5cb
commit
d247c11cd9
|
@ -26,23 +26,23 @@ export const NEW_DEFAULT_DASHBOARD_CELL = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const getMostCommonValue = values => {
|
const getMostCommonValue = values => {
|
||||||
const distribution = {}
|
const results = values.reduce(
|
||||||
let max = 0
|
(acc, value) => {
|
||||||
let result = 0
|
const {distribution, mostCommonCount} = acc
|
||||||
|
distribution[value] = (distribution[value] || 0) + 1
|
||||||
|
if (distribution[value] > mostCommonCount) {
|
||||||
|
return {
|
||||||
|
distribution,
|
||||||
|
mostCommonCount: distribution[value],
|
||||||
|
mostCommonValue: value,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
},
|
||||||
|
{distribution: {}, mostCommonCount: 0}
|
||||||
|
)
|
||||||
|
|
||||||
values.forEach(value => {
|
return results.mostCommonValue
|
||||||
distribution[value] = (distribution[value] || 0) + 1
|
|
||||||
if (distribution[value] > max) {
|
|
||||||
max = distribution[value]
|
|
||||||
result = [value]
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (distribution[value] === max) {
|
|
||||||
result.push(value)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return result[0]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const generateNewDashboardCell = dashboard => {
|
export const generateNewDashboardCell = dashboard => {
|
||||||
|
|
Loading…
Reference in New Issue