From 3a1c2b55e033d3c8c70f06e2573b9b4ac68dcecb Mon Sep 17 00:00:00 2001 From: veillette Date: Fri, 8 Jul 2016 15:07:11 -0400 Subject: [PATCH] use view bounds methods for clip area and rectangle --- js/curve-fitting/view/GraphAreaNode.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/js/curve-fitting/view/GraphAreaNode.js b/js/curve-fitting/view/GraphAreaNode.js index a4637cc..44d7fbb 100644 --- a/js/curve-fitting/view/GraphAreaNode.js +++ b/js/curve-fitting/view/GraphAreaNode.js @@ -38,11 +38,15 @@ define( function( require ) { * @constructor */ function GraphAreaNode( curve, orderOfFitProperty, areResidualsVisibleProperty, graphModelBounds, modelViewTransform, options ) { - var graphViewBounds = modelViewTransform.modelToViewBounds( graphModelBounds ); + + Node.call( this, options ); - // add white background - this.addChild( new Rectangle( graphViewBounds.minX, graphViewBounds.minY, graphViewBounds.width, graphViewBounds.height, { + // determine the graph are bounds in the view + var graphViewBounds = modelViewTransform.modelToViewBounds( graphModelBounds ); + + // create and add white background + this.addChild( new Rectangle.bounds( graphViewBounds, { fill: 'white', lineWidth: 2, stroke: 'rgb( 214, 223, 226 )' @@ -79,7 +83,7 @@ define( function( require ) { axisShape.lineTo( graphViewBounds.centerX + TICK_LENGTH, graphViewBounds.maxY - AXIS_OPTIONS.lineWidth / 2 ); // add clip area - this.clipArea = Shape.rect( graphViewBounds.minX, graphViewBounds.minY, graphViewBounds.width, graphViewBounds.height ); + this.clipArea = Shape.bounds( graphViewBounds ); var curvePath = new Path( null, { stroke: 'black', lineWidth: 2 } ); this.addChild( curvePath ); @@ -105,7 +109,7 @@ define( function( require ) { //update curve view if ( orderOfFit === 1 ) { curveShape.moveTo( xMin, c * xMin + d ); - curveShape.lineTo( xMax, +c * xMax + d ); + curveShape.lineTo( xMax, c * xMax + d ); curvePath.setShape( modelViewTransform.modelToViewShape( curveShape ) ); } else { @@ -122,7 +126,7 @@ define( function( require ) { points.forEach( function( point ) { if ( orderOfFit ) { residualsShape.moveToPoint( point.position ); - residualsShape.lineTo( point.position.x, a * Math.pow( point.position.x, 3 ) + b * Math.pow( point.position.x, 2 ) + c * point.position.x + d ); + residualsShape.verticalLineTo( a * Math.pow( point.position.x, 3 ) + b * Math.pow( point.position.x, 2 ) + c * point.position.x + d ); } } ); residualsPath.setShape( modelViewTransform.modelToViewShape( residualsShape ) );