@@ -38,7 +38,6 @@ class LayeredChartState extends State<LayeredChart> {
3838 void buildPaths (Size size, List <DataSeries > dataToPlot, List <WeekLabel > milestones, int numPoints, double graphGap, double margin, double capTheta, double capSize) {
3939 double screenRatio = size.width / size.height;
4040 double degrees = MathUtils .clampedMap (screenRatio, 0.5 , 2.5 , 50 , 5 );
41- print ("Ratio: ${screenRatio }, Degrees: ${degrees }" );
4241 theta = pi* degrees/ 180 ;
4342 graphHeight = MathUtils .clampedMap (screenRatio, 0.5 , 2.5 , 50 , 150 );
4443
@@ -64,7 +63,6 @@ class LayeredChartState extends State<LayeredChart> {
6463 double endY = startY - (endX - startX) * tan (theta);
6564 double xWidth = (endX - startX) / numPoints;
6665 double capRangeX = capSize * cos (capTheta);
67- double capFix = 1 - (capRangeX % xWidth) / capRangeX;
6866 double tanCapTheta = tan (capTheta);
6967 List <double > curvePoints = new List <double >(numPoints);
7068 for (int i = 0 ; i < m; i++ ) {
@@ -150,6 +148,23 @@ class LayeredChartState extends State<LayeredChart> {
150148
151149class ChartPainter extends CustomPainter {
152150
151+ static List <Color > colors = [
152+ Colors .red[900 ],
153+ new Color (0xffc4721a ),
154+ Colors .lime[900 ],
155+ Colors .green[900 ],
156+ Colors .blue[900 ],
157+ Colors .purple[900 ],
158+ ];
159+ static List <Color > capColors = [
160+ Colors .red[500 ],
161+ Colors .amber[500 ],
162+ Colors .lime[500 ],
163+ Colors .green[500 ],
164+ Colors .blue[500 ],
165+ Colors .purple[500 ],
166+ ];
167+
153168 List <DataSeries > dataToPlot;
154169 List <WeekLabel > milestones;
155170
@@ -191,7 +206,6 @@ class ChartPainter extends CustomPainter {
191206
192207 @override
193208 void paint (Canvas canvas, Size size) {
194- // print("PAINTING");
195209 if (dataToPlot.length == 0 ) {
196210 return ;
197211 }
@@ -200,23 +214,6 @@ class ChartPainter extends CustomPainter {
200214 print ("Building paths, lastsize = ${state .lastSize }" );
201215 state.buildPaths (size, dataToPlot, milestones, numPoints, graphGap, margin, capTheta, capSize);
202216 }
203- // Using the 900 version of the Material color for the main color, and the 500 version for the cap
204- List <Color > colors = [
205- Colors .red[900 ],
206- new Color (0xffc4721a ),
207- Colors .lime[900 ],
208- Colors .green[900 ],
209- Colors .blue[900 ],
210- Colors .purple[900 ],
211- ];
212- List <Color > capColors = [
213- Colors .red[500 ],
214- Colors .amber[500 ],
215- Colors .lime[500 ],
216- Colors .green[500 ],
217- Colors .blue[500 ],
218- Colors .purple[500 ],
219- ];
220217 int m = dataToPlot.length;
221218 int numWeeks = dataToPlot[0 ].series.length;
222219 // How far along to draw
@@ -227,12 +224,6 @@ class ChartPainter extends CustomPainter {
227224 double endX = size.width - margin;
228225 double startY = size.height;
229226 double endY = startY - (endX - startX) * tan (state.theta);
230- // TextStyle textStyle = new TextStyle();
231- // ParagraphBuilder paragraphBuilder = new ParagraphBuilder(new ParagraphStyle(fontSize: 10));
232-
233- // paragraphBuilder.pushStyle(new TextStyle);
234- // paragraphBuilder.addText("LINES COMMITTED");
235- // Paragraph paragraph = paragraphBuilder.build();
236227 // MILESTONES
237228 {
238229 for (int i = 0 ; i < milestones.length; i++ ) {
@@ -261,28 +252,15 @@ class ChartPainter extends CustomPainter {
261252 for (int i = m - 1 ; i >= 0 ; i-- ) {
262253 canvas.save ();
263254 canvas.translate (- dx * i, - graphGap * i);
264- // canvas.drawParagraph(paragraph, new Offset(startX, startY + 5));
265255
266256 { // TEXT LABELS
267257 canvas.save ();
268- // Flat approach
269258 double textPosition = 0.2 ;
270259 double textX = MathUtils .map (textPosition, 0 , 1 , startX, endX);
271260 double textY = MathUtils .map (textPosition, 0 , 1 , startY, endY) + 5 ;
272261 canvas.translate (textX, textY);
273- // double scale = 0.67;
274- // canvas.scale(1, scale);
275- // canvas.skew(capTheta, -theta * 1.4);
276- // canvas.skew(capTheta, -theta);
277- // Horizontal approach
278- // canvas.skew(capTheta * 1.0, -theta);
279- // Vertical approach
280- // canvas.translate(startX + 25, startY - 2);
281262 TextPainter tp = state.labelPainter[i];
282- // canvas.translate(-tp.width / 2, tp.height / 2);
283- // canvas.skew(0, -state.theta + 2 * pi);
284263 canvas.skew (0 , - tan (state.theta));
285- // canvas.rotate(-state.theta);
286264 canvas.drawRect (new Rect .fromLTWH (- 1 , - 1 , tp.width + 2 , tp.height + 2 ), fillPaint);
287265 tp.paint (canvas, new Offset (0 , 0 ));
288266 canvas.restore ();
@@ -297,7 +275,6 @@ class ChartPainter extends CustomPainter {
297275 clipPath.lineTo (endX, endY - state.graphHeight - capSize);
298276 clipPath.lineTo (startX - capSize, startY - state.graphHeight - capSize);
299277 clipPath.close ();
300- // canvas.drawPath(clipPath, testPaint);
301278 canvas.clipPath (clipPath);
302279
303280 pathPaint.color = colors[i];
@@ -316,4 +293,5 @@ class ChartPainter extends CustomPainter {
316293 bool shouldRepaint (CustomPainter oldDelegate) {
317294 return true ;
318295 }
296+
319297}
0 commit comments