From 661368646a67fbab88dd2ff078e97662f6c0e443 Mon Sep 17 00:00:00 2001 From: pixelzoom Date: Fri, 21 Jul 2023 16:17:24 -0600 Subject: [PATCH] dynamically center 'No Data' in Proportions graph, https://github.com/phetsims/natural-selection/issues/319 --- js/common/view/proportions/ProportionsGraphNode.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/common/view/proportions/ProportionsGraphNode.ts b/js/common/view/proportions/ProportionsGraphNode.ts index 652b0a7d..d8a85bf5 100644 --- a/js/common/view/proportions/ProportionsGraphNode.ts +++ b/js/common/view/proportions/ProportionsGraphNode.ts @@ -169,11 +169,13 @@ export default class ProportionsGraphNode extends Node { // 'No Data', visible when we have no data to display. const noDataText = new Text( NaturalSelectionStrings.noDataStringProperty, { font: NaturalSelectionConstants.INSTRUCTIONS_FONT, - centerX: backgroundNode.centerX, - centerY: backgroundNode.top + ( backgroundNode.height / 6 ), maxWidth: 0.5 * backgroundNode.width, tandem: options.tandem.createTandem( 'noDataText' ) } ); + noDataText.boundsProperty.link( bounds => { + noDataText.centerX = backgroundNode.centerX; + noDataText.centerY = backgroundNode.top + ( backgroundNode.height / 6 ); + } ); assert && assert( !options.children, 'ProportionGraphNode sets children' ); options.children = [ backgroundNode, noDataText, content ];