Skip to content

Commit

Permalink
rename GraphNodeOptions.graphHeight to chartRectangleHeight
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Mar 8, 2023
1 parent 115b0d8 commit 062adbb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
6 changes: 3 additions & 3 deletions js/common/view/GraphNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ const DEFAULT_MAX_Y = Y_ZOOM_INFO[ DEFAULT_ZOOM_LEVEL ].max; // default y-range

type SelfOptions = {

// height of the graph, in view coordinates
graphHeight: number;
// height of the ChartRectangle, in view coordinates
chartRectangleHeight: number;

// options to the bamboo ChartRectangle
chartRectangleOptions?: PickOptional<ChartRectangleOptions, 'fill' | 'stroke'>;
Expand Down Expand Up @@ -178,7 +178,7 @@ export default class GraphNode extends Node {
// chart transform for the graph
this.chartTransform = new ChartTransform( {
viewWidth: CalculusGrapherConstants.GRAPH_VIEW_WIDTH,
viewHeight: options.graphHeight,
viewHeight: options.chartRectangleHeight,
modelXRange: CalculusGrapherConstants.CURVE_X_RANGE,
modelYRange: new Range( -DEFAULT_MAX_Y, DEFAULT_MAX_Y )
} );
Expand Down
6 changes: 3 additions & 3 deletions js/common/view/GraphSetsAnimator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ export default class GraphSetsAnimator {
* @param graphSetNode - parent Node for the GraphNodes
* @param oldGraphNodes - the current children of graphSetNode, null if it has no children
* @param newGraphNodes - the new children of graphSetNode
* @param graphHeight - the height of one GraphNode's ChartRectangle
* @param chartRectangleHeight - the height of one GraphNode's ChartRectangle
* @param ySpacing - the vertical spacing between GraphNode instances
* @param [endCallback] - called when animation has completed
*/
public changeGraphSets( graphSetNode: Node,
oldGraphNodes: GraphNode[] | null,
newGraphNodes: GraphNode[],
graphHeight: number,
chartRectangleHeight: number,
ySpacing: number,
endCallback?: () => void ): void {

Expand All @@ -93,7 +93,7 @@ export default class GraphSetsAnimator {
const x = newGraphNodes[ 0 ].x;
const yEndCoordinates = [ 0 ];
for ( let i = 1; i < newGraphNodes.length; i++ ) {
yEndCoordinates.push( yEndCoordinates[ i - 1 ] + graphHeight + ySpacing );
yEndCoordinates.push( yEndCoordinates[ i - 1 ] + chartRectangleHeight + ySpacing );
}

// Move immediately to the new state if:
Expand Down
16 changes: 9 additions & 7 deletions js/common/view/GraphsNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export default class GraphsNode extends Node {
// The parent for all GraphNode instances that are part model.graphSetProperty.value
private readonly graphSetNode: Node;

// Height of the graph, in view coordinates
private readonly graphHeight: number;
// Height of the ChartRectangles, in view coordinates
private readonly chartRectangleHeight: number;

// A reference line that extends vertically through all graphs
private readonly referenceLineNode: ReferenceLineNode;
Expand All @@ -79,14 +79,14 @@ export default class GraphsNode extends Node {
super();

// The (view) height of the graph based on the number of visible graphs.
this.graphHeight = CalculusGrapherConstants.SINGLE_GRAPH_HEIGHT / model.graphSetProperty.value.length;
this.chartRectangleHeight = CalculusGrapherConstants.SINGLE_GRAPH_HEIGHT / model.graphSetProperty.value.length;

// Creates a GraphNode instance, and instruments it if its GraphType is included in graphSets.
const createGraphNode = ( graphType: GraphType, curve: Curve ) => {
assert && assert( graphType !== GraphType.ORIGINAL, 'does not support GraphType.ORIGINAL' );

return new GraphNode( graphType, curve, model.gridVisibleProperty, {
graphHeight: this.graphHeight,
chartRectangleHeight: this.chartRectangleHeight,
tandem: GraphSet.includes( model.graphSets, graphType ) ?
options.tandem.createTandem( `${graphType.tandemNamePrefix}GraphNode` ) :
Tandem.OPT_OUT
Expand All @@ -95,7 +95,7 @@ export default class GraphsNode extends Node {

// OriginalGraphNode is always instrumented, because it should always be present.
this.originalGraphNode = new OriginalGraphNode( model, {
graphHeight: this.graphHeight,
chartRectangleHeight: this.chartRectangleHeight,
tandem: options.tandem.createTandem( 'originalGraphNode' )
} );

Expand Down Expand Up @@ -133,7 +133,8 @@ export default class GraphsNode extends Node {
const oldGraphNodes = oldGraphSet ? this.getGraphNodes( oldGraphSet ) : null;
const newGraphNodes = this.getGraphNodes( newGraphSet );

this.graphSetsAnimator.changeGraphSets( this.graphSetNode, oldGraphNodes, newGraphNodes, this.graphHeight, GRAPH_NODE_Y_SPACING );
this.graphSetsAnimator.changeGraphSets( this.graphSetNode, oldGraphNodes, newGraphNodes,
this.chartRectangleHeight, GRAPH_NODE_Y_SPACING );
} );

// Reference Line, length adjusted depending on whether values are visible.
Expand Down Expand Up @@ -198,7 +199,8 @@ export default class GraphsNode extends Node {
*/
private getChartRectanglesBottom(): number {
const numberOfGraphNodes = this.graphSetNode.getChildrenCount();
return this.getChartRectanglesTop() + ( numberOfGraphNodes * this.graphHeight ) + ( ( numberOfGraphNodes - 1 ) * GRAPH_NODE_Y_SPACING );
return this.getChartRectanglesTop() + ( numberOfGraphNodes * this.chartRectangleHeight ) +
( ( numberOfGraphNodes - 1 ) * GRAPH_NODE_Y_SPACING );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion js/common/view/OriginalGraphNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import BooleanProperty from '../../../../axon/js/BooleanProperty.js';

type SelfOptions = EmptySelfOptions;

type OriginalGraphNodeOptions = SelfOptions & PickRequired<GraphNodeOptions, 'graphHeight' | 'tandem'>;
type OriginalGraphNodeOptions = SelfOptions & PickRequired<GraphNodeOptions, 'chartRectangleHeight' | 'tandem'>;

export default class OriginalGraphNode extends GraphNode {

Expand Down

0 comments on commit 062adbb

Please sign in to comment.