Skip to content

Commit

Permalink
Fix NaN charts
Browse files Browse the repository at this point in the history
  • Loading branch information
SnekNOTSnake committed Mar 23, 2022
1 parent 7e4ebf5 commit 4e0e134
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "my-personal-list",
"description": "My personal anime tracking list",
"version": "1.0.1",
"version": "1.0.2",
"scripts": {
"start": "concurrently \"yarn start:renderer\" \"yarn start:main\" --kill-others",
"start:main": "tsc && electron .",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ const ChartBar: React.FC = () => {
tickColor: 'transparent',
},
ticks: {
stepSize: Math.ceil(Math.max(...tags.map((tag) => tag.epsNum)) / 5),
stepSize:
tags.length > 0
? Math.ceil(Math.max(...tags.map((tag) => tag.epsNum)) / 5)
: 100,
color: textColor,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@ const DoughnutChart: React.FC = () => {
],
}

const percentage =
stats.totalEpisodes > 0
? Math.ceil((stats.watchedEpisodes / stats.totalEpisodes) * 100)
: 0

return (
<div className={styles.root}>
<div className={styles.label}>
<div className={styles.percentage}>
{Math.ceil((stats.watchedEpisodes / stats.totalEpisodes) * 100)}%
</div>
<div className={styles.percentage}>{percentage}%</div>
<div className={styles.episodes}>
{stats.watchedEpisodes} / {stats.totalEpisodes} Eps
</div>
Expand Down
6 changes: 3 additions & 3 deletions packages/renderer/src/store/series.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ export const seriesStats = selector({

let stockpileLasts, suffix
const daysRunsOut = (totalEpisodes - watchedEpisodes) / avgEpsPerDay
if (daysRunsOut === Infinity) {
stockpileLasts = daysRunsOut
suffix = ''
if (totalEpisodes === 0) {
stockpileLasts = 0
suffix = 'M'
} else if (daysRunsOut > 365) {
stockpileLasts = daysRunsOut / 365
suffix = 'Y'
Expand Down

0 comments on commit 4e0e134

Please sign in to comment.