interés de los compradores.
para atraer más visitas.
y listo para generar ofertas.
const raw = document.getElementById('property-stats').textContent const stats = JSON.parse(raw) function drawSparkline(card, pts) { if (!pts || pts.length < 2) return const w = 120, h = 32 const max = Math.max(...pts), min = Math.min(...pts) const range = max - min || 1 const coords = pts.map((v, i) => { const x = (i / (pts.length - 1)) * w const y = h - ((v - min) / range) * (h - 2) - 1 return `${x.toFixed(1)},${y.toFixed(1)}` }) const line = coords.join(' ') const fill = line + ` ${w},${h} 0,${h}` card.querySelector('.spark-line').setAttribute('points', line) card.querySelector('.spark-fill').setAttribute('points', fill) } function updateMetrics(period) { const d = stats[period] document.querySelectorAll('[data-metric]').forEach(card => { const metric = card.getAttribute('data-metric') const val = d[metric].total const pts = d[metric].points card.querySelector('.metric-value').textContent = val.toLocaleString('es-ES') drawSparkline(card, pts) }) } document.querySelectorAll('.w-tab-link').forEach(btn => { btn.addEventListener('click', () => { updateMetrics(btn.getAttribute('data-period')) }) }) // Carga 7d por defecto updateMetrics('7d')