{"action":"created","issue":{"url":"https://api.github.com/repos/pelotom/purescript-d3/issues/10","labels_url":"https://api.github.com/repos/pelotom/purescript-d3/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/pelotom/purescript-d3/issues/10/comments","events_url":"https://api.github.com/repos/pelotom/purescript-d3/issues/10/events","html_url":"https://github.com/pelotom/purescript-d3/pull/10","id":67425440,"number":10,"title":"Adding timeScale and extent","user":{"login":"tgdwyer","id":2754673,"avatar_url":"https://avatars.githubusercontent.com/u/2754673?v=3","gravatar_id":"","url":"https://api.github.com/users/tgdwyer","html_url":"https://github.com/tgdwyer","followers_url":"https://api.github.com/users/tgdwyer/followers","following_url":"https://api.github.com/users/tgdwyer/following{/other_user}","gists_url":"https://api.github.com/users/tgdwyer/gists{/gist_id}","starred_url":"https://api.github.com/users/tgdwyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgdwyer/subscriptions","organizations_url":"https://api.github.com/users/tgdwyer/orgs","repos_url":"https://api.github.com/users/tgdwyer/repos","events_url":"https://api.github.com/users/tgdwyer/events{/privacy}","received_events_url":"https://api.github.com/users/tgdwyer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-04-09T18:41:09Z","updated_at":"2015-04-19T09:48:25Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/pelotom/purescript-d3/pulls/10","html_url":"https://github.com/pelotom/purescript-d3/pull/10","diff_url":"https://github.com/pelotom/purescript-d3/pull/10.diff","patch_url":"https://github.com/pelotom/purescript-d3/pull/10.patch"},"body":"This is my first non-trivial purescript effort so please review and comment (gently :) )!\r\n\r\nThere's two things I guess could be improved but I don't know how precisely:\r\n\r\nI put the time stuff in a new module `Graphics.D3.Time` defined in `time.purs`.  It could also go in `Scale` which would mean we wouldn't need to redefine `unsafeDomain`, `unsafeRange`, etc.  However, there's loads more time stuff to come so I guess it makes sense to separate it now?\r\nWhat is the correct way to share these `unsafe` definitions between Time and Scale without exposing them outside the library?\r\n\r\nAlso, I left the `extent` type parameter completely general so it can work with Number or JSDate.  What is the correct way to specify a \"this type or that\" constraint?\r\n\r\nHere's the example I'm working on which uses these added bindings:\r\n\r\n```\r\nmodule Graphics.D3.Examples.UpdateGraph where\r\n\r\nimport Data.Either\r\nimport Data.Traversable\r\nimport Data.Date\r\nimport Data.Foreign\r\nimport Data.Foreign.EasyFFI\r\n\r\nimport Graphics.D3.Base\r\nimport Graphics.D3.Util\r\nimport Graphics.D3.Selection\r\nimport Graphics.D3.SVG.Axis\r\nimport Graphics.D3.Scale\r\nimport Graphics.D3.Time\r\nimport Graphics.D3.Request\r\n\r\n-- | This is a PureScript adaptation of d3noob's example: \"Update graph data automatically\"\r\n-- | http://bl.ocks.org/d3noob/6bd13f974d6516f3e491\r\n\r\n{-\r\n\r\nOriginal JavaScript code:\r\n=========================\r\n\r\n-}\r\n\r\ntype DateAndClose = { date :: JSDate, close :: Number }\r\n\r\ncoerceDatum :: forall a. a -> D3Eff DateAndClose\r\ncoerceDatum = unsafeForeignFunction [\"x\", \"\"] \"{ date: d3.time.format('%d-%b-%y').parse(x.date), close: Number(x.close) }\"\r\n\r\nmargin = {top: 30, right: 20, bottom: 30, left: 50}\r\nwidth = 600 - margin.left - margin.right\r\nheight = 270 - margin.top - margin.bottom\r\n\r\n-- valueline = ffi [\"xdata\", \"ydata\", \"\"] \"d3.svg.line().x(xdata).y(ydata);\"\r\nclose x = x.close\r\ndate x = x.date\r\n\r\nmain = do\r\n\r\n  xScale <- timeScale\r\n    .. range [0, width]\r\n\r\n  yScale <- linearScale\r\n    .. range [height, 0]\r\n\r\n-- Define the axes\r\n  xAxis <- axis\r\n    .. scale xScale\r\n    .. orient \"bottom\"\r\n    .. ticks 5\r\n\r\n  yAxis <- axis\r\n    .. scale yScale\r\n    .. orient \"left\"\r\n    .. ticks 5\r\n\r\n  svg <- rootSelect \"body\" .. append \"svg\"\r\n    .. attr \"width\" (width + margin.left + margin.right)\r\n    .. attr \"height\" (height + margin.top + margin.bottom)\r\n    .. append \"g\"\r\n      .. attr \"transform\" (\"translate(\" ++ show margin.left ++ \",\" ++ show margin.top ++ \")\")\r\n\r\n  csv \"data.csv\" \\(Right array) -> do\r\n    typedData <- traverse coerceDatum array\r\n\r\n    xScale ... domain $ extent $ date <$> typedData\r\n\r\n    yScale ... domain [0, max close typedData]\r\n\r\n    svg ... append \"g\"\r\n      .. attr \"class\" \"x axis\"\r\n      .. attr \"transform\" (\"translate(0,\" ++ show height ++ \")\")\r\n      .. renderAxis xAxis\r\n\r\n    svg ... append \"g\"\r\n      .. attr \"class\" \"y axis\"\r\n      .. renderAxis yAxis\r\n\r\n    x <- toFunction xScale\r\n    y <- toFunction yScale\r\n\r\n    svg ... selectAll \"ellipse\"\r\n        .. bind typedData\r\n      .. enter .. append \"ellipse\"\r\n        .. attr \"class\" \"datapoint\"\r\n        .. attr' \"cx\" (x <<< date)\r\n        .. attr' \"cy\" (y <<< close)\r\n        .. attr \"rx\" \"5\"\r\n        .. attr \"ry\" \"5\"\r\n\r\n    -- let xdata = x <$> (date <$> typedData)\r\n    -- let ydata = y <$> (close <$> typedData)\r\n\r\n    --let dd = valueline xdata ydata\r\n    -- svg ... append \"path\"\r\n    --   .. attr \"class\" \"line\"\r\n    --   .. attr \"d\" dd\r\n```"},"comment":{"url":"https://api.github.com/repos/pelotom/purescript-d3/issues/comments/94256924","html_url":"https://github.com/pelotom/purescript-d3/pull/10#issuecomment-94256924","issue_url":"https://api.github.com/repos/pelotom/purescript-d3/issues/10","id":94256924,"user":{"login":"tgdwyer","id":2754673,"avatar_url":"https://avatars.githubusercontent.com/u/2754673?v=3","gravatar_id":"","url":"https://api.github.com/users/tgdwyer","html_url":"https://github.com/tgdwyer","followers_url":"https://api.github.com/users/tgdwyer/followers","following_url":"https://api.github.com/users/tgdwyer/following{/other_user}","gists_url":"https://api.github.com/users/tgdwyer/gists{/gist_id}","starred_url":"https://api.github.com/users/tgdwyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgdwyer/subscriptions","organizations_url":"https://api.github.com/users/tgdwyer/orgs","repos_url":"https://api.github.com/users/tgdwyer/repos","events_url":"https://api.github.com/users/tgdwyer/events{/privacy}","received_events_url":"https://api.github.com/users/tgdwyer/received_events","type":"User","site_admin":false},"created_at":"2015-04-19T09:48:25Z","updated_at":"2015-04-19T09:48:25Z","body":"added extent' export"}}