Skip to content

Commit f3fd2f6

Browse files
committed
refactor: do not render chart if no commit collected in statistics
Signed-off-by: leo <longshuang@msn.cn>
1 parent bb9a360 commit f3fd2f6

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

src/Models/Statistics.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,14 @@ public StatisticsSamples(StatisticsMode mode, DateTime start, DateTime end, Dict
4242
else
4343
MaxValue = (int)(Math.Floor(maxValue / 6.0) * 8.0);
4444

45-
Count = mode switch
46-
{
47-
StatisticsMode.All => (end.Year - start.Year) * 12 + (end.Month - start.Month) + 1,
48-
_ => all.Count,
49-
};
45+
if (maxValue == 0)
46+
Count = 0;
47+
else
48+
Count = mode switch
49+
{
50+
StatisticsMode.All => (end.Year - start.Year) * 12 + (end.Month - start.Month) + 1,
51+
_ => all.Count,
52+
};
5053
}
5154

5255
public void WithUser(Dictionary<DateTime, int> user)

src/Views/Chart.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public override void Render(DrawingContext context)
5454
base.Render(context);
5555

5656
var samples = _samples;
57-
if (samples == null || samples.Count <= 0)
57+
if (samples == null || samples.Count == 0)
5858
return;
5959

6060
var w = Bounds.Width;

0 commit comments

Comments
 (0)