Permalink
Browse files

take in graph path in query string

  • Loading branch information...
1 parent 4ebaded commit 8d4509392297f759864f2b7f13c53119c287283b @shuw committed Feb 1, 2012
Showing with 12 additions and 10 deletions.
  1. +2 −1 app.coffee
  2. +7 −7 assets/js/viz.coffee
  3. +3 −2 views/index.jade
View
@@ -35,7 +35,8 @@ app.configure 'production', () ->
app.get '/', (req, res) ->
res.render 'index',
locals:
- title: '| - |'
+ data_path: req.query["data"]
+ title: '/|/|/'
# SERVER
View
@@ -6,8 +6,8 @@ h = 700
fill = d3.scale.category20()
# TODO: Visualize breakups as well
-Graph =
- init: ->
+window.Graph =
+ init: (data_path) ->
@nodeMap = {}
@nodes = []
@links = []
@@ -16,8 +16,10 @@ Graph =
.attr("width", w)
.attr("height", h)
+ data_path ||= 'celebrities_started_dating'
+
# TODO: Order events by date
- d3.json "data/org_acquired_another_org.json", (news_events) =>
+ d3.json "data/#{data_path}.json", (news_events) =>
@news_events = news_events
@start()
@@ -61,7 +63,7 @@ Graph =
@refreshData()
setInterval (=>
- @processData(@news_events.splice(0, 3))
+ @processData(@news_events.splice(0, 5))
@refreshData()
), 500
@@ -106,6 +108,4 @@ Graph =
.attr("x2", (d) -> d.target.x)
.attr("y2", (d) -> d.target.y)
- @node.attr "transform", (d) -> "translate(#{d.x},#{d.y})"
-
-$ => Graph.init()
+ @node.attr "transform", (d) -> "translate(#{d.x},#{d.y})"
View
@@ -9,6 +9,7 @@ header
stroke: #999;
stroke-opacity: .6;
}
-
body
- #chart
+ #chart
+ script
+ $(function() { window.Graph.init('#{data_path}') })

0 comments on commit 8d45093

Please sign in to comment.