diff --git a/js/common/view/CAVPlotNode.ts b/js/common/view/CAVPlotNode.ts index 9f98497b..b771dd10 100644 --- a/js/common/view/CAVPlotNode.ts +++ b/js/common/view/CAVPlotNode.ts @@ -44,7 +44,7 @@ export default class CAVPlotNode extends Node { const numberLinePositionY = 127; - // Empirically determined + // View size of a data point in the chart const dataPointHeight = 17; // Coordinates here are somewhat unusual, since x dimension is based off of meters, and y dimension is based off of @@ -57,6 +57,7 @@ export default class CAVPlotNode extends Node { const numberLineNode = new NumberLineNode( sceneModel.meanValueProperty, + modelViewTransform, model instanceof MeanAndMedianModel ? model.isShowingTopMeanProperty : new BooleanProperty( false ), sceneModel.dataRangeProperty, { color: 'black', diff --git a/js/common/view/CAVScreenView.ts b/js/common/view/CAVScreenView.ts index 2ea01ca0..cb9de9b3 100644 --- a/js/common/view/CAVScreenView.ts +++ b/js/common/view/CAVScreenView.ts @@ -65,10 +65,13 @@ export default class CAVScreenView extends ScreenView { public constructor( model: CAVModel, providedOptions: CAVScreenViewOptions ) { const options = optionize()( {}, providedOptions ); + // View size of a soccer ball + const objectHeight = 41; + // The ground is at y=0 const modelViewTransform = ModelViewTransform2.createRectangleInvertedYMapping( - new Bounds2( CAVConstants.PHYSICAL_RANGE.min, 0, CAVConstants.PHYSICAL_RANGE.max, CAVConstants.PHYSICAL_RANGE.getLength() ), - new Bounds2( CAVConstants.NUMBER_LINE_MARGIN_X, GROUND_POSITION_Y - CAVConstants.CHART_VIEW_WIDTH, CAVConstants.NUMBER_LINE_MARGIN_X + CAVConstants.CHART_VIEW_WIDTH, GROUND_POSITION_Y ) + new Bounds2( CAVConstants.PHYSICAL_RANGE.min, 0, CAVConstants.PHYSICAL_RANGE.max, 1 ), + new Bounds2( CAVConstants.NUMBER_LINE_MARGIN_X, GROUND_POSITION_Y - objectHeight, CAVConstants.NUMBER_LINE_MARGIN_X + CAVConstants.CHART_VIEW_WIDTH, GROUND_POSITION_Y ) ); super( options ); @@ -127,6 +130,7 @@ export default class CAVScreenView extends ScreenView { new DynamicProperty( model.selectedSceneModelProperty, { derive: 'meanValueProperty' } ), + modelViewTransform, model.isShowingPlayAreaMeanProperty, new DynamicProperty( model.selectedSceneModelProperty, { derive: 'dataRangeProperty' diff --git a/js/common/view/NumberLineNode.ts b/js/common/view/NumberLineNode.ts index 4d0a5fa2..c19e2f63 100644 --- a/js/common/view/NumberLineNode.ts +++ b/js/common/view/NumberLineNode.ts @@ -21,7 +21,6 @@ import TReadOnlyProperty from '../../../../axon/js/TReadOnlyProperty.js'; import CAVColors from '../CAVColors.js'; import Vector2 from '../../../../dot/js/Vector2.js'; import ModelViewTransform2 from '../../../../phetcommon/js/view/ModelViewTransform2.js'; -import Bounds2 from '../../../../dot/js/Bounds2.js'; import CAVConstants from '../CAVConstants.js'; import PickRequired from '../../../../phet-core/js/types/PickRequired.js'; import Multilink from '../../../../axon/js/Multilink.js'; @@ -40,6 +39,7 @@ export default class NumberLineNode extends Node { public constructor( meanValueProperty: TReadOnlyProperty, + modelViewTransform: ModelViewTransform2, isShowingMeanIndicatorProperty: TReadOnlyProperty, rangeProperty: TReadOnlyProperty, providedOptions?: NumberLineNodeOptions @@ -105,14 +105,6 @@ export default class NumberLineNode extends Node { this.addChild( rangeNode ); } - // TODO: See see https://github.com/phetsims/center-and-variability/issues/168, Can we make a 1d MVT since that's - // all that's needed here, or should this be using the same MVT as the outer MVT? Like the one that positions the number line node, - // and puts objects in the right spots. - const modelViewTransform = ModelViewTransform2.createRectangleInvertedYMapping( - new Bounds2( CAVConstants.PHYSICAL_RANGE.min, 0, CAVConstants.PHYSICAL_RANGE.max, CAVConstants.PHYSICAL_RANGE.getLength() ), - new Bounds2( 0, -CAVConstants.CHART_VIEW_WIDTH, CAVConstants.CHART_VIEW_WIDTH, CAVConstants.CHART_VIEW_WIDTH ) - ); - const meanIndicatorNode = NumberLineNode.createMeanIndicatorNode( options.includeMeanStroke, false ); this.addChild( meanIndicatorNode );