Creating Progress Animations Across Map Regions

Creating Progress Animations Across Map Regions

Progress animations across map regions create compelling visualizations that show data progression, completion tracking, or status changes over time. Whether you're visualizing sales progress, project completion, or data growth, animated progress fills add dynamic visual interest and effectively communicate information.

In this guide, we'll explore how to create progress animations across map regions using SVG and CSS.

Why Use Progress Animations?

Progress animations offer several benefits:

Generate vector dotted maps

Create vector dotted maps with custom options and download them as SVG or PNG files

Basic Progress Fill

SVG Path Fill Animation

<svg class="map">
  <defs>
    <clipPath id="region-clip">
      <path id="region-path" d="M100,100 L200,100 L200,200 L100,200 Z" />
    </clipPath>
  </defs>
  
  <rect class="progress-fill" x="100" y="100" width="100" height="100" 
        clip-path="url(#region-clip)" fill="#3b82f6" />
  <path class="region-outline" d="M100,100 L200,100 L200,200 L100,200 Z" 
        fill="none" stroke="#333" stroke-width="2" />
</svg>
.progress-fill {
  width: 0;
  transition: width 2s ease-out;
}

.progress-fill.animate {
  width: 100;
}

Mask-Based Fill

<svg class="map">
  <defs>
    <mask id="progress-mask">
      <rect id="mask-rect" x="0" y="0" width="0" height="100%" fill="white" />
    </mask>
  </defs>
  
  <path class="region" d="M100,100 L200,100 L200,200 L100,200 Z" 
        fill="#3b82f6" mask="url(#progress-mask)" />
</svg>
function animateProgress(maskRect, targetWidth, duration = 2000) {
  const startTime = performance.now();
  const startWidth = 0;
  
  function animate(currentTime) {
    const elapsed = currentTime - startTime;
    const progress = Math.min(elapsed / duration, 1);
    const ease = easeOutCubic(progress);
    
    const currentWidth = startWidth + (targetWidth - startWidth) * ease;
    maskRect.setAttribute('width', currentWidth);
    
    if (progress < 1) {
      requestAnimationFrame(animate);
    }
  }
  
  requestAnimationFrame(animate);
}

Generate vector dotted maps

Create vector dotted maps with custom options and download them as SVG or PNG files

Percentage-Based Progress

Animate to Percentage

function animateRegionProgress(region, percentage, duration = 2000) {
  const path = document.querySelector(`.region-${region}`);
  const pathLength = path.getTotalLength();
  const targetLength = pathLength * (percentage / 100);
  
  path.style.strokeDasharray = pathLength;
  path.style.strokeDashoffset = pathLength;
  path.style.transition = `stroke-dashoffset ${duration}ms ease-out`;
  path.style.strokeDashoffset = pathLength - targetLength;
}

Fill from Bottom

function fillFromBottom(element, percentage) {
  const height = element.getBBox().height;
  const fillHeight = height * (percentage / 100);
  
  const fillRect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
  fillRect.setAttribute('x', element.getBBox().x);
  fillRect.setAttribute('y', element.getBBox().y + height - fillHeight);
  fillRect.setAttribute('width', element.getBBox().width);
  fillRect.setAttribute('height', fillHeight);
  fillRect.setAttribute('fill', '#3b82f6');
  
  element.parentNode.insertBefore(fillRect, element);
}

Sequential Region Animation

Animate Regions One by One

function animateRegionsSequentially(regions, progressData, delay = 300) {
  regions.forEach((region, index) => {
    setTimeout(() => {
      const progress = progressData[region.id] || 0;
      animateRegionProgress(region, progress);
    }, index * delay);
  });
}

Staggered Start

.region-progress:nth-child(1) {
  animation-delay: 0s;
}

.region-progress:nth-child(2) {
  animation-delay: 0.3s;
}

.region-progress:nth-child(3) {
  animation-delay: 0.6s;
}

Data-Driven Progress

Update from Data

function updateProgressFromData(data) {
  Object.keys(data).forEach(regionId => {
    const progress = data[regionId];
    const region = document.querySelector(`.region-${regionId}`);
    
    if (region) {
      animateRegionProgress(region, progress);
    }
  });
}

// Example usage
const progressData = {
  'north-america': 75,
  'europe': 60,
  'asia': 90
};

updateProgressFromData(progressData);

Real-Time Updates

function connectToDataStream(callback) {
  // Simulate data stream
  setInterval(() => {
    const newData = fetchProgressData();
    callback(newData);
  }, 1000);
}

connectToDataStream((data) => {
  updateProgressFromData(data);
});

Visual Variations

Color-Coded Progress

function getProgressColor(percentage) {
  if (percentage >= 80) return '#10b981'; // Green
  if (percentage >= 50) return '#f59e0b'; // Yellow
  return '#ef4444'; // Red
}

function animateWithColor(region, percentage) {
  const color = getProgressColor(percentage);
  animateRegionProgress(region, percentage);
  updateRegionColor(region, color);
}

Gradient Progress

<defs>
  <linearGradient id="progress-gradient">
    <stop offset="0%" stop-color="#3b82f6" />
    <stop offset="100%" stop-color="#8b5cf6" />
  </linearGradient>
</defs>

Pulsing Progress

.progress-fill {
  animation: pulseProgress 2s ease-in-out infinite;
}

@keyframes pulseProgress {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
}

Performance Optimization

Use CSS When Possible

/* Good - CSS animation */
.progress-fill {
  transition: width 2s ease-out;
}

/* Avoid - JavaScript if CSS can do it */

Batch Updates

function batchUpdateProgress(updates) {
  requestAnimationFrame(() => {
    updates.forEach(update => {
      animateRegionProgress(update.region, update.progress);
    });
  });
}

Best Practices

Timing

Visual Design

Data Accuracy

Common Patterns

Completion Tracking

Data Growth

Status Visualization

Final Thoughts

Creating progress animations across map regions creates compelling visualizations that effectively communicate progress, completion, or data growth. Whether animating completion tracking, data visualization, or status changes, progress animations add dynamic visual interest.

Start with accurate data, choose appropriate animation techniques, and ensure smooth, readable progress fills. The result is engaging map visualizations that effectively communicate progress and status information.

Ready to animate progress? Generate your dotted map and start creating progress animations today.