Skip to content

Commit

Permalink
delete unused discontinuousLinePlotOptions, narrow continuousLinePlot…
Browse files Browse the repository at this point in the history
…Options, #262
  • Loading branch information
pixelzoom committed Mar 11, 2023
1 parent f1bfddc commit b506cb0
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions js/common/view/CurveNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ import Vector2 from '../../../../dot/js/Vector2.js';
import CalculusGrapherQueryParameters from '../CalculusGrapherQueryParameters.js';
import CalculusGrapherPreferences from '../model/CalculusGrapherPreferences.js';
import DerivedProperty from '../../../../axon/js/DerivedProperty.js';
import StrictOmit from '../../../../phet-core/js/types/StrictOmit.js';
import PickOptional from '../../../../phet-core/js/types/PickOptional.js';
import PickRequired from '../../../../phet-core/js/types/PickRequired.js';
import Bounds2 from '../../../../dot/js/Bounds2.js';
import StrictOmit from '../../../../phet-core/js/types/StrictOmit.js';

// dateset types associated with LinePlot and ScatterPlot
type LinePlotDataSet = ( Vector2 | null )[];
Expand All @@ -45,9 +45,8 @@ type SelfOptions = {
// fill for discontinuous points, which should be the same as the chart or panel background
discontinuousPointsFill: TPaint;

// options propagated to LinePlots
continuousLinePlotOptions?: StrictOmit<LinePlotOptions, 'stroke'>;
discontinuousLinePlotOptions?: StrictOmit<LinePlotOptions, 'stroke'>;
// options propagated to continuousLinePlot
continuousLinePlotOptions?: PickOptional<LinePlot, 'lineWidth' | 'lineDash'>;

// boundsMethod to be used with bamboo plots. Override this where performance optimization is needed.
// See https://github.com/phetsims/calculus-grapher/issues/210 and https://github.com/phetsims/calculus-grapher/issues/226
Expand Down Expand Up @@ -82,23 +81,11 @@ export default class CurveNode extends Node {

public constructor( curve: Curve, chartTransform: ChartTransform, providedOptions: CurveNodeOptions ) {

const options = optionize<CurveNodeOptions, SelfOptions, NodeOptions>()( {
const options = optionize<CurveNodeOptions, StrictOmit<SelfOptions, 'continuousLinePlotOptions'>, NodeOptions>()( {

// SelfOptions
continuousLinePlotOptions: {
lineWidth: 2
},

discontinuousLinePlotOptions: {
lineWidth: 2,
lineDash: [ 2, 2 ],
visibleProperty: new DerivedProperty( [ CalculusGrapherPreferences.connectDiscontinuitiesProperty ],
connectDiscontinuities => connectDiscontinuities === 'dashedLine' )
},

plotBoundsMethod: 'accurate',
plotBounds: null

}, providedOptions );

super( options );
Expand All @@ -108,15 +95,19 @@ export default class CurveNode extends Node {
this.continuousLinePlot = new LinePlot( chartTransform, this.getContinuousLinePlotDataSet(),
combineOptions<LinePlotOptions>( {
stroke: options.stroke,
lineWidth: 2,
boundsMethod: options.plotBoundsMethod
}, options.continuousLinePlotOptions ) );
this.addChild( this.continuousLinePlot );

this.discontinuousLinePlot = new LinePlot( chartTransform, this.getDiscontinuousLinePlotDataSet(),
combineOptions<LinePlotOptions>( {
stroke: options.stroke,
boundsMethod: options.plotBoundsMethod
}, options.discontinuousLinePlotOptions ) );
this.discontinuousLinePlot = new LinePlot( chartTransform, this.getDiscontinuousLinePlotDataSet(), {
stroke: options.stroke,
lineWidth: 2,
lineDash: [ 2, 2 ],
boundsMethod: options.plotBoundsMethod,
visibleProperty: new DerivedProperty( [ CalculusGrapherPreferences.connectDiscontinuitiesProperty ],
connectDiscontinuities => connectDiscontinuities === 'dashedLine' )
} );
this.addChild( this.discontinuousLinePlot );

this.discontinuousPointsScatterPlot = new ScatterPlot( chartTransform, this.getDiscontinuousPointsScatterPlotDataSet(), {
Expand Down

0 comments on commit b506cb0

Please sign in to comment.