From 6ef2da03dab6d86c508da576090115c2f3d7dc0a Mon Sep 17 00:00:00 2001 From: zepumph Date: Fri, 26 Mar 2021 11:46:28 -0800 Subject: [PATCH] prefer Utils.toFixed when possible, https://github.com/phetsims/chipper/issues/737 --- js/demo/DemoBarPlot.js | 8 ++++---- js/demo/DemoChartCanvasNode.js | 9 +++++---- js/demo/DemoLinePlot.js | 9 +++++---- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/js/demo/DemoBarPlot.js b/js/demo/DemoBarPlot.js index d4ba0c4..17d025b 100644 --- a/js/demo/DemoBarPlot.js +++ b/js/demo/DemoBarPlot.js @@ -15,13 +15,13 @@ import Node from '../../../scenery/js/nodes/Node.js'; import Text from '../../../scenery/js/nodes/Text.js'; import VBox from '../../../scenery/js/nodes/VBox.js'; import Color from '../../../scenery/js/util/Color.js'; +import bamboo from '../bamboo.js'; import BarPlot from '../BarPlot.js'; -import ChartTransform from '../ChartTransform.js'; import ChartRectangle from '../ChartRectangle.js'; +import ChartTransform from '../ChartTransform.js'; import GridLineSet from '../GridLineSet.js'; import LabelSet from '../LabelSet.js'; import TickMarkSet from '../TickMarkSet.js'; -import bamboo from '../bamboo.js'; class DemoBarPlot extends Node { @@ -88,13 +88,13 @@ class DemoBarPlot extends Node { new TickMarkSet( chartTransform, Orientation.VERTICAL, 0.05, { edge: 'min' } ), new LabelSet( chartTransform, Orientation.VERTICAL, 0.05, { edge: 'min', - createLabel: value => new Text( value.toFixed( 2 ), { fontSize: 12 } ) + createLabel: value => new Text( Utils.toFixed( value, 2 ), { fontSize: 12 } ) } ), new TickMarkSet( chartTransform, Orientation.HORIZONTAL, Math.PI * 2, { edge: 'min' } ), new LabelSet( chartTransform, Orientation.HORIZONTAL, Math.PI * 2, { edge: 'min', - createLabel: value => new Text( ( value / Math.PI ).toFixed( 0 ) + MathSymbols.PI, { fontSize: 12 } ) + createLabel: value => new Text( Utils.toFixed( value / Math.PI, 0 ) + MathSymbols.PI, { fontSize: 12 } ) } ) ] } ); diff --git a/js/demo/DemoChartCanvasNode.js b/js/demo/DemoChartCanvasNode.js index 411fbc5..e51aef7 100644 --- a/js/demo/DemoChartCanvasNode.js +++ b/js/demo/DemoChartCanvasNode.js @@ -9,6 +9,7 @@ import NumberProperty from '../../../axon/js/NumberProperty.js'; import dotRandom from '../../../dot/js/dotRandom.js'; import Range from '../../../dot/js/Range.js'; +import Utils from '../../../dot/js/Utils.js'; import Vector2 from '../../../dot/js/Vector2.js'; import Orientation from '../../../phet-core/js/Orientation.js'; import PlusMinusZoomButtonGroup from '../../../scenery-phet/js/PlusMinusZoomButtonGroup.js'; @@ -16,14 +17,14 @@ import Node from '../../../scenery/js/nodes/Node.js'; import Text from '../../../scenery/js/nodes/Text.js'; import Color from '../../../scenery/js/util/Color.js'; import AxisNode from '../AxisNode.js'; -import ChartCanvasNode from '../ChartCanvasNode.js'; +import bamboo from '../bamboo.js'; import CanvasLinePlot from '../CanvasLinePlot.js'; -import ChartTransform from '../ChartTransform.js'; +import ChartCanvasNode from '../ChartCanvasNode.js'; import ChartRectangle from '../ChartRectangle.js'; +import ChartTransform from '../ChartTransform.js'; import GridLineSet from '../GridLineSet.js'; import LabelSet from '../LabelSet.js'; import TickMarkSet from '../TickMarkSet.js'; -import bamboo from '../bamboo.js'; class DemoChartCanvasNode extends Node { @@ -124,7 +125,7 @@ class DemoChartCanvasNode extends Node { new TickMarkSet( chartTransform, Orientation.HORIZONTAL, Math.PI / 8, { edge: 'min' } ), new LabelSet( chartTransform, Orientation.HORIZONTAL, Math.PI / 8, { edge: 'min', - createLabel: value => new Text( Math.abs( value ) < 1E-6 ? value.toFixed( 0 ) : value.toFixed( 2 ), { + createLabel: value => new Text( Math.abs( value ) < 1E-6 ? Utils.toFixed( value, 0 ) : Utils.toFixed( value, 2 ), { fontSize: 12 } ) } ), diff --git a/js/demo/DemoLinePlot.js b/js/demo/DemoLinePlot.js index f8230d8..71b435e 100644 --- a/js/demo/DemoLinePlot.js +++ b/js/demo/DemoLinePlot.js @@ -7,9 +7,10 @@ */ import NumberProperty from '../../../axon/js/NumberProperty.js'; +import SpanNode from '../../../bamboo/js/SpanNode.js'; import Range from '../../../dot/js/Range.js'; +import Utils from '../../../dot/js/Utils.js'; import Vector2 from '../../../dot/js/Vector2.js'; -import SpanNode from '../../../bamboo/js/SpanNode.js'; import Orientation from '../../../phet-core/js/Orientation.js'; import MathSymbols from '../../../scenery-phet/js/MathSymbols.js'; import PhetFont from '../../../scenery-phet/js/PhetFont.js'; @@ -17,13 +18,13 @@ import PlusMinusZoomButtonGroup from '../../../scenery-phet/js/PlusMinusZoomButt import Node from '../../../scenery/js/nodes/Node.js'; import Text from '../../../scenery/js/nodes/Text.js'; import AxisNode from '../AxisNode.js'; -import ChartTransform from '../ChartTransform.js'; +import bamboo from '../bamboo.js'; import ChartRectangle from '../ChartRectangle.js'; +import ChartTransform from '../ChartTransform.js'; import GridLineSet from '../GridLineSet.js'; import LabelSet from '../LabelSet.js'; import LinePlot from '../LinePlot.js'; import TickMarkSet from '../TickMarkSet.js'; -import bamboo from '../bamboo.js'; class DemoLinePlot extends Node { @@ -111,7 +112,7 @@ class DemoLinePlot extends Node { new TickMarkSet( chartTransform, Orientation.HORIZONTAL, Math.PI / 8, { edge: 'min' } ), new LabelSet( chartTransform, Orientation.HORIZONTAL, Math.PI / 8, { edge: 'min', - createLabel: value => new Text( Math.abs( value ) < 1E-6 ? value.toFixed( 0 ) : value.toFixed( 2 ), { + createLabel: value => new Text( Math.abs( value ) < 1E-6 ? Utils.toFixed( value, 0 ) : Utils.toFixed( value, 2 ), { fontSize: 12 } ) } ),