mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2025-01-11 23:57:21 -08:00
feature: allow user to select the chart fill color
This commit is contained in:
parent
de15cb1ff2
commit
c0f59c441b
6 changed files with 88 additions and 13 deletions
|
@ -103,7 +103,7 @@ namespace SourceGit.Models
|
||||||
{
|
{
|
||||||
Values = samples,
|
Values = samples,
|
||||||
Stroke = null,
|
Stroke = null,
|
||||||
Fill = new SolidColorPaint(SKColors.Green),
|
Fill = null,
|
||||||
Padding = 1,
|
Padding = 1,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -117,6 +117,12 @@ namespace SourceGit.Models
|
||||||
_mapSamples.Clear();
|
_mapSamples.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ChangeColor(uint color)
|
||||||
|
{
|
||||||
|
if (Series is [ColumnSeries<DateTimePoint> series])
|
||||||
|
series.Fill = new SolidColorPaint(new SKColor(color));
|
||||||
|
}
|
||||||
|
|
||||||
private StaticsticsMode _mode = StaticsticsMode.All;
|
private StaticsticsMode _mode = StaticsticsMode.All;
|
||||||
private Dictionary<string, int> _mapUsers = new Dictionary<string, int>();
|
private Dictionary<string, int> _mapUsers = new Dictionary<string, int>();
|
||||||
private Dictionary<DateTime, int> _mapSamples = new Dictionary<DateTime, int>();
|
private Dictionary<DateTime, int> _mapSamples = new Dictionary<DateTime, int>();
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
<StreamGeometry x:Key="Icons.Clean">M797 829a49 49 0 1049 49 49 49 0 00-49-49zm147-114A49 49 0 10992 764a49 49 0 00-49-49zM928 861a49 49 0 1049 49A49 49 0 00928 861zm-5-586L992 205 851 64l-71 71a67 67 0 00-94 0l235 235a67 67 0 000-94zm-853 128a32 32 0 00-32 50 1291 1291 0 0075 112L288 552c20 0 25 21 8 37l-93 86a1282 1282 0 00120 114l100-32c19-6 28 15 14 34l-40 55c26 19 53 36 82 53a89 89 0 00115-20 1391 1391 0 00256-485l-188-188s-306 224-595 198z</StreamGeometry>
|
<StreamGeometry x:Key="Icons.Clean">M797 829a49 49 0 1049 49 49 49 0 00-49-49zm147-114A49 49 0 10992 764a49 49 0 00-49-49zM928 861a49 49 0 1049 49A49 49 0 00928 861zm-5-586L992 205 851 64l-71 71a67 67 0 00-94 0l235 235a67 67 0 000-94zm-853 128a32 32 0 00-32 50 1291 1291 0 0075 112L288 552c20 0 25 21 8 37l-93 86a1282 1282 0 00120 114l100-32c19-6 28 15 14 34l-40 55c26 19 53 36 82 53a89 89 0 00115-20 1391 1391 0 00256-485l-188-188s-306 224-595 198z</StreamGeometry>
|
||||||
<StreamGeometry x:Key="Icons.Clone">M1280 704c0 141-115 256-256 256H288C129 960 0 831 0 672c0-126 80-232 192-272A327 327 0 01192 384c0-177 143-320 320-320 119 0 222 64 277 160C820 204 857 192 896 192c106 0 192 86 192 192 0 24-5 48-13 69C1192 477 1280 580 1280 704zm-493-128H656V352c0-18-14-32-32-32h-96c-18 0-32 14-32 32v224h-131c-29 0-43 34-23 55l211 211c12 12 33 12 45 0l211-211c20-20 6-55-23-55z</StreamGeometry>
|
<StreamGeometry x:Key="Icons.Clone">M1280 704c0 141-115 256-256 256H288C129 960 0 831 0 672c0-126 80-232 192-272A327 327 0 01192 384c0-177 143-320 320-320 119 0 222 64 277 160C820 204 857 192 896 192c106 0 192 86 192 192 0 24-5 48-13 69C1192 477 1280 580 1280 704zm-493-128H656V352c0-18-14-32-32-32h-96c-18 0-32 14-32 32v224h-131c-29 0-43 34-23 55l211 211c12 12 33 12 45 0l211-211c20-20 6-55-23-55z</StreamGeometry>
|
||||||
<StreamGeometry x:Key="Icons.Code">M853 102H171C133 102 102 133 102 171v683C102 891 133 922 171 922h683C891 922 922 891 922 853V171C922 133 891 102 853 102zM390 600l-48 48L205 512l137-137 48 48L301 512l88 88zM465 819l-66-18L559 205l66 18L465 819zm218-171L634 600 723 512l-88-88 48-48L819 512 683 649z</StreamGeometry>
|
<StreamGeometry x:Key="Icons.Code">M853 102H171C133 102 102 133 102 171v683C102 891 133 922 171 922h683C891 922 922 891 922 853V171C922 133 891 102 853 102zM390 600l-48 48L205 512l137-137 48 48L301 512l88 88zM465 819l-66-18L559 205l66 18L465 819zm218-171L634 600 723 512l-88-88 48-48L819 512 683 649z</StreamGeometry>
|
||||||
|
<StreamGeometry x:Key="Icons.ColorPicker">M731 331c-28-28-43-27-64-130s-95-136-176-136C244 65 64 265 64 512a447 447 0 00448 447c247 0 450-165 448-412-2-224-186-173-229-215zM246 467a57 57 0 1157 57 57 57 0 01-57-57zm125 215a45 45 0 1145-45 45 45 0 01-45 45zm34-310a71 71 0 1171-71 71 71 0 01-71 71z</StreamGeometry>
|
||||||
<StreamGeometry x:Key="Icons.Commit">M796 471A292 292 0 00512 256a293 293 0 00-284 215H0v144h228A293 293 0 00512 832a291 291 0 00284-217H1024V471h-228M512 688A146 146 0 01366 544A145 145 0 01512 400c80 0 146 63 146 144A146 146 0 01512 688</StreamGeometry>
|
<StreamGeometry x:Key="Icons.Commit">M796 471A292 292 0 00512 256a293 293 0 00-284 215H0v144h228A293 293 0 00512 832a291 291 0 00284-217H1024V471h-228M512 688A146 146 0 01366 544A145 145 0 01512 400c80 0 146 63 146 144A146 146 0 01512 688</StreamGeometry>
|
||||||
<StreamGeometry x:Key="Icons.Compare">M645 448l64 64 220-221L704 64l-64 64 115 115H128v90h628zM375 576l-64-64-220 224L314 960l64-64-116-115H896v-90H262z</StreamGeometry>
|
<StreamGeometry x:Key="Icons.Compare">M645 448l64 64 220-221L704 64l-64 64 115 115H128v90h628zM375 576l-64-64-220 224L314 960l64-64-116-115H896v-90H262z</StreamGeometry>
|
||||||
<StreamGeometry x:Key="Icons.Conflict">M608 0q48 0 88 23t63 63 23 87v70h55q35 0 67 14t57 38 38 57 14 67V831q0 34-14 66t-38 57-57 38-67 13H426q-34 0-66-13t-57-38-38-57-14-66v-70h-56q-34 0-66-14t-57-38-38-57-13-67V174q0-47 23-87T109 23 196 0h412m175 244H426q-46 0-86 22T278 328t-26 85v348H608q47 0 86-22t63-62 25-85l1-348m-269 318q18 0 31 13t13 31-13 31-31 13-31-13-13-31 13-31 31-13m0-212q13 0 22 9t11 22v125q0 14-9 23t-22 10-23-7-11-22l-1-126q0-13 10-23t23-10z</StreamGeometry>
|
<StreamGeometry x:Key="Icons.Conflict">M608 0q48 0 88 23t63 63 23 87v70h55q35 0 67 14t57 38 38 57 14 67V831q0 34-14 66t-38 57-57 38-67 13H426q-34 0-66-13t-57-38-38-57-14-66v-70h-56q-34 0-66-14t-57-38-38-57-13-67V174q0-47 23-87T109 23 196 0h412m175 244H426q-46 0-86 22T278 328t-26 85v348H608q47 0 86-22t63-62 25-85l1-348m-269 318q18 0 31 13t13 31-13 31-31 13-31-13-13-31 13-31 31-13m0-212q13 0 22 9t11 22v125q0 14-9 23t-22 10-23-7-11-22l-1-126q0-13 10-23t23-10z</StreamGeometry>
|
||||||
|
|
|
@ -337,6 +337,12 @@ namespace SourceGit.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public uint StatisticsSampleColor
|
||||||
|
{
|
||||||
|
get => _statisticsSampleColor;
|
||||||
|
set => SetProperty(ref _statisticsSampleColor, value);
|
||||||
|
}
|
||||||
|
|
||||||
public List<RepositoryNode> RepositoryNodes
|
public List<RepositoryNode> RepositoryNodes
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
@ -621,5 +627,7 @@ namespace SourceGit.ViewModels
|
||||||
private int _shellOrTerminal = -1;
|
private int _shellOrTerminal = -1;
|
||||||
private int _externalMergeToolType = 0;
|
private int _externalMergeToolType = 0;
|
||||||
private string _externalMergeToolPath = string.Empty;
|
private string _externalMergeToolPath = string.Empty;
|
||||||
|
|
||||||
|
private uint _statisticsSampleColor = 0xFF00FF00;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,18 +47,12 @@ namespace SourceGit.ViewModels
|
||||||
if (_data == null)
|
if (_data == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (_selectedIndex)
|
SelectedReport = _selectedIndex switch
|
||||||
{
|
{
|
||||||
case 0:
|
0 => _data.All,
|
||||||
SelectedReport = _data.All;
|
1 => _data.Month,
|
||||||
break;
|
_ => _data.Week,
|
||||||
case 1:
|
};
|
||||||
SelectedReport = _data.Month;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
SelectedReport = _data.Week;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _isLoading = true;
|
private bool _isLoading = true;
|
||||||
|
|
|
@ -185,7 +185,25 @@
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<!-- Graph -->
|
<!-- Graph -->
|
||||||
<lvc:CartesianChart Grid.Column="1" Margin="16" Series="{Binding Series}" XAxes="{Binding XAxes}" YAxes="{Binding YAxes}" ZoomMode="X"/>
|
<Grid Grid.Column="1" RowDefinitions="28,*" Margin="16,0">
|
||||||
|
<Button Grid.Row="0" Background="Transparent" BorderThickness="0" HorizontalAlignment="Center">
|
||||||
|
<Button.Flyout>
|
||||||
|
<Flyout>
|
||||||
|
<Border Padding="8">
|
||||||
|
<v:ColorPicker Value="{Binding #ThisControl.SampleFillColor, Mode=TwoWay}"/>
|
||||||
|
</Border>
|
||||||
|
</Flyout>
|
||||||
|
</Button.Flyout>
|
||||||
|
|
||||||
|
<Path Width="20" Height="20" Data="{StaticResource Icons.ColorPicker}" Fill="{Binding #ThisControl.SampleFillBrush}"/>
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<lvc:CartesianChart Grid.Row="1"
|
||||||
|
Series="{Binding Series}"
|
||||||
|
XAxes="{Binding XAxes}" YAxes="{Binding YAxes}"
|
||||||
|
ZoomMode="X"
|
||||||
|
DataContextChanged="OnReportChanged"/>
|
||||||
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ContentControl.DataTemplates>
|
</ContentControl.DataTemplates>
|
||||||
|
|
|
@ -1,17 +1,65 @@
|
||||||
|
using Avalonia;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
|
using Avalonia.Media;
|
||||||
|
|
||||||
namespace SourceGit.Views
|
namespace SourceGit.Views
|
||||||
{
|
{
|
||||||
public partial class Statistics : ChromelessWindow
|
public partial class Statistics : ChromelessWindow
|
||||||
{
|
{
|
||||||
|
public static readonly StyledProperty<uint> SampleFillColorProperty =
|
||||||
|
AvaloniaProperty.Register<Statistics, uint>(nameof(SampleFillColor));
|
||||||
|
|
||||||
|
public uint SampleFillColor
|
||||||
|
{
|
||||||
|
get => GetValue(SampleFillColorProperty);
|
||||||
|
set => SetValue(SampleFillColorProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static readonly StyledProperty<IBrush> SampleFillBrushProperty =
|
||||||
|
AvaloniaProperty.Register<Statistics, IBrush>(nameof(SampleFillBrush), Brushes.Transparent);
|
||||||
|
|
||||||
|
public IBrush SampleFillBrush
|
||||||
|
{
|
||||||
|
get => GetValue(SampleFillBrushProperty);
|
||||||
|
set => SetValue(SampleFillBrushProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
public Statistics()
|
public Statistics()
|
||||||
{
|
{
|
||||||
|
SampleFillColor = ViewModels.Preference.Instance.StatisticsSampleColor;
|
||||||
|
SampleFillBrush = new SolidColorBrush(SampleFillColor);
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
|
||||||
|
{
|
||||||
|
base.OnPropertyChanged(change);
|
||||||
|
|
||||||
|
if (change.Property == SampleFillColorProperty)
|
||||||
|
ChangeColor(SampleFillColor);
|
||||||
|
}
|
||||||
|
|
||||||
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
|
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
|
||||||
{
|
{
|
||||||
BeginMoveDrag(e);
|
BeginMoveDrag(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnReportChanged(object sender, System.EventArgs e)
|
||||||
|
{
|
||||||
|
if (DataContext is ViewModels.Statistics { SelectedReport: Models.StatisticsReport report })
|
||||||
|
report.ChangeColor(SampleFillColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ChangeColor(uint color)
|
||||||
|
{
|
||||||
|
if (color != ViewModels.Preference.Instance.StatisticsSampleColor)
|
||||||
|
{
|
||||||
|
ViewModels.Preference.Instance.StatisticsSampleColor = color;
|
||||||
|
SetCurrentValue(SampleFillBrushProperty, new SolidColorBrush(color));
|
||||||
|
|
||||||
|
if (DataContext is ViewModels.Statistics { SelectedReport: Models.StatisticsReport report })
|
||||||
|
report.ChangeColor(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue