Skip to content

Commit

Permalink
changed parameter order for convert, invert, and ticks
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbjames committed Jul 17, 2014
1 parent ec75645 commit af3960e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions src/D3/Scale.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions src/Native/D3/Scale.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -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);
}
Expand Down

0 comments on commit af3960e

Please sign in to comment.