@@ -192,14 +192,16 @@ export class PlotXY extends React.Component<PlotXYProps, PlotXYState> {
192192 if ( ! paramDef ) {
193193 return null ;
194194 }
195+ if ( paramDef . type === ParamType . TIMESTAMP ) {
196+ return null ;
197+ }
195198 if ( paramDef . ticks_format ) {
196199 return d3 . format ( paramDef . ticks_format ) ;
197200 }
198201 const isNumericLike =
199202 paramDef . type === ParamType . NUMERIC ||
200203 paramDef . type === ParamType . NUMERICLOG ||
201- paramDef . type === ParamType . NUMERICPERCENTILE ||
202- paramDef . type === ParamType . TIMESTAMP ;
204+ paramDef . type === ParamType . NUMERICPERCENTILE ;
203205 if ( ! isNumericLike || typeof scale . domain !== "function" ) {
204206 return null ;
205207 }
@@ -215,6 +217,28 @@ export class PlotXY extends React.Component<PlotXYProps, PlotXYState> {
215217 }
216218 return d3 . format ( ".3~e" ) ;
217219 }
220+ function getTickValues ( param : string , scale : any , approxTickCount : number ) : any [ ] | null {
221+ const paramDef = me . props . params_def [ param ] ;
222+ if (
223+ ! paramDef ||
224+ paramDef . type !== ParamType . NUMERICLOG ||
225+ typeof scale . ticks !== "function"
226+ ) {
227+ return null ;
228+ }
229+ const ticks = scale . ticks ( approxTickCount ) ;
230+ if ( ! Array . isArray ( ticks ) ) {
231+ return null ;
232+ }
233+ const majorTicks = ticks . filter ( ( tick : number ) => {
234+ if ( ! Number . isFinite ( tick ) || tick <= 0 ) {
235+ return false ;
236+ }
237+ const lg = Math . log10 ( tick ) ;
238+ return Math . abs ( lg - Math . round ( lg ) ) < 1e-10 ;
239+ } ) ;
240+ return majorTicks . length > 1 ? majorTicks : null ;
241+ }
218242 function redraw_axis ( ) {
219243 me . svg . selectAll ( ".axis_render" ) . remove ( ) ;
220244 me . svg . selectAll ( ".brush" ) . remove ( ) ;
@@ -242,6 +266,10 @@ export class PlotXY extends React.Component<PlotXYProps, PlotXYState> {
242266 ] ) ;
243267 const xTickFormatter = getTickFormatter ( me . state . axis_x , x_scale ) ;
244268 const yTickFormatter = getTickFormatter ( me . state . axis_y , y_scale ) ;
269+ const yTickCount = 1 + me . state . height / 40 ;
270+ const xTickCount = 1 + me . state . width / 80 ;
271+ const xTickValues = getTickValues ( me . state . axis_x , x_scale , xTickCount ) ;
272+ const yTickValues = getTickValues ( me . state . axis_y , y_scale , yTickCount ) ;
245273 zoom_brush = d3
246274 . brush ( )
247275 . extent ( [
@@ -256,7 +284,8 @@ export class PlotXY extends React.Component<PlotXYProps, PlotXYState> {
256284 . call (
257285 d3
258286 . axisLeft ( y_scale )
259- . ticks ( 1 + me . state . height / 40 )
287+ . ticks ( yTickCount )
288+ . tickValues ( yTickValues as any )
260289 . tickFormat ( yTickFormatter as any )
261290 . tickSizeInner ( margin . left + margin . right - me . state . width ) ,
262291 )
@@ -289,7 +318,8 @@ export class PlotXY extends React.Component<PlotXYProps, PlotXYState> {
289318 . call (
290319 d3
291320 . axisBottom ( x_scale )
292- . ticks ( 1 + me . state . width / 80 )
321+ . ticks ( xTickCount )
322+ . tickValues ( xTickValues as any )
293323 . tickFormat ( xTickFormatter as any )
294324 . tickSizeInner ( margin . bottom + margin . top - me . state . height ) ,
295325 )
0 commit comments