@@ -36,6 +36,12 @@ export namespace PrivateDataTypes {
3636 } ;
3737 }
3838
39+ export const defaultRange = {
40+ linear : [ - Infinity , Infinity ] ,
41+ parametric : [ 0 , 2 * Math . PI ] ,
42+ polar : [ - Math . PI , Math . PI ] ,
43+ } as const ;
44+
3945 /** Normal functions: y=f(x) */
4046 export type Linear = Function & {
4147 fnType : "linear" ;
@@ -133,8 +139,10 @@ export function toPublicData(data: PrivateData): FunctionPlotDatum {
133139 ...data ,
134140 range : ( ( ) : [ number , number ] | undefined => {
135141 if ( ! ( "range" in data ) ) return undefined ;
136- let [ v1 , v2 ] = data . range ;
137- if ( v1 === - Infinity && v2 === Infinity ) return undefined ;
142+ let [ min , max ] = data . range ;
143+ let [ defaultMin , defaultMax ] =
144+ PrivateDataTypes . defaultRange [ data . fnType ] ;
145+ if ( min === defaultMin && max === defaultMax ) return undefined ;
138146 return data . range ;
139147 } ) ( ) ,
140148 derivative : ( ( ) => {
@@ -222,7 +230,7 @@ export function toPrivateData(input: Object) {
222230 } ) ,
223231 skipTip : false ,
224232 nSamples : undefined ,
225- range : ( ) => [ - Infinity , Infinity ] as [ number , number ] ,
233+ range : ( ) => [ ... PrivateDataTypes . defaultRange . linear ] ,
226234 ...getFunctionGlobals ( ) ,
227235 }
228236 ) ;
@@ -239,7 +247,7 @@ export function toPrivateData(input: Object) {
239247 graphType : "polyline" ,
240248 r : "" ,
241249 nSamples : undefined ,
242- range : ( ) => [ - Infinity , Infinity ] as [ number , number ] ,
250+ range : ( ) => [ ... PrivateDataTypes . defaultRange . polar ] ,
243251 ...getFunctionGlobals ( ) ,
244252 } ) ;
245253 case "parametric" :
@@ -249,7 +257,7 @@ export function toPrivateData(input: Object) {
249257 x : "" ,
250258 y : "" ,
251259 nSamples : undefined ,
252- range : ( ) => [ - Infinity , Infinity ] as [ number , number ] ,
260+ range : ( ) => [ ... PrivateDataTypes . defaultRange . parametric ] ,
253261 ...getFunctionGlobals ( ) ,
254262 } ) ;
255263 case "points" :
0 commit comments