All skills
mapbox avatar

/mapbox-data-visualization-patterns

@65bab68 official
by mapboxmapbox/mapbox-agent-skills80 stars
17

Patterns for visualizing data on maps including choropleth maps, heat maps, 3D visualizations, data-driven styling, and animated data. Covers layer types, color scales, and performance optimization.

Use this Skill: https://skilld.dev/gh/mapbox/mapbox-agent-skills/mapbox-data-visualization-patterns

This session only. Nothing lands on disk.

referencesanimation.md

≈705 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Animated Data Visualizations

Time-Series Animation

Pattern: Animate data over time

let currentTime = 0;
const times = [0, 6, 12, 18, 24]; // Hours of day
let animationId;

map.on('load', () => {
  map.addSource('hourly-data', {
    type: 'geojson',
    data: getDataForTime(currentTime)
  });

  map.addLayer({
    id: 'data-layer',
    type: 'circle',
    source: 'hourly-data',
    paint: {
      'circle-radius': 8,
      'circle-color': ['get', 'color']
    }
  });

  // Animation loop
  function animate() {
    currentTime = (currentTime + 1) % times.length;

    // Update data
    map.getSource('hourly-data').setData(getDataForTime(times[currentTime]));

    // Update UI
    document.getElementById('time-display').textContent = `${times[currentTime]}:00`;

    animationId = setTimeout(animate, 1000); // Update every second
  }

  // Start animation
  document.getElementById('play-button').addEventListener('click', () => {
    if (animationId) {
      clearTimeout(animationId);
      animationId = null;
    } else {
      animate();
    }
  });
});

function getDataForTime(hour) {
  // Fetch or generate data for specific time
  return {
    type: 'FeatureCollection',
    features: data.filter((d) => d.properties.hour === hour)
  };
}

Real-Time Data Updates

Pattern: Update data from live sources

map.on('load', () => {
  map.addSource('live-data', {
    type: 'geojson',
    data: {
      type: 'FeatureCollection',
      features: []
    }
  });

  map.addLayer({
    id: 'live-points',
    type: 'circle',
    source: 'live-data',
    paint: {
      'circle-radius': 6,
      'circle-color': '#ff4444'
    }
  });

  // Poll for updates every 5 seconds
  setInterval(async () => {
    const response = await fetch('https://api.example.com/live-data');
    const data = await response.json();

    // Update source
    map.getSource('live-data').setData(data);
  }, 5000);

  // Or use WebSocket for real-time updates
  const ws = new WebSocket('wss://api.example.com/live');

  ws.onmessage = (event) => {
    const data = JSON.parse(event.data);
    map.getSource('live-data').setData(data);
  };
});

Smooth Transitions

Pattern: Animate property changes

// Smoothly transition circle sizes
function updateVisualization(newData) {
  map.getSource('data-source').setData(newData);

  // Animate circle radius
  const currentRadius = map.getPaintProperty('data-layer', 'circle-radius');
  const targetRadius = ['get', 'newSize'];

  // Use setPaintProperty with transition
  map.setPaintProperty('data-layer', 'circle-radius', targetRadius);

  // Or use expressions for smooth interpolation
  map.setPaintProperty('data-layer', 'circle-radius', ['interpolate', ['linear'], ['get', 'value'], 0, 2, 100, 20]);
}

Source: SKILL.md on GitHub

No alerts14d5 checks · Risk SAFE
  • Gen Agent Trust Hub14d

    The skill provides comprehensive patterns for Mapbox data visualizations. It is generally safe, but it identifies an attack surface for indirect prompt injection by demonstrating how to ingest external data and display properties in UI components without sanitization or boundary markers.

  • Socket14d

    No alerts

  • Snyk14d

    Risk: LOW · No issues

  • Runlayer6mo

    2 files scanned · No issues

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 65bab68. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 5 hours ago.

Activeupdated 6 months ago
  • mapbox
  • choropleth
  • heatmap
  • 3d-extrusion
  • data-driven-styling
  • geojson
  • vector-tiles
  • animation
  • cartography

README badge

README badge for mapbox/mapbox-agent-skills/mapbox-data-visualization-patterns

Teaches patterns for visualizing statistical and geographic data on Mapbox maps, including choropleth maps, heat maps, 3D extrusions, data-driven styling, and animation. Covers layer types, color scales, accessibility, and performance optimization for datasets up to vector tilesets.

Generated from the current SKILL.md.

Does this skill cover vector tiles or only GeoJSON?
It covers both. The skill recommends GeoJSON for datasets under 1 MB, vector tiles for datasets over 10 MB. See the performance reference file for implementation details.
What color scale strategies does this skill include?
Three main strategies: linear interpolation for continuous gradients, step intervals for discrete buckets, and match-based styling for categorical data. ColorBrewer scales are recommended for accessibility.
Does this skill cover 3D visualizations?
Yes. The skill includes patterns for 3D building extrusions and terrain elevation, with detailed implementation in the 3d-extrusions reference file.
Can this skill handle real-time or animated data?
Yes. The animation reference file covers time-series animation, real-time data updates, and smooth transitions.
What layer types are covered?
Choropleth (fill layers), heat maps, circle/bubble maps, line visualizations, and 3D extrusions. Additional patterns are available in referenced files for clustering and custom styling.

Generated from the current SKILL.md. These answers refresh after source changes.