Skip to content

Scale.Normalize

Maps a value from one scale to another. Used for scaling values to fit within SVG dimensions

DaxLib.SVG.Scale.Normalize( inputValue, fromMin, fromMax, toMin, toMax )
Name Type Required Description
inputValue NUMERIC VAL The value to map
fromMin NUMERIC VAL The minimum value of the original scale
fromMax NUMERIC VAL The maximum value of the original scale
toMin NUMERIC VAL The minimum value of the new scale
toMax NUMERIC VAL The maximum value of the new scale

NUMERIC mapped value

DaxLib.SVG.Scale.Normalize(50, 0, 200, 0, 100) 
// Returns 25
function 'DaxLib.SVG.Scale.Normalize' =
    (
        inputValue: NUMERIC VAL,
        fromMin: NUMERIC VAL,
        fromMax: NUMERIC VAL,
        toMin: NUMERIC VAL,
        toMax: NUMERIC VAL
    ) =>

        ( ( inputValue - fromMin ) / ( fromMax - fromMin ) ) * ( toMax - toMin ) + toMin

Comments