Skip to content

Commit

Permalink
prefer Utils.toFixed when possible, phetsims/chipper#737
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Mar 26, 2021
1 parent 66c9047 commit 6ef2da0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
8 changes: 4 additions & 4 deletions js/demo/DemoBarPlot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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 } )
} )
]
} );
Expand Down
9 changes: 5 additions & 4 deletions js/demo/DemoChartCanvasNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,22 @@
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';
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 {

Expand Down Expand Up @@ -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
} )
} ),
Expand Down
9 changes: 5 additions & 4 deletions js/demo/DemoLinePlot.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@
*/

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';
import PlusMinusZoomButtonGroup from '../../../scenery-phet/js/PlusMinusZoomButtonGroup.js';
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 {

Expand Down Expand Up @@ -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
} )
} ),
Expand Down

0 comments on commit 6ef2da0

Please sign in to comment.