@@ -142,6 +142,9 @@ class ChartPainter extends CustomPainter {
142142
143143 LayeredChartState state;
144144
145+ List <TextPainter > labelPainter;
146+ List <TextPainter > milestonePainter;
147+
145148 ChartPainter (this .state, this .dataToPlot, this .milestones, this .margin, this .graphHeight, this .graphGap, double degrees, double capDegrees, this .capSize, this .numPoints, this .amount) {
146149 this .theta = pi * degrees / 180 ;
147150 this .capTheta = pi * capDegrees / 180 ;
@@ -155,6 +158,20 @@ class ChartPainter extends CustomPainter {
155158 milestonePaint.color = new Color (0xAAFFFFFF );
156159 milestonePaint.style = PaintingStyle .stroke;
157160 milestonePaint.strokeWidth = 1 ;
161+ labelPainter = new List <TextPainter >();
162+ for (int i = 0 ; i < dataToPlot.length; i++ ) {
163+ TextSpan span = new TextSpan (style: new TextStyle (color: Color .fromARGB (255 , 255 , 255 , 255 ), fontSize: 12 ), text: dataToPlot[i].label.toUpperCase ());
164+ TextPainter tp = new TextPainter (text: span, textAlign: TextAlign .left, textDirection: TextDirection .ltr);
165+ tp.layout ();
166+ labelPainter.add (tp);
167+ }
168+ milestonePainter = new List <TextPainter >();
169+ for (int i = 0 ; i < milestones.length; i++ ) {
170+ TextSpan span = new TextSpan (style: new TextStyle (color: Color .fromARGB (255 , 255 , 255 , 255 ), fontSize: 10 ), text: milestones[i].label.toUpperCase ());
171+ TextPainter tp = new TextPainter (text: span, textAlign: TextAlign .left, textDirection: TextDirection .ltr);
172+ tp.layout ();
173+ milestonePainter.add (tp);
174+ }
158175 }
159176
160177 @override
@@ -213,9 +230,7 @@ class ChartPainter extends CustomPainter {
213230 y1 += graphGap * 0.5 ;
214231 canvas.drawLine (new Offset (x1, y1), new Offset (x2, y2), milestonePaint);
215232 canvas.save ();
216- TextSpan span = new TextSpan (style: new TextStyle (color: Color .fromARGB (255 , 255 , 255 , 255 ), fontSize: 10 ), text: milestone.label.toUpperCase ());
217- TextPainter tp = new TextPainter (text: span, textAlign: TextAlign .left, textDirection: TextDirection .ltr);
218- tp.layout ();
233+ TextPainter tp = milestonePainter[i];
219234 canvas.translate (x1 - tp.width / 2 , y1);
220235 canvas.skew (capTheta * 1.0 , - theta);
221236 tp.paint (canvas, new Offset (0 , 0 ));
@@ -243,9 +258,7 @@ class ChartPainter extends CustomPainter {
243258 // Vertical approach
244259// canvas.translate(startX + 25, startY - 2);
245260// canvas.skew(0 * pi / 180, -theta);
246- TextSpan span = new TextSpan (style: new TextStyle (color: Color .fromARGB (255 , 255 , 255 , 255 ), fontSize: 12 ), text: dataToPlot[i].label.toUpperCase ());
247- TextPainter tp = new TextPainter (text: span, textAlign: TextAlign .left, textDirection: TextDirection .ltr);
248- tp.layout ();
261+ TextPainter tp = labelPainter[i];
249262 tp.paint (canvas, new Offset (0 , 0 ));
250263 canvas.restore ();
251264 }
0 commit comments