From af3960e669760fd3fb37bad00fe93e1f93d8bdb3 Mon Sep 17 00:00:00 2001 From: Michael James Date: Thu, 17 Jul 2014 19:19:51 +0200 Subject: [PATCH] changed parameter order for convert, invert, and ticks --- src/D3/Scale.elm | 11 ++++++----- src/Native/D3/Scale.js | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/D3/Scale.elm b/src/D3/Scale.elm index cd8fe80..a15f864 100644 --- a/src/D3/Scale.elm +++ b/src/D3/Scale.elm @@ -75,20 +75,21 @@ clamp = Native.D3.Scale.clamp {-| Apply the scale to a value and it will map the input value to the output range. - linear |> domain [0,1] |> range [0,100] |> convert 0.5 == 50 + let cToF = linear |> domain [0,100] |> range [32,212] |> convert + in cToF -40 => -40 -} -convert : Float -> Scale b -> b +convert : Scale b -> Float -> b convert = Native.D3.Scale.convert {-| Apply the scale to a value in its range to get the corresponding value in the domain. -} -invert : Float -> Scale Float -> Float +invert : Scale Float -> Float -> Float invert = Native.D3.Scale.invert {-| Get a list of where the ticks are on the scale, given a number of ticks you want. - linear |> domain [0,10] |> ticks 3 == [0, 5, 10] + (linear |> domain [0,10] |> ticks) 3 == [0, 5, 10] -} -ticks : Int -> Scale Float -> [Float] +ticks : Scale Float -> Int -> [Float] ticks = Native.D3.Scale.ticks diff --git a/src/Native/D3/Scale.js b/src/Native/D3/Scale.js index dad0407..345318c 100644 --- a/src/Native/D3/Scale.js +++ b/src/Native/D3/Scale.js @@ -29,7 +29,7 @@ Elm.Native.D3.Scale.make = function (elm) { return newScale.range(newRange); } - function ticks(nTicks, scale) { + function ticks(scale, nTicks) { var tempScale = scale.copy(); return tempScale.ticks(JS.toInt(nTicks)); } @@ -44,12 +44,12 @@ Elm.Native.D3.Scale.make = function (elm) { return newScale.clamp(JS.toBool(bool)); } - function convert(n, scale) { + function convert(scale, n) { var number = JS.toFloat(n); return scale(number); } - function invert(n, scale) { + function invert(scale, n) { var number = JS.toFloat(n); return scale.invert(number); }