I want to make the bubble position is random instead of people need to set the y and x position.
Here the link of example bubble chart
http://codepen.io/anon/pen/LowKD
here the js script
$(document).ready(function() {
$('.graph-bar').each(function() {
var dataWidth = $(this).data('value');
$(this).css("width", dataWidth + "%");
});
});
// Positioning of .bubbleChart
$(document).ready(function() {
$('.chart-bubble').each(function() {
// Bubble Size
var bubbleSize = $(this).data('value');
$(this).css("width", function() {
return (bubbleSize * 10) + "px"
});
$(this).css("height", function() {
return (bubbleSize * 10) + "px"
});
// Bubble Position
var posX = $(this).data('x');
var posY = $(this).data('y');
$(this).css("left", function() {
return posX - (bubbleSize * 0.5) + "%"
});
$(this).css("bottom", function() {
return posY - (bubbleSize * 0.5) + "%"
});
});
});
I want this bubble chart to random positioning
<div data-value="7" data-label="500" data-x="50" data-y="50" class="chart-bubble"></div>
so I don't have to set the data x and y because I want to make it random when user fill the value