ux: new style for statistics page

This commit is contained in:
leo 2024-04-03 17:34:06 +08:00
parent 3d5a9f9d8b
commit bcb83af576
6 changed files with 52 additions and 48 deletions

View file

@ -3607,7 +3607,7 @@ namespace SourceGit.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Total Commits. /// Looks up a localized string similar to COMMITS: .
/// </summary> /// </summary>
public static string Text_Statistics_TotalCommits { public static string Text_Statistics_TotalCommits {
get { get {
@ -3616,7 +3616,7 @@ namespace SourceGit.Resources {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to Total Committers. /// Looks up a localized string similar to COMMITTERS: .
/// </summary> /// </summary>
public static string Text_Statistics_TotalCommitters { public static string Text_Statistics_TotalCommitters {
get { get {

View file

@ -1201,10 +1201,10 @@
<value>YEAR</value> <value>YEAR</value>
</data> </data>
<data xml:space="preserve" name="Text.Statistics.TotalCommitters"> <data xml:space="preserve" name="Text.Statistics.TotalCommitters">
<value>Total Committers</value> <value>COMMITTERS: </value>
</data> </data>
<data xml:space="preserve" name="Text.Statistics.TotalCommits"> <data xml:space="preserve" name="Text.Statistics.TotalCommits">
<value>Total Commits</value> <value>COMMITS: </value>
</data> </data>
<data xml:space="preserve" name="Text.Statistics.Committer"> <data xml:space="preserve" name="Text.Statistics.Committer">
<value>COMMITTER</value> <value>COMMITTER</value>

View file

@ -1201,10 +1201,10 @@
<value>YEAR</value> <value>YEAR</value>
</data> </data>
<data xml:space="preserve" name="Text.Statistics.TotalCommitters"> <data xml:space="preserve" name="Text.Statistics.TotalCommitters">
<value>Total Committers</value> <value>COMMITTERS: </value>
</data> </data>
<data xml:space="preserve" name="Text.Statistics.TotalCommits"> <data xml:space="preserve" name="Text.Statistics.TotalCommits">
<value>Total Commits</value> <value>COMMITS: </value>
</data> </data>
<data xml:space="preserve" name="Text.Statistics.Committer"> <data xml:space="preserve" name="Text.Statistics.Committer">
<value>COMMITTER</value> <value>COMMITTER</value>

View file

@ -1198,10 +1198,10 @@
<value>本年</value> <value>本年</value>
</data> </data>
<data xml:space="preserve" name="Text.Statistics.TotalCommitters"> <data xml:space="preserve" name="Text.Statistics.TotalCommitters">
<value>提交者人数</value> <value>提交者: </value>
</data> </data>
<data xml:space="preserve" name="Text.Statistics.TotalCommits"> <data xml:space="preserve" name="Text.Statistics.TotalCommits">
<value>总计提交次数</value> <value>提交次数: </value>
</data> </data>
<data xml:space="preserve" name="Text.Statistics.Committer"> <data xml:space="preserve" name="Text.Statistics.Committer">
<value>提交者</value> <value>提交者</value>

View file

@ -128,9 +128,10 @@
<ContentControl Grid.Row="2" Content="{Binding SelectedReport, Mode=OneWay}"> <ContentControl Grid.Row="2" Content="{Binding SelectedReport, Mode=OneWay}">
<ContentControl.DataTemplates> <ContentControl.DataTemplates>
<DataTemplate DataType="m:StatisticsReport"> <DataTemplate DataType="m:StatisticsReport">
<Grid RowDefinitions="*,32" ColumnDefinitions="256,*" Margin="8"> <Grid ColumnDefinitions="256,*" Margin="8,8,8,16">
<Grid Grid.Column="0" RowDefinitions="*,16">
<!-- Table By Committer --> <!-- Table By Committer -->
<DataGrid Grid.Row="0" Grid.Column="0" <DataGrid Grid.Row="0"
ItemsSource="{Binding ByCommitter}" ItemsSource="{Binding ByCommitter}"
SelectionMode="Single" SelectionMode="Single"
CanUserReorderColumns="False" CanUserReorderColumns="False"
@ -151,25 +152,29 @@
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
<!-- Summary -->
<Grid Grid.Row="1" ColumnDefinitions="*,*">
<!-- Total Committers --> <!-- Total Committers -->
<StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal"> <StackPanel Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Bottom">
<TextBlock Text="{DynamicResource Text.Statistics.TotalCommitters}" Foreground="{DynamicResource Brush.FG2}" FontWeight="Bold"/> <TextBlock Classes="monospace" Text="{DynamicResource Text.Statistics.TotalCommitters}" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/>
<TextBlock Text="{Binding ByCommitter.Count}" Margin="4,0,0,0"/> <TextBlock Classes="monospace" Text="{Binding ByCommitter.Count}" FontSize="11" Margin="4,0,0,0"/>
</StackPanel> </StackPanel>
<!-- Graph -->
<v:Chart Grid.Row="0" Grid.Column="1"
Margin="16,8,0,0"
LineBrush="{DynamicResource Brush.FG1}"
ShapeBrush="{DynamicResource Brush.Accent1}"
Samples="{Binding Samples}"/>
<!-- Total Commits --> <!-- Total Commits -->
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right"> <StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom">
<TextBlock Text="{DynamicResource Text.Statistics.TotalCommits}" Foreground="{DynamicResource Brush.FG2}" FontWeight="Bold"/> <TextBlock Classes="monospace" Text="{DynamicResource Text.Statistics.TotalCommits}" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/>
<TextBlock Text="{Binding Total}" Margin="4,0,0,0"/> <TextBlock Classes="monospace" Text="{Binding Total}" FontSize="11" Margin="4,0,0,0"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
</Grid>
<!-- Graph -->
<v:Chart Grid.Column="1"
Margin="16,0,0,0"
LineBrush="{DynamicResource Brush.Border1}"
ShapeBrush="{DynamicResource Brush.Accent1}"
Samples="{Binding Samples}"/>
</Grid>
</DataTemplate> </DataTemplate>
</ContentControl.DataTemplates> </ContentControl.DataTemplates>
</ContentControl> </ContentControl>

View file

@ -104,8 +104,7 @@ namespace SourceGit.Views
var horizonStart = maxLabel.Width + 8; var horizonStart = maxLabel.Width + 8;
var labelHeight = maxLabel.Height; var labelHeight = maxLabel.Height;
context.DrawText(maxLabel, new Point(0, -maxLabel.Height * 0.5)); context.DrawText(maxLabel, new Point(0, -maxLabel.Height * 0.5));
context.DrawLine(pen, new Point(horizonStart, 0), new Point(horizonStart, height - labelHeight)); context.DrawRectangle(pen, new Rect(horizonStart, 0, width - horizonStart, height - labelHeight));
context.DrawLine(pen, new Point(horizonStart, height - labelHeight), new Point(width, height - labelHeight));
if (samples.Count == 0) if (samples.Count == 0)
return; return;
@ -114,7 +113,7 @@ namespace SourceGit.Views
var stepX = (width - horizonStart) / samples.Count; var stepX = (width - horizonStart) / samples.Count;
var stepV = (height - labelHeight) / 5; var stepV = (height - labelHeight) / 5;
var labelStepV = maxV / 5; var labelStepV = maxV / 5;
var gridPen = new Pen(LineBrush, 1, new DashStyle()); var gridPen = new Pen(LineBrush, 1, new DashStyle() { Dashes = [2, 2, 0, 2], Offset = 1 });
for (int i = 1; i < 5; i++) for (int i = 1; i < 5; i++)
{ {
var vLabel = new FormattedText( var vLabel = new FormattedText(