From 9200659d1ce27189fed6e46858a6a693af879851 Mon Sep 17 00:00:00 2001 From: Sam Reid Date: Fri, 20 Dec 2024 15:15:15 -0700 Subject: [PATCH] Set interceptOffset to 0, https://github.com/phetsims/least-squares-regression/issues/92 --- js/least-squares-regression/model/Graph.ts | 3 +-- .../model/LeastSquaresRegressionModel.ts | 1 - js/least-squares-regression/view/GraphNode.ts | 3 +-- .../view/LeastSquaresRegressionScreenView.ts | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/js/least-squares-regression/model/Graph.ts b/js/least-squares-regression/model/Graph.ts index 7141495..9c3d00c 100644 --- a/js/least-squares-regression/model/Graph.ts +++ b/js/least-squares-regression/model/Graph.ts @@ -49,7 +49,7 @@ export default class Graph { // Factors for slope and intercept conversions public slopeFactor!: number; public interceptFactor!: number; - public interceptOffset!: number; + public readonly interceptOffset = 0; // Statistical fields private averageOfSumOfSquaresXX!: number; @@ -128,7 +128,6 @@ export default class Graph { public setGraphDomain( xRange: Range, yRange: Range ): void { this.slopeFactor = ( yRange.max - yRange.min ) / ( xRange.max - xRange.min ) / ( this.bounds.height / this.bounds.width ); this.interceptFactor = ( yRange.max - yRange.min ) / this.bounds.height; - this.interceptOffset = ( yRange.min ); } /** diff --git a/js/least-squares-regression/model/LeastSquaresRegressionModel.ts b/js/least-squares-regression/model/LeastSquaresRegressionModel.ts index fe24e92..6cd8464 100644 --- a/js/least-squares-regression/model/LeastSquaresRegressionModel.ts +++ b/js/least-squares-regression/model/LeastSquaresRegressionModel.ts @@ -115,7 +115,6 @@ export default class LeastSquaresRegressionModel { this.graph.setGraphDomain( selectedDataSet.xRange, selectedDataSet.yRange ); // Populate the dataPoints array - if ( selectedDataSet === DataSet.CUSTOM ) { // use the savedCustomDataPoints to populate the dataPoints array diff --git a/js/least-squares-regression/view/GraphNode.ts b/js/least-squares-regression/view/GraphNode.ts index 3f7f93d..624370a 100644 --- a/js/least-squares-regression/view/GraphNode.ts +++ b/js/least-squares-regression/view/GraphNode.ts @@ -37,8 +37,7 @@ export default class GraphNode extends Node { const myLineBoundaryPoints = graph.getBoundaryPoints( graph.slope( graph.angleProperty.value ), graph.interceptProperty.value ); this.myLine = new Line( modelViewTransform.modelToViewPosition( myLineBoundaryPoints.point1 ), - modelViewTransform.modelToViewPosition( myLineBoundaryPoints.point2 ), - { + modelViewTransform.modelToViewPosition( myLineBoundaryPoints.point2 ), { stroke: LeastSquaresRegressionConstants.MY_LINE_COLOR.BASE_COLOR, lineWidth: LeastSquaresRegressionConstants.LINE_WIDTH } ); diff --git a/js/least-squares-regression/view/LeastSquaresRegressionScreenView.ts b/js/least-squares-regression/view/LeastSquaresRegressionScreenView.ts index 9e0d202..cb5ea2d 100644 --- a/js/least-squares-regression/view/LeastSquaresRegressionScreenView.ts +++ b/js/least-squares-regression/view/LeastSquaresRegressionScreenView.ts @@ -94,7 +94,7 @@ export default class LeastSquaresRegressionScreenView extends ScreenView { resize: false }, panelOptions ) ); - // Create the "My Line" Control Panel (located to the left of the graph) + // Create the "My Line" Control Panel (located to the right of the graph) const myLineControlPanel = new MyLineControlPanel( model.graph, model.dataPointsAddedEmitter, panelOptions ); // Create the Graph Node which is responsible for 'My Line', 'Best Fit Line' and the Residuals representation