Last active
December 15, 2015 13:29
-
-
Save hughevans/5267912 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
| drawChart = function(chapters) { | |
| var data = { | |
| // Create the dataset objects required for Chart.js | |
| datasets: $.map(chapters, function(chapter, index) { | |
| // Different shades of blue/green for each of the nine chapters | |
| var red = 26; | |
| var green = 67 + (16 * index); | |
| var blue = 84 + (13 * index); | |
| var colour = red + "," + green + "," + blue; | |
| return { | |
| fillColor: "rgba("+colour+",0.8)", | |
| strokeColor: "rgba("+colour+",0.9)", | |
| pointColor: "rgba("+colour+",0)", | |
| pointStrokeColor: "rgba("+colour+",0)", | |
| // The Chart.js radar chart is not stacked so we add the total of the previous | |
| // chapters’ words to this one to make it so | |
| data: $.map(chapter, function(segment, segmentIndex) { | |
| var otherTotal = 0; | |
| for (var i=8; i > index; i--) { | |
| otherTotal = otherTotal + chapters[i][segmentIndex]; | |
| } | |
| return otherTotal + segment; | |
| }) | |
| }; | |
| }) | |
| }; | |
| var ctx = $("#radar_chart").get(0).getContext("2d"); | |
| new Chart(ctx).Radar(data, {scaleLineColor : "rgba(0,0,0,.06)"}); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment