Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Is this what you are looking for?</p> <p>I've commented the script, kept it close to the original from the link you provided.</p> <p><a href="http://jsfiddle.net/mori57/FhSrn/5/" rel="nofollow">JsFiddle</a></p> <p>(Decided to add the script here, for archival purposes and b/c Stack Overflow has been encouraging the inclusion of pertinent source.)</p> <p>HTML Source used:</p> <pre><code>&lt;div id="diagram"&gt;&lt;/div&gt; &lt;div class="get"&gt; &lt;div class="skill"&gt; &lt;span class="text"&gt;jQuery&lt;/span&gt; &lt;input type="hidden" class="percent" value="95" /&gt; &lt;input type="hidden" class="color" value="#97BE0D" /&gt; &lt;/div&gt; &lt;div class="skill"&gt; &lt;span class="text"&gt;CSS3&lt;/span&gt; &lt;input type="hidden" class="percent" value="90" /&gt; &lt;input type="hidden" class="color" value="#D84F5F" /&gt; &lt;/div&gt; &lt;div class="skill"&gt; &lt;span class="text"&gt;HTML5&lt;/span&gt; &lt;input type="hidden" class="percent" value="80" /&gt; &lt;input type="hidden" class="color" value="#88B8E6" /&gt; &lt;/div&gt; &lt;div class="skill"&gt; &lt;span class="text"&gt;PHP&lt;/span&gt; &lt;input type="hidden" class="percent" value="53" /&gt; &lt;input type="hidden" class="color" value="#BEDBE9" /&gt; &lt;/div&gt; &lt;div class="skill"&gt; &lt;span class="text"&gt;MySQL&lt;/span&gt; &lt;input type="hidden" class="percent" value="45" /&gt; &lt;input type="hidden" class="color" value="#EDEBEE" /&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Javascript:</p> <pre><code>var o = { init: function(){ this.diagram(); }, random: function(l, u){ return Math.floor((Math.random()*(u-l+1))+l); }, diagram: function(){ var originX = 10; var originY = 50; var barHeight = 30; var barMargin = 10; var r = Raphael('diagram', 600, 600); // We don't need the customAttributes, so we drop that, // and replace with a simple call to rect() r.rect(10,10,300,barHeight,6).attr({ stroke: 'none', fill: '#193340' }); // Similarly, we reposition the title to center // it with our new rectangle. var title = r.text(160, 25, 'Skills').attr({ font: '20px Arial', fill: '#fff' }).toFront(); $('.get').find('.skill').each(function(i){ // I've added in a width field, and calculate // it based on turning its value to a percentage // of the width of the Raphael element. var t = $(this), color = t.find('.color').val(), value = t.find('.percent').val(), width = r.width * (t.find('.percent').val() *.01), text = t.find('.text').text(); // create a new rectangle, providing X, Y, width, // and height. Base the fill and stroke on the color var z = r.rect(originX, originY, width, barHeight).attr({ 'fill': color, 'stroke': color, 'stroke-width':0 }); // update our originY to accomodate shifting the next // bar down by the barHeight + barMargin originY = originY + barHeight + barMargin; z.mouseover(function(){ // I added X in to animation, so that it would // appear to expand from the left, and the // expansion would not bleed off-canvas this.animate({ 'x': 10, 'stroke-width': 20, opacity: .75 }, 1000, 'elastic'); if(Raphael.type != 'VML') //solves IE problem this.toFront(); title.animate({ opacity: 0 }, 500, '&gt;', function(){ this.attr({ text: text + ': ' + value + '%' }).animate({ opacity: 1 }, 500, '&lt;'); }); }).mouseout(function(){ // and here I revert back to the originX after the // mouse has moved on... this.animate({ x: originX, 'stroke-width': 0, opacity: 1 }, 1000, 'elastic'); }); }); } } $(function(){ o.init(); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload