Skip to content

Instantly share code, notes, and snippets.

@josephcc
Created January 31, 2014 06:57
Show Gist options
  • Select an option

  • Save josephcc/8727658 to your computer and use it in GitHub Desktop.

Select an option

Save josephcc/8727658 to your computer and use it in GitHub Desktop.
jQuery ->
#
# only execute script on .v-find-clips-feedback context
#
if jQuery('body').find('.v-find-clips-feedback-analytics').length == 0
return
console.log 'init'
# ---------------------------
#
# FUNCTIONS
#
# ---------------------------
addGraph = (target, data) ->
nv.addGraph () ->
chart = nv.models.pieChart()
.x( (d) -> d.label )
.y( (d) -> d.value )
.showLabels(true)
.labelThreshold(.05)
.donut(true)
d3.select(target + " svg")
.datum(data)
.transition().duration(1200)
.call(chart)
return chart
# ---------------------------
#
# INIT
#
# ---------------------------
survey = $.parseJSON($('input').val())
data = survey.data
for item in data
target = "." + item.key
addgraph(target, item)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment