I want to generate random numbers between 0.0251 to 0.4070.
From below code:
<circle>
r
value has to be dynamically set as 0.0841, 0.2541, 0.3257, 0.0998 for each attribute..
SVG Code
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" width="660" height="320" viewBox="0 0 201 97">
<g stroke="#000" stroke-width=".144">
<circle class="st3" cx="191" cy="90" r=".3"/>
<circle class="st3" cx="190" cy="90" r=".3"/>
<circle class="st3" cx="189" cy="90" r=".3"/>
<circle class="st3" cx="192" cy="89" r=".3"/>
<circle class="st3" cx="191" cy="89" r=".3"/>
<circle class="st3" cx="190" cy="89" r=".3"/>
<circle class="st3" cx="193" cy="88" r=".3"/>
<circle class="st3" cx="192" cy="88" r=".3"/>
<circle class="st3" cx="178" cy="88" r=".3"/>
<circle class="st3" cx="177" cy="88" r=".3"/>
<circle class="st3" cx="194" cy="87" r=".3"/>
<circle class="st3" cx="179" cy="87" r=".3"/>
<circle class="st3" cx="178" cy="87" r=".3"/>
</g>
</svg>
jQuery
$("circle.st3").attr("r", (Math.random() * (0.0251 - 0.4070) + 0.4070).toFixed(4));
Online Demo
Output from Above Example:
<g stroke="#000" stroke-width=".144">
<circle class="st3" cx="191" cy="90" r="0.0973"></circle>
<circle class="st3" cx="190" cy="90" r="0.0973"></circle>
<circle class="st3" cx="189" cy="90" r="0.0973"></circle>
<circle class="st3" cx="192" cy="89" r="0.0973"></circle>
<circle class="st3" cx="191" cy="89" r="0.0973"></circle>
<circle class="st3" cx="190" cy="89" r="0.0973"></circle>
<circle class="st3" cx="193" cy="88" r="0.0973"></circle>
<circle class="st3" cx="192" cy="88" r="0.0973"></circle>
<circle class="st3" cx="178" cy="88" r="0.0973"></circle>
<circle class="st3" cx="177" cy="88" r="0.0973"></circle>
<circle class="st3" cx="194" cy="87" r="0.0973"></circle>
<circle class="st3" cx="179" cy="87" r="0.0973"></circle>
<circle class="st3" cx="178" cy="87" r="0.0973"></circle>
</g>
But my requiremnt is to display different number for each "r" attribute..
Can somebody please help me out?