Created
January 31, 2014 06:57
-
-
Save josephcc/8727658 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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