mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-23 11:03:09 +02:00
fix(frontend): fix retention rate heatmap rendering
This commit is contained in:
parent
5be6438bbc
commit
f983e44d9e
1 changed files with 13 additions and 3 deletions
|
@ -90,8 +90,13 @@ async function renderChart() {
|
||||||
borderRadius: 3,
|
borderRadius: 3,
|
||||||
backgroundColor(c) {
|
backgroundColor(c) {
|
||||||
const value = c.dataset.data[c.dataIndex].v;
|
const value = c.dataset.data[c.dataIndex].v;
|
||||||
const a = value / max(c.dataset.data[c.dataIndex].y);
|
const m = max(c.dataset.data[c.dataIndex].y);
|
||||||
return alpha(color, a);
|
if (m === 0) {
|
||||||
|
return alpha(color, 0);
|
||||||
|
} else {
|
||||||
|
const a = value / m;
|
||||||
|
return alpha(color, a);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
fill: true,
|
fill: true,
|
||||||
width(c) {
|
width(c) {
|
||||||
|
@ -170,7 +175,12 @@ async function renderChart() {
|
||||||
},
|
},
|
||||||
label(context) {
|
label(context) {
|
||||||
const v = context.dataset.data[context.dataIndex];
|
const v = context.dataset.data[context.dataIndex];
|
||||||
return [`Active: ${v.v} (${Math.round((v.v / max(v.y)) * 100)}%)`];
|
const m = max(v.y);
|
||||||
|
if (m === 0) {
|
||||||
|
return [`Active: ${v.v} (-%)`];
|
||||||
|
} else {
|
||||||
|
return [`Active: ${v.v} (${Math.round((v.v / m) * 100)}%)`];
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
//mode: 'index',
|
//mode: 'index',
|
||||||
|
|
Loading…
Reference in a new issue