Skip to content

Commit

Permalink
Finish separating out readout texts in accordionBox, see: #153
Browse files Browse the repository at this point in the history
  • Loading branch information
marlitas committed May 2, 2023
1 parent b5bc622 commit ccfb01b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 20 deletions.
2 changes: 1 addition & 1 deletion js/common/view/TopRepresentationCheckboxGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export default class TopRepresentationCheckboxGroup extends VerticalCheckboxGrou
return {
createNode: ( tandem: Tandem ) => {
return TopRepresentationCheckboxGroup.createGridBox(
new Text( CenterAndVariabilityStrings.meanAbsoluteDeviationMADStringProperty, CAVConstants.CHECKBOX_TEXT_OPTIONS ),
new Text( CenterAndVariabilityStrings.madStringProperty, CAVConstants.CHECKBOX_TEXT_OPTIONS ),
// TODO: Replace with MAD icon.
new Node( {
children: [
Expand Down
27 changes: 14 additions & 13 deletions js/variability/view/IQRNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import CenterAndVariabilityStrings from '../../CenterAndVariabilityStrings.js';
import CAVPlotNode, { CAVPlotOptions } from '../../common/view/CAVPlotNode.js';
import StrictOmit from '../../../../phet-core/js/types/StrictOmit.js';
import CAVColors from '../../common/CAVColors.js';
import Checkbox from '../../../../sun/js/Checkbox.js';
import CAVConstants from '../../common/CAVConstants.js';
import DerivedProperty from '../../../../axon/js/DerivedProperty.js';
import VariabilityReadoutText from './VariabilityReadoutText.js';

Expand All @@ -29,19 +27,22 @@ export default class IQRNode extends CAVPlotNode {
dataPointFill: CAVColors.grayDataPointFill,
...options
} );
const iqrReadoutValueProperty = new DerivedProperty( [ model.rangeValueProperty ], rangeValue => {
return rangeValue ? `${rangeValue}` : '?';
} );


if ( providedOptions.parentContext === 'accordion' ) {
const iqrReadoutValueProperty = new DerivedProperty( [ model.iqrValueProperty ], iqrValue => {
return iqrValue ? `${iqrValue}` : '?';
} );

// TODO: I think we need one of these in MadNode?
const iqrReadoutText = new VariabilityReadoutText( iqrReadoutValueProperty, CenterAndVariabilityStrings.iqrEqualsValuePatternStringProperty,
{ fill: CAVColors.meanColorProperty, tandem: options.tandem.createTandem( 'iqrReadoutText' ), visibleProperty: model.isShowingIQRProperty } );
this.addChild( iqrReadoutText );
const iqrCheckbox = new Checkbox( model.isShowingIQRProperty, new Text( CenterAndVariabilityStrings.iqrStringProperty, CAVConstants.CHECKBOX_TEXT_OPTIONS ), {
tandem: options.tandem.createTandem( 'iqrCheckbox' )
const iqrReadoutText = new VariabilityReadoutText( iqrReadoutValueProperty, CenterAndVariabilityStrings.iqrEqualsValuePatternStringProperty, {
fill: CAVColors.meanColorProperty,
visibleProperty: model.isShowingIQRProperty,
right: this.left,
y: this.centerY,
tandem: options.tandem.createTandem( 'iqrReadoutText' )
} );
this.addChild( iqrCheckbox );
this.addChild( iqrReadoutText );
}

const needAtLeastFiveKicks = new Text( CenterAndVariabilityStrings.needAtLeastFiveKicksStringProperty, {
Expand Down Expand Up @@ -242,6 +243,6 @@ export default class IQRNode extends CAVPlotNode {
model.selectedVariabilityProperty.link( updateIQRNode );
model.numberOfDataPointsProperty.link( updateIQRNode );
}
}
}

centerAndVariability.register( 'IQRNode', IQRNode );
centerAndVariability.register( 'IQRNode', IQRNode );
24 changes: 19 additions & 5 deletions js/variability/view/MADNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import CAVPlotNode, { CAVPlotOptions } from '../../common/view/CAVPlotNode.js';
import CAVConstants from '../../common/CAVConstants.js';
import StrictOmit from '../../../../phet-core/js/types/StrictOmit.js';
import CAVColors from '../../common/CAVColors.js';
import Checkbox from '../../../../sun/js/Checkbox.js';
import DerivedProperty from '../../../../axon/js/DerivedProperty.js';
import VariabilityReadoutText from './VariabilityReadoutText.js';

type SelfOptions = {
parentContext: 'accordion' | 'info';
Expand All @@ -28,10 +29,23 @@ export default class MADNode extends CAVPlotNode {
...options
} );

const madCheckbox = new Checkbox( model.isShowingMADProperty, new Text( CenterAndVariabilityStrings.madStringProperty, CAVConstants.CHECKBOX_TEXT_OPTIONS ), {
tandem: options.tandem.createTandem( 'madCheckbox' )
} );
this.addChild( madCheckbox );
if ( options.parentContext === 'accordion' ) {
const madReadoutValueProperty = new DerivedProperty( [ model.meanValueProperty ], meanValue => {
return meanValue ? `${meanValue}` : '?';
} );

const madReadoutText = new VariabilityReadoutText( madReadoutValueProperty,
CenterAndVariabilityStrings.meanEqualsValuePatternStringProperty, {
fill: CAVColors.meanColorProperty,
visibleProperty: model.isShowingMADProperty,
right: this.left,
y: this.centerY,
tandem: options.tandem.createTandem( 'rangeReadoutText' )
} );

this.addChild( madReadoutText );
}


const needAtLeastOneKickText = new Text( CenterAndVariabilityStrings.needAtLeastOneKickStringProperty, {
fontSize: 18,
Expand Down
2 changes: 1 addition & 1 deletion js/variability/view/RangeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default class RangeNode extends CAVPlotNode {
fill: CAVColors.meanColorProperty,
visibleProperty: model.isShowingRangeProperty,
right: this.left,
y: 100, // TODO: Let's find a better way to position these.
y: this.centerY,
tandem: options.tandem.createTandem( 'rangeReadoutText' )
} );

Expand Down

0 comments on commit ccfb01b

Please sign in to comment.