@@ -82,21 +82,33 @@ class TF3Painter extends TH2Painter {
8282 gr = fp ?. getGrFuncs ( this . second_x , this . second_y ) ;
8383 let xmin = func . fXmin , xmax = func . fXmax ,
8484 ymin = func . fYmin , ymax = func . fYmax ,
85- zmin = func . fZmin , zmax = func . fZmax ;
86-
87- if ( gr ?. zoom_xmin !== gr ?. zoom_xmax ) {
88- xmin = Math . min ( xmin , gr . zoom_xmin ) ;
89- xmax = Math . max ( xmax , gr . zoom_xmax ) ;
85+ zmin = func . fZmin , zmax = func . fZmax ,
86+ npx = Math . max ( func . fNpx , 20 ) ,
87+ npy = Math . max ( func . fNpy , 20 ) ,
88+ npz = Math . max ( func . fNpz , 20 ) ;
89+
90+ if ( gr ?. zoom_xmin !== gr ?. zoom_xmax ) {
91+ const dx = ( xmax - xmin ) / npx ;
92+ if ( ( xmin < gr . zoom_xmin ) && ( gr . zoom_xmin < xmax ) )
93+ xmin = Math . max ( xmin , gr . zoom_xmin - dx ) ;
94+ if ( ( xmin < gr . zoom_xmax ) && ( gr . zoom_xmax < xmax ) )
95+ xmax = Math . min ( xmax , gr . zoom_xmax + dx ) ;
9096 }
9197
92- if ( gr ?. zoom_ymin !== gr ?. zoom_ymax ) {
93- ymin = Math . min ( ymin , gr . zoom_ymin ) ;
94- ymax = Math . max ( ymax , gr . zoom_ymax ) ;
98+ if ( gr ?. zoom_ymin !== gr ?. zoom_ymax ) {
99+ const dy = ( ymax - ymin ) / npy ;
100+ if ( ( ymin < gr . zoom_ymin ) && ( gr . zoom_ymin < ymax ) )
101+ ymin = Math . max ( ymin , gr . zoom_ymin - dy ) ;
102+ if ( ( ymin < gr . zoom_ymax ) && ( gr . zoom_ymax < ymax ) )
103+ ymax = Math . min ( ymax , gr . zoom_ymax + dy ) ;
95104 }
96105
97- if ( gr ?. zoom_zmin !== gr ?. zoom_zmax ) {
98- zmin = Math . min ( zmin , gr . zoom_zmin ) ;
99- zmax = Math . max ( zmax , gr . zoom_zmax ) ;
106+ if ( gr ?. zoom_zmin !== gr ?. zoom_zmax ) {
107+ // no need for dz here - TH2 is not binned over Z axis
108+ if ( ( zmin < gr . zoom_zmin ) && ( gr . zoom_zmin < zmax ) )
109+ zmin = gr . zoom_zmin ;
110+ if ( ( zmin < gr . zoom_zmax ) && ( gr . zoom_zmax < zmax ) )
111+ zmax = gr . zoom_zmax ;
100112 }
101113
102114 const ensureBins = ( nx , ny ) => {
@@ -120,9 +132,6 @@ class TF3Painter extends TH2Painter {
120132 delete this . _fail_eval ;
121133
122134 if ( ! this . _use_saved_points ) {
123- const npx = Math . max ( func . fNpx , 20 ) ,
124- npy = Math . max ( func . fNpy , 20 ) ,
125- npz = Math . max ( func . fNpz , 20 ) ;
126135 let iserror = false ;
127136
128137 if ( ! func . evalPar && ! proivdeEvalPar ( func ) )
@@ -170,12 +179,12 @@ class TF3Painter extends TH2Painter {
170179 xmin = func . fSave [ nsave ] ; xmax = func . fSave [ nsave + 1 ] ;
171180 ymin = func . fSave [ nsave + 2 ] ; ymax = func . fSave [ nsave + 3 ] ;
172181 zmin = func . fSave [ nsave + 4 ] ; zmax = func . fSave [ nsave + 5 ] ;
173- const npx = Math . round ( func . fSave [ nsave + 6 ] ) ,
174- npy = Math . round ( func . fSave [ nsave + 7 ] ) ,
175- npz = Math . round ( func . fSave [ nsave + 8 ] ) ,
176- // dx = (xmax - xmin) / npx,
177- // dy = (ymax - ymin) / npy,
178- dz = ( zmax - zmin ) / npz ;
182+ npx = Math . round ( func . fSave [ nsave + 6 ] ) ;
183+ npy = Math . round ( func . fSave [ nsave + 7 ] ) ;
184+ npz = Math . round ( func . fSave [ nsave + 8 ] ) ;
185+ // dx = (xmax - xmin) / npx,
186+ // dy = (ymax - ymin) / npy,
187+ const dz = ( zmax - zmin ) / npz ;
179188
180189 ensureBins ( npx + 1 , npy + 1 ) ;
181190
0 commit comments