@@ -3,7 +3,7 @@ use crate::gui::styles::style_constants::{FONT_SIZE_FOOTER, FONT_SIZE_SUBTITLE,
33use crate :: networking:: types:: data_representation:: DataRepr ;
44use iced:: alignment:: Vertical ;
55use iced:: widget:: canvas:: path:: Arc ;
6- use iced:: widget:: canvas:: { Frame , Text } ;
6+ use iced:: widget:: canvas:: { Frame , Stroke , Text } ;
77use iced:: widget:: text:: Alignment ;
88use iced:: widget:: { Canvas , canvas} ;
99use iced:: { Length , Radians , Renderer , mouse} ;
@@ -91,28 +91,34 @@ impl<Message, Theme: Catalog> canvas::Program<Message, Theme> for DonutChart {
9191 ) -> Vec < canvas:: Geometry > {
9292 let mut frame = Frame :: new ( renderer, bounds. size ( ) ) ;
9393 let center = frame. center ( ) ;
94- let radius = ( frame. width ( ) . min ( frame. height ( ) ) / 2.0 ) * 0.9 ;
94+
95+ let thickness = 6.0 ;
96+ let radius = ( frame. width ( ) . min ( frame. height ( ) ) / 2.0 ) * 0.9 - thickness / 2.0 ;
9597
9698 let style = <Theme as Catalog >:: style ( theme, & <Theme as Catalog >:: default ( ) ) ;
9799 let colors = [ style. incoming , style. outgoing , style. dropped ] ;
98100
99101 for ( ( start_angle, end_angle) , color) in self . angles ( ) . into_iter ( ) . zip ( colors) {
100102 let path = canvas:: Path :: new ( |builder| {
103+ // build path using just an arc with thickness, because iced's paths are limited:
104+ // - no single close path can be constructed as the one we want (drawing an arc starts a new sub-path)
105+ // - counter-clockwise arcs are not supported
101106 builder. arc ( Arc {
102107 center,
103108 radius,
104109 start_angle,
105110 end_angle,
106111 } ) ;
107- builder. line_to ( center) ;
108- builder. close ( ) ;
109112 } ) ;
110113
111- frame. fill ( & path, color) ;
114+ let stroke = Stroke {
115+ style : canvas:: stroke:: Style :: Solid ( color) ,
116+ width : thickness,
117+ ..Default :: default ( )
118+ } ;
119+ frame. stroke ( & path, stroke) ;
112120 }
113121
114- let inner_circle = canvas:: Path :: circle ( center, radius - 6.0 ) ;
115- frame. fill ( & inner_circle, style. background ) ;
116122 frame. fill_text ( Text {
117123 content : self . title ( ) . clone ( ) ,
118124 position : center,
0 commit comments