{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"shadcn-studio/date-picker-13","type":"registry:component","title":"Date Picker 13","description":"Analytics chart with date range filter showing visitor data and interactive filtering","dependencies":["lucide-react"],"registryDependencies":["button","calendar","card","chart","popover"],"files":[{"path":"src/registry/new-york/components/date-picker/date-picker-13.tsx","content":"'use client'\n\nimport { useState, useMemo } from 'react'\n\nimport { CalendarIcon } from 'lucide-react'\nimport type { DateRange } from 'react-day-picker'\nimport { Bar, BarChart, CartesianGrid, XAxis } from 'recharts'\n\nimport { Button } from '@/registry/new-york/ui/button'\nimport { Calendar } from '@/registry/new-york/ui/calendar'\nimport {\n  Card,\n  CardAction,\n  CardContent,\n  CardDescription,\n  CardFooter,\n  CardHeader,\n  CardTitle\n} from '@/registry/new-york/ui/card'\nimport type { ChartConfig } from '@/registry/new-york/ui/chart'\nimport { ChartContainer, ChartTooltip, ChartTooltipContent } from '@/registry/new-york/ui/chart'\nimport { Popover, PopoverContent, PopoverTrigger } from '@/registry/new-york/ui/popover'\n\nconst chartData = [\n  { date: '2025-01-01', visitors: 178 },\n  { date: '2025-01-02', visitors: 470 },\n  { date: '2025-01-03', visitors: 103 },\n  { date: '2025-01-04', visitors: 439 },\n  { date: '2025-01-05', visitors: 88 },\n  { date: '2025-01-06', visitors: 294 },\n  { date: '2025-01-07', visitors: 323 },\n  { date: '2025-01-08', visitors: 385 },\n  { date: '2025-01-09', visitors: 438 },\n  { date: '2025-01-10', visitors: 155 },\n  { date: '2025-01-11', visitors: 92 },\n  { date: '2025-01-12', visitors: 492 },\n  { date: '2025-01-13', visitors: 81 },\n  { date: '2025-01-14', visitors: 426 },\n  { date: '2025-01-15', visitors: 307 },\n  { date: '2025-01-16', visitors: 371 },\n  { date: '2025-01-17', visitors: 475 },\n  { date: '2025-01-18', visitors: 107 },\n  { date: '2025-01-19', visitors: 341 },\n  { date: '2025-01-20', visitors: 408 },\n  { date: '2025-01-21', visitors: 169 },\n  { date: '2025-01-22', visitors: 317 },\n  { date: '2025-01-23', visitors: 480 },\n  { date: '2025-01-24', visitors: 132 },\n  { date: '2025-01-25', visitors: 141 },\n  { date: '2025-01-26', visitors: 434 },\n  { date: '2025-01-27', visitors: 448 },\n  { date: '2025-01-28', visitors: 149 },\n  { date: '2025-01-29', visitors: 103 },\n  { date: '2025-01-30', visitors: 446 },\n  { date: '2025-01-31', visitors: 320 }\n]\n\nconst total = chartData.reduce((acc, curr) => acc + curr.visitors, 0)\n\nconst chartConfig = {\n  visitors: {\n    label: 'Visitors',\n    color: 'var(--primary)'\n  }\n} satisfies ChartConfig\n\nconst ChartFilterDemo = () => {\n  const [range, setRange] = useState<DateRange | undefined>({\n    from: new Date(2025, 0, 1),\n    to: new Date(2025, 0, 31)\n  })\n\n  const filteredData = useMemo(() => {\n    if (!range?.from && !range?.to) {\n      return chartData\n    }\n\n    return chartData.filter(item => {\n      const date = new Date(item.date)\n\n      return date >= range.from! && date <= range.to!\n    })\n  }, [range])\n\n  return (\n    <Card className='@container/card w-full max-w-xl'>\n      <CardHeader className='flex flex-col border-b @md/card:grid'>\n        <CardTitle>Web Analytics</CardTitle>\n        <CardDescription>Showing total visitors for this month.</CardDescription>\n        <CardAction className='mt-2 @md/card:mt-0'>\n          <Popover>\n            <PopoverTrigger asChild>\n              <Button variant='outline'>\n                <CalendarIcon />\n                {range?.from && range?.to\n                  ? `${range.from.toLocaleDateString()} - ${range.to.toLocaleDateString()}`\n                  : 'January 2025'}\n              </Button>\n            </PopoverTrigger>\n            <PopoverContent className='w-auto overflow-hidden p-0' align='end'>\n              <Calendar\n                className='w-full'\n                mode='range'\n                defaultMonth={range?.from}\n                selected={range}\n                onSelect={setRange}\n                startMonth={range?.from}\n                fixedWeeks\n                showOutsideDays\n                disabled={{\n                  after: new Date(2025, 0, 31),\n                  before: new Date(2025, 0, 1)\n                }}\n              />\n            </PopoverContent>\n          </Popover>\n        </CardAction>\n      </CardHeader>\n      <CardContent className='px-4'>\n        <ChartContainer config={chartConfig} className='aspect-auto h-62 w-full'>\n          <BarChart\n            accessibilityLayer\n            data={filteredData}\n            margin={{\n              left: 12,\n              right: 12\n            }}\n          >\n            <CartesianGrid vertical={false} />\n            <XAxis\n              dataKey='date'\n              tickLine={false}\n              axisLine={false}\n              tickMargin={8}\n              minTickGap={20}\n              tickFormatter={value => {\n                const date = new Date(value)\n\n                return date.toLocaleDateString('en-US', {\n                  day: 'numeric'\n                })\n              }}\n            />\n            <ChartTooltip\n              content={\n                <ChartTooltipContent\n                  className='w-37.5'\n                  nameKey='visitors'\n                  labelFormatter={value => {\n                    return new Date(value).toLocaleDateString('en-US', {\n                      month: 'short',\n                      day: 'numeric',\n                      year: 'numeric'\n                    })\n                  }}\n                />\n              }\n            />\n            <Bar dataKey='visitors' fill={`var(--color-visitors)`} radius={4} />\n          </BarChart>\n        </ChartContainer>\n      </CardContent>\n      <CardFooter className='border-t'>\n        <div className='text-sm'>\n          You had <span className='font-semibold'>{total.toLocaleString()}</span> visitors for the month of January.\n        </div>\n      </CardFooter>\n    </Card>\n  )\n}\n\nexport default ChartFilterDemo\n","type":"registry:component","target":"components/shadcn-studio/date-picker/date-picker-13.tsx"}]}