@@ -73,6 +73,15 @@ public IBrush SecondaryForeground
7373 set => SetValue ( SecondaryForegroundProperty , value ) ;
7474 }
7575
76+ public static readonly StyledProperty < IBrush > BorderBrushProperty =
77+ AvaloniaProperty . Register < PieChart , IBrush > ( nameof ( BorderBrush ) , Brushes . White ) ;
78+
79+ public IBrush BorderBrush
80+ {
81+ get => GetValue ( BorderBrushProperty ) ;
82+ set => SetValue ( BorderBrushProperty , value ) ;
83+ }
84+
7685 public override void Render ( DrawingContext context )
7786 {
7887 base . Render ( context ) ;
@@ -125,10 +134,10 @@ public override void Render(DrawingContext context)
125134 foreach ( var author in _report . Authors )
126135 {
127136 var percent = ( double ) author . Count / total ;
128- var brush = s_brushes [ brushIndex ] ;
129137 if ( percent > 0.01 )
130138 {
131139 var sweepAngle = percent * 2 * Math . PI ;
140+ var brush = s_brushes [ brushIndex ] ;
132141 DrawArc ( context , startAngle , sweepAngle , brush ) ;
133142
134143 var arc = new Arc ( startAngle , sweepAngle , author . User . Name , author . Count , percent , brush , author ) ;
@@ -146,10 +155,11 @@ public override void Render(DrawingContext context)
146155 else
147156 {
148157 var sweepAngle = remaining ;
158+ var othersBrush = secondaryForeground ;
149159 var count = total - renderedCount ;
150- DrawArc ( context , startAngle , sweepAngle , brush ) ;
160+ DrawArc ( context , startAngle , sweepAngle , othersBrush ) ;
151161
152- var arc = new Arc ( startAngle , sweepAngle , "Others" , count , ( double ) count / total , brush , null ) ;
162+ var arc = new Arc ( startAngle , sweepAngle , "Others" , count , ( double ) count / total , othersBrush , null ) ;
153163 _arcs . Add ( arc ) ;
154164 if ( arc . IsLeftSide )
155165 leftArcs . Add ( arc ) ;
@@ -159,6 +169,8 @@ public override void Render(DrawingContext context)
159169 }
160170 }
161171
172+ context . DrawLine ( new Pen ( BorderBrush , 1 ) , _center , new Point ( _center . X , _center . Y - _radius ) ) ;
173+
162174 if ( leftArcs . Count > 0 )
163175 {
164176 for ( var i = leftArcs . Count - 1 ; i >= 0 ; i -- )
@@ -255,6 +267,7 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
255267 if ( change . Property == ReportProperty ||
256268 change . Property == FontFamilyProperty ||
257269 change . Property == ForegroundProperty ||
270+ change . Property == BorderBrushProperty ||
258271 change . Property == SecondaryForegroundProperty )
259272 InvalidateVisual ( ) ;
260273 }
0 commit comments