improve jsdoc and remove Math.round()
This commit is contained in:
parent
1ed72ede25
commit
91a8a9eec3
|
@ -144,14 +144,12 @@ export const getXLineScale = ( uniqueDates, width ) =>
|
||||||
.rangeRound( [ 0, width ] );
|
.rangeRound( [ 0, width ] );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describes getYMax
|
* Describes and rounds the maximum y value to the nearest thousadn, ten-thousand, million etc.
|
||||||
* @param {array} lineData - from `getLineData`
|
* @param {array} lineData - from `getLineData`
|
||||||
* @returns {number} the maximum value in the timeseries multiplied by 4/3
|
* @returns {number} the maximum value in the timeseries multiplied by 4/3
|
||||||
*/
|
*/
|
||||||
export const getYMax = lineData => {
|
export const getYMax = lineData => {
|
||||||
const yMax = Math.round(
|
const yMax = 4 / 3 * d3Max( lineData, d => d3Max( d.values.map( date => date.value ) ) );
|
||||||
4 / 3 * d3Max( lineData, d => d3Max( d.values.map( date => date.value ) ) )
|
|
||||||
);
|
|
||||||
const pow3Y = Math.pow( 10, ( ( Math.log( yMax ) * Math.LOG10E + 1 ) | 0 ) - 2 ) * 3;
|
const pow3Y = Math.pow( 10, ( ( Math.log( yMax ) * Math.LOG10E + 1 ) | 0 ) - 2 ) * 3;
|
||||||
return Math.ceil( yMax / pow3Y ) * pow3Y;
|
return Math.ceil( yMax / pow3Y ) * pow3Y;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue