Traffic Card
NEWA compact traffic block with a count-up visit total, a Day / Week switcher, and a stacked column chart where every channel is its own rounded capsule. Built with hand-written SVG, light and dark themes, and full keyboard support.
Traffic
Last 22 days
30,895visits
Oct 27Nov 17
| Interval | Direct | Referral | Social | Search | Paid | Total |
|---|---|---|---|---|---|---|
| Oct 27 | 242 | 396 | 455 | 347 | 293 | 1,733 |
| Oct 28 | 254 | 348 | 515 | 370 | 297 | 1,784 |
| Oct 29 | 256 | 338 | 374 | 263 | 289 | 1,520 |
| Oct 30 | 232 | 359 | 466 | 289 | 289 | 1,635 |
| Oct 31 | 206 | 305 | 327 | 298 | 225 | 1,361 |
| Nov 01 | 219 | 324 | 385 | 290 | 229 | 1,447 |
| Nov 02 | 259 | 420 | 436 | 303 | 341 | 1,759 |
| Nov 03 | 230 | 441 | 496 | 293 | 257 | 1,717 |
| Nov 04 | 177 | 330 | 352 | 278 | 225 | 1,362 |
| Nov 05 | 213 | 324 | 339 | 270 | 199 | 1,345 |
| Nov 06 | 148 | 258 | 305 | 192 | 202 | 1,105 |
| Nov 07 | 127 | 180 | 237 | 147 | 138 | 829 |
| Nov 08 | 145 | 203 | 234 | 207 | 161 | 950 |
| Nov 09 | 130 | 223 | 284 | 176 | 198 | 1,011 |
| Nov 10 | 177 | 303 | 270 | 251 | 192 | 1,193 |
| Nov 11 | 158 | 330 | 355 | 218 | 230 | 1,291 |
| Nov 12 | 191 | 292 | 304 | 217 | 248 | 1,252 |
| Nov 13 | 159 | 341 | 348 | 271 | 250 | 1,369 |
| Nov 14 | 214 | 279 | 336 | 237 | 279 | 1,345 |
| Nov 15 | 216 | 328 | 453 | 309 | 324 | 1,630 |
| Nov 16 | 215 | 379 | 385 | 252 | 231 | 1,462 |
| Nov 17 | 262 | 444 | 431 | 347 | 311 | 1,795 |
| All | 4,430 | 7,145 | 8,087 | 5,825 | 5,408 | 30,895 |
Installation
Add the component directly to your repository using shadcn CLI:
npx shadcn@latest add Surajmaurya1/easyui/traffic-card
API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
| ranges | TrafficRange[] | — | Switchable ranges, each with its own points, caption, and optional total |
| channels | TrafficChannel[] | — | Channel definitions rendered bottom-to-top in every stacked column |
| defaultRange | string | first range | Range id selected on first render |
| onRangeChange | (id: string) => void | — | Called when the visitor switches the Day / Week control |
| title | string | "Traffic" | Heading shown at the top of the card |
| unit | string | "visits" | Noun displayed beside the headline number |
| format | (n: number) => string | rounded Intl.NumberFormat | Formats the headline, tooltip values, and screen-reader table |
| height | number | 132 | Chart height in pixels |
| animated | boolean | true | Count-up and column entrance animations (disabled for reduced motion) |
| className | string | "" | Additional CSS classes for the card |
| TrafficRange.points | TrafficPoint[] | — | One column per entry, ordered oldest to newest |
| TrafficPoint.values | Record<string, number> | — | Channel id → visits for that interval |
| TrafficChannel.color | string | — | Optional CSS color; defaults to the built-in traffic palette |