@@ -59,6 +59,9 @@ class LayeredChartState extends State<LayeredChart> {
5959 double capX = cos (capTheta + pi / 2 ) * capSize;
6060 double capY = - sin (capTheta + pi / 2 ) * capSize;
6161 double capRange = capSize * cos (capTheta);
62+ double capFix = 1 - (capRange % xWidth) / capRange;
63+ capX *= capFix;
64+ capY *= capFix;
6265 double tanCapTheta = tan (capTheta);
6366 List <double > curvePoints = new List <double >(numPoints);
6467 for (int i = 0 ; i < m; i++ ) {
@@ -90,7 +93,7 @@ class LayeredChartState extends State<LayeredChart> {
9093 int k = j + 1 ;
9194 double xDist = xWidth;
9295 double capV = v;
93- while (k < numPoints && xDist < capRange) {
96+ while (k < numPoints && xDist <= capRange) {
9497 double cy = curvePoints[k] + xDist * tanCapTheta;
9598 capV = max (capV, cy);
9699 k++ ;
@@ -133,7 +136,7 @@ class LayeredChartState extends State<LayeredChart> {
133136 Widget build (BuildContext context) {
134137 return new Container (
135138 color: const Color (0xFF000020 ),
136- child: new CustomPaint (foregroundPainter: new ChartPainter (this , widget.dataToPlot, widget.milestones, 80 , 200 , 110 , 10 , 50 , 10 , 500 , widget.animationValue), child: new Container ()));
139+ child: new CustomPaint (foregroundPainter: new ChartPainter (this , widget.dataToPlot, widget.milestones, 80 , 200 , 110 , 10 , 50 , 12 , 500 , widget.animationValue), child: new Container ()));
137140 }
138141}
139142
@@ -155,6 +158,7 @@ class ChartPainter extends CustomPainter {
155158 Paint capPaint;
156159 Paint textPaint;
157160 Paint milestonePaint;
161+ Paint linePaint;
158162
159163 LayeredChartState state;
160164
@@ -168,9 +172,12 @@ class ChartPainter extends CustomPainter {
168172 textPaint = new Paint ();
169173 textPaint.color = new Color (0xFFFFFFFF );
170174 milestonePaint = new Paint ();
171- milestonePaint.color = new Color (0xAAFFFFFF );
175+ milestonePaint.color = new Color (0x40FFFFFF );
172176 milestonePaint.style = PaintingStyle .stroke;
173- milestonePaint.strokeWidth = 1 ;
177+ milestonePaint.strokeWidth = 2 ;
178+ linePaint = new Paint ();
179+ linePaint.style = PaintingStyle .stroke;
180+ linePaint.strokeWidth = 0.5 ;
174181 }
175182
176183 @override
@@ -227,10 +234,12 @@ class ChartPainter extends CustomPainter {
227234 double y2 = y1 - graphGap * (m - 0.5 );
228235 x1 += dx * 0.5 ;
229236 y1 += graphGap * 0.5 ;
237+ double textY = y1 + 5 ;
238+ double textX = x1 + 5 * tan (capTheta);
230239 canvas.drawLine (new Offset (x1, y1), new Offset (x2, y2), milestonePaint);
231240 canvas.save ();
232241 TextPainter tp = state.milestonePainter[i];
233- canvas.translate (x1 - tp.width / 2 , y1 );
242+ canvas.translate (textX - tp.width / 2 , textY );
234243 canvas.skew (capTheta * 1.0 , - theta);
235244 tp.paint (canvas, new Offset (0 , 0 ));
236245 canvas.restore ();
@@ -252,25 +261,25 @@ class ChartPainter extends CustomPainter {
252261// double scale = 0.67;
253262// canvas.scale(1, scale);
254263// canvas.skew(capTheta, -theta * 1.4);
255- canvas.skew (capTheta * 1.0 , - theta);
256264// canvas.skew(capTheta, -theta);
265+ // Horizontal approach
266+ // canvas.skew(capTheta * 1.0, -theta);
257267 // Vertical approach
258268// canvas.translate(startX + 25, startY - 2);
259- // canvas.skew(0 * pi / 180, -theta);
269+ canvas.skew (0 * pi / 180 , - theta);
260270 TextPainter tp = state.labelPainter[i];
261271 tp.paint (canvas, new Offset (0 , 0 ));
262272 canvas.restore ();
263273 }
264274
265- Paint testPaint = new Paint ();
266- testPaint.style = PaintingStyle .fill;
267- testPaint.color = new Color .fromARGB (128 , 255 , 0 , 255 );
275+ linePaint.color = capColors[i];
276+ canvas.drawLine (new Offset (startX, startY), new Offset (endX, endY), linePaint);
268277
269278 Path clipPath = new Path ();
270- clipPath.moveTo (startX, startY + 1 );
279+ clipPath.moveTo (startX - capSize , startY + 11 );
271280 clipPath.lineTo (endX, endY + 1 );
272281 clipPath.lineTo (endX, endY - graphHeight - capSize);
273- clipPath.lineTo (startX, startY - graphHeight - capSize);
282+ clipPath.lineTo (startX - capSize , startY - graphHeight - capSize);
274283 clipPath.close ();
275284 // canvas.drawPath(clipPath, testPaint);
276285 canvas.clipPath (clipPath);
0 commit comments