Skip to content

Commit

Permalink
fix(frontend): fix retention rate heatmap rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
syuilo committed May 12, 2023
1 parent 5be6438 commit f983e44
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/frontend/src/components/MkRetentionHeatmap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,13 @@ async function renderChart() {
borderRadius: 3,
backgroundColor(c) {
const value = c.dataset.data[c.dataIndex].v;
const a = value / max(c.dataset.data[c.dataIndex].y);
return alpha(color, a);
const m = max(c.dataset.data[c.dataIndex].y);
if (m === 0) {
return alpha(color, 0);
} else {
const a = value / m;
return alpha(color, a);
}
},
fill: true,
width(c) {
Expand Down Expand Up @@ -170,7 +175,12 @@ async function renderChart() {
},
label(context) {
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',
Expand Down

1 comment on commit f983e44

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chromatic detects changes. Please review the changes on Chromatic.

Please sign in to comment.