I'm planning to use a bar chart plugin from this site. How would you push the strings from each div.get's data attribute into the array arrayOfData?
For example:
<div class="get" data-stats="10.3,'Jan','#222222'"></div>
<div class="get" data-stats="15.2,'Feb','#7D252B'"></div>
I want to push the strings from data-stats into an array like this:
arrayOfData = new Array(
[10.3,'Jan','#222222'],
[15.2,'Feb','#7D252B']
);
Is push the correct way of doing this? I can't pass the strings into the array at all in the failed example. Any help would be appreciated.
HTML:
<div id="exampleSimple" style="width: 400px; height: 300px; position: relative; text-align: center;"></div>
<div class="get" data-stats="10.3,'Jan','#222222'"></div>
<div class="get" data-stats="15.2,'Feb','#7D252B'"></div>
<div class="get" data-stats="13.1,'Mar','#EB9781'"></div>
<div class="get" data-stats="16.3,'Apr','#FFD2B5'"></div>
<div class="get" data-stats="14.5,'May','#4A4147'"></div>
Jquery:
$(function() {
var arrayOfData = [];
$('.get').each(function(get){
var getstats = $(this).data('stats');
arrayOfData.push(getstats);
});
$('#exampleSimple').jqbargraph({
data: arrayOfData
});
});