Skip to content

Commit

Permalink
Use ManualConstraint to dynamically position sum label, see #90
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Dec 27, 2024
1 parent 001f5b5 commit d491a03
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Emitter from '../../../../axon/js/Emitter.js';
import Multilink from '../../../../axon/js/Multilink.js';
import TReadOnlyProperty from '../../../../axon/js/TReadOnlyProperty.js';
import ArrowNode from '../../../../scenery-phet/js/ArrowNode.js';
import { Color, Line, Node, Rectangle, Text } from '../../../../scenery/js/imports.js';
import { Color, Line, ManualConstraint, Node, Rectangle, Text } from '../../../../scenery/js/imports.js';
import leastSquaresRegression from '../../leastSquaresRegression.js';
import LeastSquaresRegressionStrings from '../../LeastSquaresRegressionStrings.js';
import LeastSquaresRegressionConstants from '../LeastSquaresRegressionConstants.js';
Expand Down Expand Up @@ -53,10 +53,12 @@ export default class SumOfSquaredResidualsChart extends Node {
// Text for the chart
const label = new Text( LeastSquaresRegressionStrings.sumStringProperty, {
font: FONT,
centerX: horizontalArrow.centerX,
top: horizontalArrow.bottom + 5,
maxWidth: 100
} );
ManualConstraint.create( this, [ label, horizontalArrow ], ( label, horizontalArrow ) => {
label.centerX = horizontalArrow.centerX;
label.top = horizontalArrow.bottom + 5;
} );
const zeroLabel = new Text( '0', { font: FONT, centerX: horizontalArrow.left, top: horizontalArrow.bottom + 5 } );

/**
Expand Down

0 comments on commit d491a03

Please sign in to comment.