Skip to content

Commit

Permalink
fixes #24 - users can now pass a DOM node or a CSS selector to initia…
Browse files Browse the repository at this point in the history
…lize the chart
  • Loading branch information
jcarver committed Mar 6, 2016
1 parent 4ac75da commit 485772e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions dist/suave-charts.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/coffeescript/svg.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ class Svg
[w, h] = aspectRatio.split(":")
@aspectRatio = [parseInt(w), parseInt(h)]

@domElement = document.querySelector(selector)
# allow users to pass in a node or a selector string
@domElement = if typeof selector == "string"
document.querySelector(selector)
else
selector

@container = d3
.select(@domElement)
.append("svg")
Expand Down

0 comments on commit 485772e

Please sign in to comment.