diff --git a/src/TernaryGraph.purs b/src/TernaryGraph.purs index d949476..71ddd5c 100644 --- a/src/TernaryGraph.purs +++ b/src/TernaryGraph.purs @@ -4,7 +4,7 @@ import Prelude ( discard, class Monoid, class Semigroup, Unit, ($), (<<<), (<>), import Data.Array ((!!), concat, cons, mapWithIndex, range) import Data.Functor (map) -import Data.Int (toNumber) +import Data.Int as Int import Data.Maybe import Data.Number (cos, pi, sin) import Data.Number.Format (toString) @@ -70,8 +70,8 @@ getTick :: Number -> Int -> Int -> Line getTick scale numTicks tickI = {start: {x: x, y: -(0.5 + 5.0 / scale)}, end: {x: x, y: y}} where - x = 2.0 * (sin (pi / 3.0)) * (toNumber tickI) / (toNumber numTicks) - (sin (pi / 3.0)) - y = if tickI < numTicks / 2 + x = 2.0 * (sin (pi / 3.0)) * (Int.toNumber tickI) / (Int.toNumber numTicks) - (sin (pi / 3.0)) + y = if tickI <= numTicks / 2 then 1.0 + x * 1.5 / (sin (pi / 3.0)) else 1.0 - x * 1.5 / (sin (pi / 3.0)) @@ -138,7 +138,7 @@ ternaryGraph scale xOffset yOffset numTicks = ternaryGraphSvg fragments -- TODO: tick label size -- TODO: axis tick label rotation -- TODO: axis tick start number - axisTickLabels = \rotation -> mapWithIndex (\i point -> svgText ("E" <> (toString (toNumber i))) 10.0 point 0.0) + axisTickLabels = \rotation -> mapWithIndex (\i point -> svgText ("E" <> (toString (Int.toNumber i))) 10.0 point 0.0) axis1TickLabels = axisTickLabels 0 $ axisTickStarts axis1TickLines axis2TickLabels = axisTickLabels 0 $ axisTickStarts axis2TickLines