ChartTransform¶
Overview¶
ChartTransform defines the chart dimensions in model and view coordinate frames, and provides transform methods for moving between those coordinate frames.
@author Sam Reid (PhET Interactive Simulations)
Class ChartTransform¶
Constructor¶
new ChartTransform( providedOptions? : ChartTransformOptions )¶
Instance Methods¶
dispose()¶
forEachSpacing( axisOrientation : Orientation, spacing : number, origin : number, clippingType : ClippingType, callback : ( modelPosition: number, viewPosition: number ) => void )¶
For the axis that corresponds to Orientation, iterates over the range and performs an operation (specified by callback) at regular intervals (specified by spacing). @param axisOrientation @param spacing - the spacing (delta) between operations, in model coordinates @param origin - the origin for the operation, in model coordinates. The operation is guaranteed to occur at this position. @param clippingType - if something is clipped elsewhere, we allow slack so it doesn't disappear from view like a flicker @param callback
modelToView( axisOrientation : Orientation, value : number ) : number¶
Transforms a model coordinate {number} to a view coordinate {number} for the axis that corresponds to Orientation.
modelToViewX( x : number ) : number¶
Transforms a model coordinate {number} to a view coordinate {number} for the x axis.
modelToViewY( y : number ) : number¶
Transforms a model coordinate {number} to a view coordinate {number} for the y axis.
modelToViewXY( x : number, y : number ) : Vector2¶
Transforms model x,y coordinates to a view position.
modelToViewPosition( position : Vector2 ) : Vector2¶
Transforms a model position to a view position.
modelToViewDelta( axisOrientation : Orientation, modelDelta : number ) : number¶
Transforms a model delta {number} to a view delta {number} for the axis that corresponds to Orientation.
modelToViewDeltaX( dx : number ) : number¶
Transforms a model delta {number} to a view delta {number} for the x axis.
modelToViewDeltaY( dy : number ) : number¶
Transforms a model delta {number} to a view delta {number} for the y axis.
modelToViewDeltaXY( dx : number, dy : number ) : Vector2¶
Transforms a model delta pair of numbers to view Vector2
viewToModel( axisOrientation : Orientation, value : number ) : number¶
Converts a scalar value from view coordinates to model coordinates, along the specified axis. The inverse of modelToView.
viewToModelX( x : number ) : number¶
Convert a view position to a model position, in the horizontal direction.
viewToModelY( y : number ) : number¶
Convert a view position to a model position, in the vertical direction.
viewToModelXY( x : number, y : number ) : Vector2¶
Convert a view position to a model position, for a coordinate specified as x,y.
viewToModelPosition( position : Vector2 ) : Vector2¶
Convert a view position to a model position.
viewToModelDeltaX( dx : number ) : number¶
Convert a delta in the view to a delta in the model, in the horizontal direction.
viewToModelDeltaY( dy : number ) : number¶
Convert a delta in the view to a delta in the model, in the vertical direction.
viewToModelDelta( deltaVector : Vector2 ) : Vector2¶
Convert a delta in the view to a delta in the model, for a Vector2
setViewWidth( viewWidth : number )¶
Sets the view width.
setViewHeight( viewHeight : number )¶
Sets the view height.
setModelXRange( modelXRange : Range )¶
Sets the Range for the model's x dimension.
setModelYRange( modelYRange : Range )¶
Sets the Range for the model's y dimension.
getModelRange( axisOrientation : Orientation ) : Range¶
Gets the model range for the axis that corresponds to Orientation.
setXTransform( xTransform : Transform1 )¶
Sets the model-to-view scaling function for the x-axis.
setYTransform( yTransform : Transform1 )¶
Sets the model-to-view scaling function for the y-axis.
getSpacingBorders( axisOrientation : Orientation, spacing : number, origin : number, clippingType : ClippingType ) : Range¶
Returns a range with the min and max tick indices on the selected axis.
Instance Properties¶
changedEmitter : TEmitter¶
(readonly)
fires when some aspects of this transform changes
viewWidth : number¶
viewHeight : number¶
modelXRange : Range¶
modelYRange : Range¶
xTransform : Transform1¶
yTransform : Transform1¶
modelXRangeInverted : boolean¶
modelYRangeInverted : boolean¶
Type ChartTransformOptions¶
- viewWidth?: number
The horizontal axis is referred to as the "x" axis, though it may be used to depict another dimension, such as "time" - modelXRange?: Range
- modelXRangeInverted?: boolean
- xTransform?: Transform1
- viewHeight?: number
The vertical axis is referred to as the "y" axis, though it may be used to depict another dimension such as "width" - modelYRange?: Range
- modelYRangeInverted?: boolean
- yTransform?: Transform1
Source Code¶
See the source for ChartTransform.ts in the bamboo repository.