daily pastebin goal
79%
SHARE
TWEET

Untitled

a guest Sep 12th, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Strange Recursive code to draw chart
  2. function growBars() {
  3.     var barStartX = 0;
  4.     var barStartY = 0;
  5.     var barHeight = 0;
  6.     var barValue = 0;
  7.  
  8.     <!-- ********** Start Unable to understand -->
  9.     barValue = parseInt(chartData.bars[i].value);
  10.     barHeight = (barValue * chartHeight / maxValue) / numSteps * idxStep;
  11.     barStartX = chartMargin + chartAxisSpace + (i * (barWidth + barMargin)) + barMargin;
  12.     barStartY = chartMargin + (chartHeight - barHeight);
  13.     drawBar(barStartX, barStartY, barWidth, barHeight);
  14. }
  15. if (idxStep < numSteps) {
  16.     idxStep++;
  17.     setTimeout('growBars()', growSpeed);
  18. }
  19. } < -- * * * * * * * * * * * * * End till here-- >
  20.  
  21. function drawBar(barX, barY, barW, barH) {
  22.     context.fillStyle = '#00c';
  23.     context.fillRect(barX, barY, barW, barH);
  24.     context.shadowOffsetX = 3;
  25.     context.shadowOffsetY = -3;
  26.     context.shadowBlur = 3;
  27.     context.shadowColor = 'rgba(200, 200, 200, .3)';
  28.     context.strokeStyle = '#000';
  29.     context.lineWidth = 1;
  30.     context.strokeRect(barX, barY, barW, barH);
  31. }
  32.    
  33. 1. barValue = parseInt(chartData.bars[i].value);
  34. 2. barHeight = (barValue * chartHeight / maxValue) / numSteps * idxStep;
  35. 3. barStartX = chartMargin + chartAxisSpace + (i * (barWidth + barMargin)) + barMargin;
  36. 4. barStartY = chartMargin + (chartHeight-barHeight);
  37. 5. drawBar(barStartX, barStartY, barWidth, barHeight);
  38.    
  39. function growBars() { //START OF FUNCTION
  40.     var barStartX = 0;
  41.     var barStartY = 0;
  42.     var barHeight = 0;
  43.     var barValue = 0;
  44.  
  45.     <!-- ********** Start Unable to understand -->
  46.     barValue = parseInt(chartData.bars[i].value);
  47.     barHeight = (barValue * chartHeight / maxValue) / numSteps * idxStep;
  48.     barStartX = chartMargin + chartAxisSpace + (i * (barWidth + barMargin)) + barMargin;
  49.     barStartY = chartMargin + (chartHeight - barHeight);
  50.     drawBar(barStartX, barStartY, barWidth, barHeight);
  51. } //END OF FUNCTION
  52. if (idxStep < numSteps) { //START OF IF STATEMENT
  53.     idxStep++;
  54.     setTimeout('growBars()', growSpeed);
  55. } //END OF IF STATEMENT
  56. } < -- * * * * * * * * * * * * * End till here-- > // UNPAIRED CLOSE BRACKET
  57.  
  58. function drawBar(barX, barY, barW, barH) {
  59.     context.fillStyle = '#00c';
  60.     context.fillRect(barX, barY, barW, barH);
  61.     context.shadowOffsetX = 3;
  62.     context.shadowOffsetY = -3;
  63.     context.shadowBlur = 3;
  64.     context.shadowColor = 'rgba(200, 200, 200, .3)';
  65.     context.strokeStyle = '#000';
  66.     context.lineWidth = 1;
  67.     context.strokeRect(barX, barY, barW, barH);
  68. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top