Created
October 22, 2015 15:31
-
-
Save jenter/cde274fdfc611ff9d119 to your computer and use it in GitHub Desktop.
This file contains 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
<!-- This will need to be put into the destination html --> | |
<div id="circles_container"> </div> | |
<!-- This is the example markup from the polls --> | |
<span class="fake_info"> | |
<span class="group"> | |
<span class="percentage">55</span> | |
<span class="text">Dude?</span> | |
</span> | |
<span class="group"> | |
<span class="percentage">35</span> | |
<span class="text">Bro!</span> | |
</span> | |
<span class="group"> | |
<span class="percentage">85</span> | |
<span class="text">Hello</span> | |
</span> | |
</span> | |
<!-- JS to create everything --> | |
<script> | |
function createBosCircles(source, dest) { | |
// console.log(source); | |
// console.log(dest); | |
// console.log(source.length); | |
var count = 0; | |
for (var i = 0; i < source.length; i++) { | |
count++; | |
var index = (count - 1); | |
var inner_circle = 'circle_inner_' + count; | |
var get_perct = source.eq(index).find('.percentage').text(); | |
var get_text = source.eq(index).find('.text').text(); | |
// console.log(get_perct); | |
// console.log(get_text); | |
// create inner DIVs | |
dest.append('<div id="'+inner_circle+'"></div>'); | |
Circles.create({ | |
id: inner_circle, | |
radius: 60, | |
value: get_perct, | |
maxValue: 100, | |
width: 10, | |
text: get_perct + '%', | |
colors: ['#D3B6C6', '#4B253A'], | |
duration: 200, | |
wrpClass: 'circles-wrp', | |
textClass: 'circles-text', | |
valueStrokeClass: 'circles-valueStroke', | |
maxValueStrokeClass: 'circles-maxValueStroke', | |
styleWrapper: true, | |
styleText: true | |
}); | |
jQuery('#' + inner_circle).find('.circles-wrp').after('<div class="under_circles_text">' + get_text + '</div>'); | |
} | |
} | |
// Call function | |
createBosCircles(jQuery('.fake_info > .group'), jQuery('#circles_container')); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment