Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Sep 18th, 2012  |  syntax: None  |  size: 2.56 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.  
  2.  
  3. function randomXToY(minVal,maxVal,floatVal)
  4. {
  5.   var randVal = minVal+(Math.random()*(maxVal-minVal));
  6.   return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);
  7. }
  8.  
  9.  
  10. tributary.init = function(g) {
  11.   var defs = g.append('defs');
  12.  
  13. var gradient = defs.append('linearGradient')
  14.     .attr('id','g320')
  15.     .attr('gradientUnits','userSpaceOnUse')
  16.     .attr('x1','0%')
  17.     .attr('x2','0%')
  18.     .attr('y1','0%')
  19.     .attr('y2',141)    
  20.    
  21. var stop1 =   gradient.append('stop')
  22.         .attr('stop-color',"#68B4CF")
  23.             .attr('offset','0')
  24.         .attr('id','stop1');
  25.  
  26. var stop2 =   gradient.append('stop')
  27.         .attr('stop-color',"#4DE3AC")
  28.             .attr('offset','1')
  29.         .attr('id','stop2');
  30.        
  31.        
  32.  
  33.  
  34. var text = {"message":"Hello","amplitude":1.216,"segments":26.03,"change1":0,"functionName":"Sinus", "change2" : 16.3,"a":1,"b":1,"c":0};
  35. var boolFlag = false;
  36. var circleBoundaries = d3.scale.linear().domain([0, 1489]).range([0.79, 20]);
  37. var r = 576 / 2,
  38.         data = d3.range(361).map(function(i) {
  39.                        
  40.                         var returnedValue = 1;
  41.                         var val = circleBoundaries(returnedValue);
  42.                         return  val;   
  43.                        
  44.          });
  45.        
  46.        
  47. var svg = g
  48.     .data([data])
  49.         .append("g")
  50.     .attr("transform", "translate(" + r + "," + r + ")");
  51.  
  52.  
  53.  
  54.  
  55.  
  56.   var path = svg.append("path")
  57.     .attr("class", "area")
  58.     .attr('fill',"url(#g320)")
  59.     .attr("d", d3.svg.area.radial()
  60.     .innerRadius(function(d,i) {
  61.       return i;
  62.     })
  63.     .outerRadius(function(d) {
  64.       return r * d;
  65.     })
  66.     .angle(function(d, i) { return i / 180 * Math.PI; }));
  67.  
  68.  
  69.           g.pathy = path;
  70.           g.stop1 = stop1;
  71.       g.stop2 = stop2;
  72.  
  73. };
  74.  
  75. var toogle = 1;
  76.  
  77. tributary.run = function(g,t) {
  78.   var delta = Math.floor(t * 100);
  79.  
  80.  var rect = g.rect;
  81.  if(delta % 96 == 0 ){
  82.  
  83.      
  84.   }  
  85.  
  86.  
  87.   if(delta % 100 == 0 ){
  88.     var r = 300;
  89.     var random = Math.sin(delta);
  90.     var radial = d3.svg.area.radial()
  91.     .innerRadius( function(d,i){
  92.         return i;
  93.         })
  94.     .outerRadius(function(d) {
  95.       return randomXToY(200,300);
  96.     })
  97.     .angle(function(d, i) {
  98.        return i / 180 * Math.PI;
  99.     });
  100.    
  101.         g.stop2
  102.                 .transition()
  103.       .ease('elastic(20, 2)')
  104.       .duration(1000)
  105.                 .attr('stop-color','#'+Math.floor(Math.random()*16777215).toString(16))
  106.  
  107.         g.stop1
  108.                 .transition()
  109.       .ease('elastic(20, 2)')
  110.       .duration(1000)
  111.                 .attr('stop-color','#'+Math.floor(Math.random()*16777215).toString(16))
  112.  
  113.      
  114.      
  115.     g.pathy
  116.       .transition()
  117.       .ease('elastic(20, 2)')
  118.       .duration(1000)
  119.       .attr("d", radial)
  120.       .attr('fill',"url(#g320)")
  121.   }
  122.  
  123.  
  124.  
  125. };