Analytics Card
mapcn/analytics-cardFreeBlock
Compact analytics card with a headline metric over a world map.
Install it
npx shadcn@latest add https://mapcn.dev/r/analytics-card.jsonSource
1"use client";23import { TrendingUp } from "lucide-react";45import { Badge } from "@/components/ui/badge";6import {7 Card,8 CardAction,9 CardDescription,10 CardHeader,11 CardTitle,12} from "@/components/ui/card";13import { Map, MapGeoJSON, MapMarker, MarkerContent } from "@/components/ui/map";14import { totalVisitors, visitorGrowth, visitorLocations } from "./data";1516// Country borders from a public CDN, or swap in your own GeoJSON.17const WORLD_GEOJSON =18 "https://cdn.jsdelivr.net/gh/nvkelso/natural-earth-vector@v5.1.2/geojson/ne_110m_admin_0_countries.geojson";1920function bubbleSize(visitors: number) {21 return Math.round(10 + Math.sqrt(visitors) * 2.2);22}2324export default function Page() {25 return (26 <div className="flex min-h-screen items-center justify-center p-8">27 <Card className="relative aspect-16/10 w-full max-w-md overflow-hidden py-0">28 <div className="absolute inset-0">29 <Map30 center={[1, 30]}31 scrollZoom={false}32 dragRotate={false}33 dragPan={false}34 doubleClickZoom={false}35 pitchWithRotate={false}36 className="[&_.maplibregl-canvas]:cursor-default! [&_.maplibregl-canvas-container]:cursor-default!"37 blank38 >39 <MapGeoJSON data={WORLD_GEOJSON} linePaint={false} />40 {visitorLocations.map((location) => {41 const size = bubbleSize(location.visitors);42 return (43 <MapMarker44 key={location.city}45 longitude={location.lng}46 latitude={location.lat}47 >48 <MarkerContent className="cursor-default">49 <span50 className="bg-chart-2/80 block rounded-full"51 style={{ width: size, height: size }}52 />53 </MarkerContent>54 </MapMarker>55 );56 })}57 </Map>58 </div>5960 <CardHeader className="from-card via-card/85 to-card/0 relative z-10 gap-1 rounded-t-[inherit] bg-linear-to-b pt-4 pb-10 mask-[linear-gradient(to_bottom,black_calc(100%_-_2.5rem),transparent)] backdrop-blur-[2px]">61 <CardDescription>Visitors</CardDescription>62 <CardTitle className="text-lg tabular-nums">63 {totalVisitors}64 </CardTitle>6566 <CardAction>67 <Badge variant="outline">68 <TrendingUp />69 {visitorGrowth} growth70// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from mapcn
All 9 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Analytics Mapanalytics-map | mapcn | Blocks | Free | 2 deps · 4 files | |
| Choroplethchoropleth | mapcn | Blocks | Free | 2 deps · 3 files | |
| Delivery Trackerdelivery-tracker | mapcn | Blocks | Free | 1 dep · 2 files | |
| Heatmapheatmap | mapcn | Blocks | Free | no deps | |
| Logistics Networklogistics-network | mapcn | Blocks | Free | 1 dep · 4 files | |
| Store Locatorstore-locator | mapcn | Blocks | Free | 1 dep · 4 files | |
| Uptime Monitoruptime-monitor | mapcn | Blocks | Free | 1 dep · 4 files |
