fix: tweak retention rate aggregation

This commit is contained in:
syuilo
2023-03-15 17:43:13 +09:00
parent 42833cd921
commit 58fc17e3b6
5 changed files with 43 additions and 12 deletions

View File

@@ -36,9 +36,11 @@ async function renderChart() {
const wide = rootEl.offsetWidth > 600;
const narrow = rootEl.offsetWidth < 400;
const maxDays = wide ? 15 : narrow ? 5 : 10;
const maxDays = wide ? 10 : narrow ? 5 : 7;
const raw = await os.api('retention', { });
let raw = await os.api('retention', { });
raw = raw.slice(0, maxDays);
const data = [];
for (const record of raw) {
@@ -60,10 +62,9 @@ async function renderChart() {
const color = defaultStore.state.darkMode ? '#b4e900' : '#86b300';
// 視覚上の分かりやすさのため上から最も大きい3つの値の平均を最大値とする
//const max = raw.readWrite.slice().sort((a, b) => b - a).slice(0, 3).reduce((a, b) => a + b, 0) / 3;
const max = 4;
const max = raw.map(x => x.users).slice().sort((a, b) => b - a).slice(0, 3).reduce((a, b) => a + b, 0) / 3;
const marginEachCell = 6;
const marginEachCell = 12;
chartInstance = new Chart(chartEl, {
type: 'matrix',