Skip to content

Commit

Permalink
dropped the Quantitative namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbjames committed Jul 13, 2014
1 parent f2c387e commit de75672
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
30 changes: 15 additions & 15 deletions src/D3/Scale/Quantitative.elm → src/D3/Scale.elm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module D3.Scale.Quantitative where
{-| Quantitative Scales in elm-d3. These are for scales that take a value
module D3.Scale where
{-| Basic scales in elm-d3. These are for scales that take a value
from the Reals and map it to the Reals
# Make a scale
Expand All @@ -11,31 +11,31 @@ from the Reals and map it to the Reals
# Do things with a scale
@docs convert, invert, ticks
-}
import Native.D3.Scale.Quantitative
import Native.D3.Scale

data Scale a = Scale
{-| Make a linear scale. Nothing fancy here. The default is the identity mapping.
-}
linear : Scale Float
linear = Native.D3.Scale.Quantitative.linear
linear = Native.D3.Scale.linear

identity : Scale Float
identity = Native.D3.Scale.Quantitative.identity
identity = Native.D3.Scale.identity

{-| Make a sqrt scale.
-}
sqrt : Scale Float
sqrt = Native.D3.Scale.Quantitative.sqrt
sqrt = Native.D3.Scale.sqrt

{-| Make a power scale. You must specify the exponent.
-}
pow : Float -> Scale Float
pow = Native.D3.Scale.Quantitative.pow
pow = Native.D3.Scale.pow

{-| Make a log scale. You must specify the base.
-}
log : Float -> Scale Float
log = Native.D3.Scale.Quantitative.log
log = Native.D3.Scale.log


{-| Change the domain of the function. You may pass in any number of values into
Expand All @@ -44,46 +44,46 @@ the list and they will be interpolated between.
yScale = linear |> domain [0,100] |> range [-150,150]
-}
domain : [Float] -> Scale a -> Scale a
domain = Native.D3.Scale.Quantitative.domain
domain = Native.D3.Scale.domain

{-| Change the range of the function. You may pass in any number of values into
the list and they will be interpolated between.
-}
range : [a] -> Scale a -> Scale a
range = Native.D3.Scale.Quantitative.range
range = Native.D3.Scale.range

{-| Extend the domain to start and end on "nice" values.
linear |> domain [0.201, 0.934] |> nice == linear |> domain [0.2, 1]
-}
nice : Scale Float -> Scale Float
nice = Native.D3.Scale.Quantitative.nice
nice = Native.D3.Scale.nice

{-| Clamp the domain so that values beyond the domain will be brough back to the
most extreme value specified in the domain.
linear |> clamp True |> convert 3 == 1
-}
clamp : Bool -> Scale Float -> Scale Float
clamp = Native.D3.Scale.Quantitative.clamp
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
-}
convert : Float -> Scale b -> b
convert = Native.D3.Scale.Quantitative.convert
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 = Native.D3.Scale.Quantitative.invert
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]
-}
ticks : Int -> Scale Float -> [Float]
ticks = Native.D3.Scale.Quantitative.ticks
ticks = Native.D3.Scale.ticks
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
Elm.Native.D3.Scale.Quantitative = {};
Elm.Native.D3.Scale.Quantitative.make = function (elm) {
Elm.Native.D3.Scale = {};
Elm.Native.D3.Scale.make = function (elm) {
'use strict';

elm.Native = elm.Native || {};
elm.Native.D3 = elm.Native.D3 || {};
elm.Native.D3.Scale = elm.Native.D3.Scale || {};
elm.Native.D3.Scale.Quantitative = elm.Native.D3.Scale.Quantitative || {};
if (elm.Native.D3.Scale.Quantitative.values) return elm.Native.D3.Scale.Quantitative.values;
if (elm.Native.D3.Scale.values) return elm.Native.D3.Scale.values;

var JS = Elm.Native.D3.JavaScript.make(elm);

Expand Down Expand Up @@ -55,7 +54,7 @@ Elm.Native.D3.Scale.Quantitative.make = function (elm) {
return scale.invert(number);
}

return elm.Native.D3.Scale.Quantitative.values =
return elm.Native.D3.Scale.values =
{ linear : d3.scale.linear()
, identity : d3.scale.identity()
, sqrt : d3.scale.sqrt()
Expand Down
3 changes: 1 addition & 2 deletions src/Native/D3/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ import "Selection"
import "Event"
import "Transition"
import "Voronoi"
Elm.Native.D3.Scale = {};
import "Scale/Quantitative"
import "Scale"

0 comments on commit de75672

Please sign in to comment.