1+ /* eslint-disable prettier/prettier */
12import { antisymlog , symlog } from './mathUtils.js' ;
23
34const e10 = Math . sqrt ( 50 ) ;
@@ -8,6 +9,10 @@ const e2 = Math.sqrt(2);
89 * Nicely formatted tick steps from d3-array.
910 */
1011function tickStep ( start , stop , count ) {
12+ // fix-1
13+ if ( count <= 0 || ! Number . isFinite ( count ) ) {
14+ throw new Error ( 'Count must be a positive finite number' ) ;
15+ }
1116 const step0 = Math . abs ( stop - start ) / Math . max ( 0 , count ) ;
1217 let step1 = Math . pow ( 10 , Math . floor ( Math . log ( step0 ) / Math . LN10 ) ) ;
1318 const error = step0 / step1 ;
@@ -63,10 +68,12 @@ export function getLogTicks(start, stop, mainTickCount = 8, secondaryTickCount =
6368 const nextTick = mainTicks [ i + 1 ] ;
6469 const rangeBetweenMainTicks = nextTick - tick ;
6570
71+ // fix-2
72+ const adjustedTickCount = Math . max ( 1 , secondaryTickCount - 2 ) ;
6673 const secondaryLogTicks = ticks (
6774 tick + rangeBetweenMainTicks / ( secondaryTickCount + 1 ) ,
6875 nextTick - rangeBetweenMainTicks / ( secondaryTickCount + 1 ) ,
69- secondaryTickCount - 2
76+ adjustedTickCount
7077 ) . map ( ( n ) => symlog ( n , 10 ) ) ;
7178
7279 result . push ( ...secondaryLogTicks ) ;
@@ -76,7 +83,7 @@ export function getLogTicks(start, stop, mainTickCount = 8, secondaryTickCount =
7683
7784 return result ;
7885}
79-
86+ // getLogTicks(0, 100, 4, 2);
8087/**
8188 * Linear tick generation from d3-array.
8289 */
@@ -154,3 +161,4 @@ export function getFormattedTicks(newTicks, format) {
154161
155162 return newTicks ;
156163}
164+
0 commit comments