diff --git a/js/least-squares-regression/model/DataSet.ts b/js/least-squares-regression/model/DataSet.ts index 297e4b4..0e1ce72 100644 --- a/js/least-squares-regression/model/DataSet.ts +++ b/js/least-squares-regression/model/DataSet.ts @@ -210,15 +210,15 @@ const heightShoe = { export default class DataSet { public constructor( - private readonly specs: { graphTitle: string; yAxisTitle: string; xAxisTitle: string; reference: string; source: string }, // TODO: better name https://github.com/phetsims/least-squares-regression/issues/94 + config: { graphTitle: string; yAxisTitle: string; xAxisTitle: string; reference: string; source: string }, public readonly yRange: Range, public readonly xRange: Range, public readonly dataXY: Array<{ x: number; y: number }>, - public readonly name = specs.graphTitle, - public readonly yAxisTitle: string = specs.yAxisTitle, - public readonly xAxisTitle: string = specs.xAxisTitle, - public readonly reference: string = specs.reference, - public readonly source: string = specs.source + public readonly name = config.graphTitle, + public readonly yAxisTitle: string = config.yAxisTitle, + public readonly xAxisTitle: string = config.xAxisTitle, + public readonly reference: string = config.reference, + public readonly source: string = config.source ) {} public static readonly CUSTOM = new DataSet( custom, new Range( 0, 20 ), new Range( 0, 20 ), [] ); diff --git a/js/least-squares-regression/view/BestFitLineControlPanel.ts b/js/least-squares-regression/view/BestFitLineControlPanel.ts index 66d1189..42f3b7b 100644 --- a/js/least-squares-regression/view/BestFitLineControlPanel.ts +++ b/js/least-squares-regression/view/BestFitLineControlPanel.ts @@ -16,7 +16,6 @@ import Panel from '../../../../sun/js/Panel.js'; import leastSquaresRegression from '../../leastSquaresRegression.js'; import LeastSquaresRegressionStrings from '../../LeastSquaresRegressionStrings.js'; import LeastSquaresRegressionConstants from '../LeastSquaresRegressionConstants.js'; -import DataPoint from '../model/DataPoint.js'; import Graph from '../model/Graph.js'; import EquationNode from './EquationNode.js'; import SumOfSquaredResidualsChart from './SumOfSquaredResidualsChart.js'; @@ -38,13 +37,11 @@ export default class BestFitLineControlPanel extends AccordionBox { /** * @param graph - Model of the graph - * @param dataPoints - Array of data points * @param dataPointsAddedEmitter - Emitter that signals when data points are added in bulk * @param providedOptions - Optional customization options */ public constructor( private readonly graph: Graph, - dataPoints: DataPoint[], // TODO: unused? https://github.com/phetsims/least-squares-regression/issues/94 dataPointsAddedEmitter: Emitter, providedOptions?: AccordionBoxOptions ) { diff --git a/js/least-squares-regression/view/DataPointCreatorNode.ts b/js/least-squares-regression/view/DataPointCreatorNode.ts index 4fb4c6b..affe879 100644 --- a/js/least-squares-regression/view/DataPointCreatorNode.ts +++ b/js/least-squares-regression/view/DataPointCreatorNode.ts @@ -20,12 +20,12 @@ export default class DataPointCreatorNode extends Node { /** * @param addDataPointToModel - A function for adding the created DataPoint to the model. * @param modelViewTransform - The ModelViewTransform2 instance for coordinate transformations. - * @param options - Optional customization options. + * @param providedOptions - Optional customization options. */ public constructor( addDataPointToModel: ( dataPoint: DataPoint ) => void, modelViewTransform: ModelViewTransform2, - options?: NodeOptions // TODO: rename to providedOptions https://github.com/phetsims/least-squares-regression/issues/94 + providedOptions?: NodeOptions ) { super( { cursor: 'pointer' } ); @@ -87,7 +87,7 @@ export default class DataPointCreatorNode extends Node { } ) ); // Pass options through to parent. - this.mutate( options ); + this.mutate( providedOptions ); } } diff --git a/js/least-squares-regression/view/DataPointNode.ts b/js/least-squares-regression/view/DataPointNode.ts index 57e234b..61d7bc8 100644 --- a/js/least-squares-regression/view/DataPointNode.ts +++ b/js/least-squares-regression/view/DataPointNode.ts @@ -15,11 +15,6 @@ import DataPoint from '../model/DataPoint.js'; export default class DataPointNode extends Node { - /** - * A function to dispose of the DataPointNode's listeners. - */ - private readonly disposeDataPointNode: () => void; - /** * @param dataPoint - The DataPoint model instance. * @param representation - The visual representation Node of the DataPoint. @@ -40,18 +35,9 @@ export default class DataPointNode extends Node { // Move this node as the model representation moves dataPoint.positionProperty.link( centerPositionListener ); - // TODO: use disposeEmitter, see https://github.com/phetsims/least-squares-regression/issues/94 - this.disposeDataPointNode = () => { + this.disposeEmitter.addListener( () => { dataPoint.positionProperty.unlink( centerPositionListener ); - }; - } - - /** - * Releases references and listeners to prevent memory leaks. - */ - public override dispose(): void { - this.disposeDataPointNode(); - super.dispose(); + } ); } } diff --git a/js/least-squares-regression/view/DataSetComboBox.ts b/js/least-squares-regression/view/DataSetComboBox.ts index b8ccd17..f2bd813 100644 --- a/js/least-squares-regression/view/DataSetComboBox.ts +++ b/js/least-squares-regression/view/DataSetComboBox.ts @@ -8,7 +8,7 @@ import Property from '../../../../axon/js/Property.js'; import { Node, Text } from '../../../../scenery/js/imports.js'; -import ComboBox, { ComboBoxItem, ComboBoxOptions } from '../../../../sun/js/ComboBox.js'; +import ComboBox, { ComboBoxItem } from '../../../../sun/js/ComboBox.js'; import leastSquaresRegression from '../../leastSquaresRegression.js'; import LeastSquaresRegressionConstants from '../LeastSquaresRegressionConstants.js'; import DataSet from '../model/DataSet.js'; @@ -20,14 +20,12 @@ export default class DataSetComboBox extends ComboBox { * @param dataSets - Array of DataSets to populate the combo box. * @param dataSetListParent - The parent node for the combo box list. * @param maxTextWidth - Maximum width of text in the combo box items. - * @param providedOptions - Optional customization options. */ public constructor( selectedDataSetProperty: Property, dataSets: DataSet[], dataSetListParent: Node, - maxTextWidth: number, - providedOptions?: ComboBoxOptions // TODO: delete unused, see https://github.com/phetsims/least-squares-regression/issues/94 + maxTextWidth: number ) { // Create the ComboBoxItem array by mapping DataSets to ComboBoxItems const items = dataSets.map( dataSet => createItem( dataSet, maxTextWidth ) ); diff --git a/js/least-squares-regression/view/EquationNode.ts b/js/least-squares-regression/view/EquationNode.ts index 2732df5..09d6f0c 100644 --- a/js/least-squares-regression/view/EquationNode.ts +++ b/js/least-squares-regression/view/EquationNode.ts @@ -26,7 +26,7 @@ type SelfOptions = { type EquationNodeOptions = SelfOptions & NodeOptions; // TODO: Better name, see https://github.com/phetsims/least-squares-regression/issues/94 -type NumberString = { +type NumberStringData = { absoluteNumber: string; optionalSign: string; sign: string; @@ -163,7 +163,7 @@ export default class EquationNode extends Node { * @param number - The number to convert. * @returns An object containing the absolute number string, optional sign, and sign. */ - private numberToString( number: number ): NumberString { + private numberToString( number: number ): NumberStringData { const isNegative = parseFloat( this.roundNumber( number ) ) < 0; const signString = isNegative ? MathSymbols.MINUS : MathSymbols.PLUS; const optionalSignString = isNegative ? MathSymbols.MINUS : ' '; diff --git a/js/least-squares-regression/view/LeastSquaresRegressionScreenView.ts b/js/least-squares-regression/view/LeastSquaresRegressionScreenView.ts index 7b04d84..9abbc7e 100644 --- a/js/least-squares-regression/view/LeastSquaresRegressionScreenView.ts +++ b/js/least-squares-regression/view/LeastSquaresRegressionScreenView.ts @@ -92,10 +92,10 @@ export default class LeastSquaresRegressionScreenView extends ScreenView { yMargin: 10 }; // Create the "Best Fit Line" Control Panel (located to the right of the graph) - const bestFitLineControlPanel = new BestFitLineControlPanel( model.graph, model.dataPoints, model.dataPointsAddedEmitter, panelOptions ); + const bestFitLineControlPanel = new BestFitLineControlPanel( model.graph, model.dataPointsAddedEmitter, panelOptions ); // Create the "My Line" Control Panel (located to the left of the graph) - const myLineControlPanel = new MyLineControlPanel( model.graph, model.dataPoints, model.dataPointsAddedEmitter, panelOptions ); + 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 const graphNode = new GraphNode( model.graph, viewGraphBounds, modelViewTransform ); diff --git a/js/least-squares-regression/view/MyLineControlPanel.ts b/js/least-squares-regression/view/MyLineControlPanel.ts index 8792643..7e7be52 100644 --- a/js/least-squares-regression/view/MyLineControlPanel.ts +++ b/js/least-squares-regression/view/MyLineControlPanel.ts @@ -19,7 +19,6 @@ import VSlider from '../../../../sun/js/VSlider.js'; import leastSquaresRegression from '../../leastSquaresRegression.js'; import LeastSquaresRegressionStrings from '../../LeastSquaresRegressionStrings.js'; import LeastSquaresRegressionConstants from '../LeastSquaresRegressionConstants.js'; -import DataPoint from '../model/DataPoint.js'; import Graph from '../model/Graph.js'; import EquationNode from './EquationNode.js'; import SumOfSquaredResidualsChart from './SumOfSquaredResidualsChart.js'; @@ -45,8 +44,7 @@ const MAX_WIDTH = 150; export default class MyLineControlPanel extends Panel { public readonly sumOfSquaredResiduals: SumOfSquaredResidualsChart; - // TODO: unused param, see https://github.com/phetsims/least-squares-regression/issues/94 - public constructor( graph: Graph, dataPoints: DataPoint[], dataPointsAddedEmitter: Emitter, options: IntentionalAny ) { + public constructor( graph: Graph, dataPointsAddedEmitter: Emitter, options: IntentionalAny ) { // Create a mutable equation y = {1} x + {2} , the slope and intercept are updated later // max width determined empirically, and there are 6 elements that make up the equation node diff --git a/js/least-squares-regression/view/ResidualLineAndSquareNode.ts b/js/least-squares-regression/view/ResidualLineAndSquareNode.ts index a04bcec..033ba9d 100644 --- a/js/least-squares-regression/view/ResidualLineAndSquareNode.ts +++ b/js/least-squares-regression/view/ResidualLineAndSquareNode.ts @@ -86,7 +86,7 @@ export default class ResidualLineAndSquareNode extends Node { } /** - * Was dispose, see https://github.com/phetsims/scenery/issues/601 + * This used to be dispose() before we switched to Poolable, see https://github.com/phetsims/scenery/issues/601 */ public release(): void { // unlink listeners