create-huenei-template 0.2.14 → 0.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/templates.js +7 -0
- package/dist/templates/frontend/react-ssr/.cursor/agents/accessibility-reviewer.md +22 -0
- package/dist/templates/frontend/react-ssr/.cursor/agents/nextjs-code-reviewer.md +24 -0
- package/dist/templates/frontend/react-ssr/.cursor/agents/react-test-expert.md +32 -0
- package/dist/templates/frontend/react-ssr/.cursor/agents/security-auditor.md +25 -0
- package/dist/templates/frontend/react-ssr/.cursor/commands/new-component.md +97 -0
- package/dist/templates/frontend/react-ssr/.cursor/commands/new-page.md +95 -0
- package/dist/templates/frontend/react-ssr/.cursor/commands/new-prisma-model.md +66 -0
- package/dist/templates/frontend/react-ssr/.cursor/commands/new-server-action.md +89 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/auto-format.ts +64 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/auto-test-on-stop.ts +94 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/block-dangerous-commands.ts +120 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/ensure-tests-exist.ts +209 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/protect-sensitive-files.ts +101 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/session-context.ts +93 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks/tsconfig.json +10 -0
- package/dist/templates/frontend/react-ssr/.cursor/hooks.json +41 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/auth-patterns.mdc +48 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/code-quality.mdc +39 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/naming-conventions.mdc +32 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/nextjs-architecture.mdc +51 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/prisma-standards.mdc +53 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/react-conventions.mdc +52 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/testing-conventions.mdc +53 -0
- package/dist/templates/frontend/react-ssr/.cursor/rules/ui-stack.mdc +47 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/authjs-skills/SKILL.md +1149 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/SKILL.md +189 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/daisyUI5.skill +0 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/creating-components.md +412 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/data-display.md +341 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/feedback.md +240 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/input.md +283 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/layout.md +275 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/navigation.md +338 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/scripts/daisy-meta.ts +220 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/daisyui-5/scripts/generate-daisy-safelist.ts +152 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/docker-expert/SKILL.md +413 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/nextjs-app-router-patterns/SKILL.md +537 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/SKILL.md +243 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-execute.md +75 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-pull.md +185 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-push.md +148 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-seed.md +191 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/debug.md +46 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/dev.md +157 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/format.md +48 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/generate.md +147 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/init.md +118 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-deploy.md +127 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-dev.md +143 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-diff.md +89 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-reset.md +72 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-resolve.md +57 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-status.md +65 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/studio.md +122 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/validate.md +53 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/SKILL.md +216 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/client-methods.md +221 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/constructor.md +185 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/filters.md +256 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/model-queries.md +281 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/query-options.md +276 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/raw-queries.md +194 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/relations.md +308 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/transactions.md +184 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/AGENTS.md +97 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/README.md +138 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/SKILL.md +116 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/assets/templates/_template.md +26 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/_sections.md +46 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-devtools-performance.md +69 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-formprovider-memo.md +78 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-testing-wrapper.md +63 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-complete-default-objects.md +66 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-separate-crud-operations.md +76 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-unique-fieldarray-per-name.md +58 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-use-field-id-as-key.md +54 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-virtualization-formprovider.md +64 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-avoid-double-registration.md +46 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-controller-field-props.md +56 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-local-state-combination.md +69 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-single-usecontroller-per-component.md +62 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-usecontroller-isolation.md +64 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-async-default-values.md +69 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-default-values.md +57 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-revalidate-mode.md +48 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-should-unregister.md +62 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-useeffect-dependency.md +54 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-validation-mode.md +51 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-avoid-isvalid-with-onsubmit.md +58 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-destructure-formstate.md +48 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-getfieldstate-for-single-field.md +49 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-subscribe-to-specific-fields.md +54 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-useformstate-isolation.md +62 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-mui-controller-pattern.md +59 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-shadcn-form-import.md +64 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-shadcn-select-wiring.md +64 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-value-transform.md +59 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-avoid-watch-in-render.md +48 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-deep-subscription.md +62 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-useformcontext-sparingly.md +58 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-default-value.md +50 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-over-watch.md +58 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-with-getvalues.md +54 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-watch-specific-fields.md +54 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-delay-error.md +52 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-dynamic-schema-factory.md +57 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-error-message-strategy.md +65 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-inline-vs-resolver.md +63 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-native-validation.md +60 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-resolver-caching.md +58 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/recharts/SKILL.md +713 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/recharts/references/api_reference.md +1121 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/recharts/references/best_practices.md +782 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/recharts/references/examples.md +940 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/SKILL.md +114 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-gc-time.md +93 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-invalidation.md +116 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-placeholder-vs-initial.md +156 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-stale-time.md +80 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/err-error-boundaries.md +150 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/inf-page-params.md +132 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-invalidate-queries.md +118 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-mutation-state.md +169 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-optimistic-updates.md +137 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/network-mode.md +179 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/parallel-use-queries.md +152 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/perf-select-transform.md +144 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/persist-queries.md +194 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/pf-intent-prefetch.md +143 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-array-structure.md +50 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-factory-pattern.md +102 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-hierarchical-organization.md +76 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-include-dependencies.md +62 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-serializable.md +93 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/query-cancellation.md +171 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/ssr-dehydration.md +158 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/tanstack-table/SKILL.md +582 -0
- package/dist/templates/frontend/react-ssr/.cursor/skills/zod-4/SKILL.md +216 -0
- package/dist/templates/frontend/react-ssr/.dockerignore +14 -0
- package/dist/templates/frontend/react-ssr/.env.example +9 -0
- package/dist/templates/frontend/react-ssr/.husky/pre-commit +1 -0
- package/dist/templates/frontend/react-ssr/Dockerfile +41 -0
- package/dist/templates/frontend/react-ssr/README.md +121 -0
- package/dist/templates/frontend/react-ssr/components.json +22 -0
- package/dist/templates/frontend/react-ssr/docker-compose.yml +21 -0
- package/dist/templates/frontend/react-ssr/eslint.config.mjs +26 -0
- package/dist/templates/frontend/react-ssr/next.config.ts +7 -0
- package/dist/templates/frontend/react-ssr/package.json +86 -0
- package/dist/templates/frontend/react-ssr/postcss.config.mjs +5 -0
- package/dist/templates/frontend/react-ssr/prisma/schema.prisma +75 -0
- package/dist/templates/frontend/react-ssr/prisma/seed.ts +109 -0
- package/dist/templates/frontend/react-ssr/prisma.config.ts +17 -0
- package/dist/templates/frontend/react-ssr/skills-lock.json +65 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/components/ui/badge.test.tsx +26 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/components/ui/button.test.tsx +38 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/components/ui/card.test.tsx +39 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/components/ui/input.test.tsx +32 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/hooks/useLocalStorage.test.ts +53 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/lib/queryClient.test.ts +19 -0
- package/dist/templates/frontend/react-ssr/src/__tests__/lib/utils.test.ts +24 -0
- package/dist/templates/frontend/react-ssr/src/actions/auth.ts +91 -0
- package/dist/templates/frontend/react-ssr/src/actions/contacto.ts +46 -0
- package/dist/templates/frontend/react-ssr/src/actions/proyectos.ts +159 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/dashboard/dashboard-client.tsx +321 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/dashboard/page.tsx +48 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/layout.tsx +34 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/perfil/page.tsx +85 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/proyectos-crud/page.tsx +23 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/proyectos-crud/proyectos-crud-client.tsx +472 -0
- package/dist/templates/frontend/react-ssr/src/app/(authenticated)/ui-components/page.tsx +358 -0
- package/dist/templates/frontend/react-ssr/src/app/api/auth/[...nextauth]/route.ts +3 -0
- package/dist/templates/frontend/react-ssr/src/app/auth/iniciar-sesion/page.tsx +148 -0
- package/dist/templates/frontend/react-ssr/src/app/auth/recuperar-password/page.tsx +100 -0
- package/dist/templates/frontend/react-ssr/src/app/auth/registro/page.tsx +154 -0
- package/dist/templates/frontend/react-ssr/src/app/contacto/contacto-form.tsx +189 -0
- package/dist/templates/frontend/react-ssr/src/app/contacto/page.tsx +11 -0
- package/dist/templates/frontend/react-ssr/src/app/globals.css +99 -0
- package/dist/templates/frontend/react-ssr/src/app/layout.tsx +22 -0
- package/dist/templates/frontend/react-ssr/src/app/loading.tsx +7 -0
- package/dist/templates/frontend/react-ssr/src/app/not-found.tsx +14 -0
- package/dist/templates/frontend/react-ssr/src/app/page.tsx +331 -0
- package/dist/templates/frontend/react-ssr/src/app/proyectos/page.tsx +178 -0
- package/dist/templates/frontend/react-ssr/src/auth.ts +64 -0
- package/dist/templates/frontend/react-ssr/src/components/layout/navbar.tsx +68 -0
- package/dist/templates/frontend/react-ssr/src/components/layout/sidebar.tsx +109 -0
- package/dist/templates/frontend/react-ssr/src/components/layout/sign-out-button.tsx +16 -0
- package/dist/templates/frontend/react-ssr/src/components/providers.tsx +33 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/avatar.tsx +53 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/badge.tsx +42 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/breadcrumb.tsx +114 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/button.tsx +58 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/card.tsx +95 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/dialog.tsx +136 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/form.tsx +168 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/input.tsx +22 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/label.tsx +26 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/password-input.tsx +43 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/separator.tsx +30 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/table.tsx +240 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/tabs.tsx +76 -0
- package/dist/templates/frontend/react-ssr/src/components/ui/textarea.tsx +21 -0
- package/dist/templates/frontend/react-ssr/src/data/dashboard.ts +179 -0
- package/dist/templates/frontend/react-ssr/src/hooks/useLocalStorage.ts +38 -0
- package/dist/templates/frontend/react-ssr/src/lib/prisma.ts +24 -0
- package/dist/templates/frontend/react-ssr/src/lib/queryClient.ts +25 -0
- package/dist/templates/frontend/react-ssr/src/lib/utils.ts +6 -0
- package/dist/templates/frontend/react-ssr/src/proxy.ts +31 -0
- package/dist/templates/frontend/react-ssr/src/test/mocks/next-navigation.ts +16 -0
- package/dist/templates/frontend/react-ssr/src/test/setup.ts +1 -0
- package/dist/templates/frontend/react-ssr/src/test/utils.tsx +30 -0
- package/dist/templates/frontend/react-ssr/src/types/index.ts +36 -0
- package/dist/templates/frontend/react-ssr/tsconfig.json +41 -0
- package/dist/templates/frontend/react-ssr/vitest.config.ts +41 -0
- package/package.json +1 -1
- package/templates/frontend/react-ssr/.cursor/agents/accessibility-reviewer.md +22 -0
- package/templates/frontend/react-ssr/.cursor/agents/nextjs-code-reviewer.md +24 -0
- package/templates/frontend/react-ssr/.cursor/agents/react-test-expert.md +32 -0
- package/templates/frontend/react-ssr/.cursor/agents/security-auditor.md +25 -0
- package/templates/frontend/react-ssr/.cursor/commands/new-component.md +97 -0
- package/templates/frontend/react-ssr/.cursor/commands/new-page.md +95 -0
- package/templates/frontend/react-ssr/.cursor/commands/new-prisma-model.md +66 -0
- package/templates/frontend/react-ssr/.cursor/commands/new-server-action.md +89 -0
- package/templates/frontend/react-ssr/.cursor/hooks/auto-format.ts +64 -0
- package/templates/frontend/react-ssr/.cursor/hooks/auto-test-on-stop.ts +94 -0
- package/templates/frontend/react-ssr/.cursor/hooks/block-dangerous-commands.ts +120 -0
- package/templates/frontend/react-ssr/.cursor/hooks/ensure-tests-exist.ts +209 -0
- package/templates/frontend/react-ssr/.cursor/hooks/protect-sensitive-files.ts +101 -0
- package/templates/frontend/react-ssr/.cursor/hooks/session-context.ts +93 -0
- package/templates/frontend/react-ssr/.cursor/hooks/tsconfig.json +10 -0
- package/templates/frontend/react-ssr/.cursor/hooks.json +41 -0
- package/templates/frontend/react-ssr/.cursor/rules/auth-patterns.mdc +48 -0
- package/templates/frontend/react-ssr/.cursor/rules/code-quality.mdc +39 -0
- package/templates/frontend/react-ssr/.cursor/rules/naming-conventions.mdc +32 -0
- package/templates/frontend/react-ssr/.cursor/rules/nextjs-architecture.mdc +51 -0
- package/templates/frontend/react-ssr/.cursor/rules/prisma-standards.mdc +53 -0
- package/templates/frontend/react-ssr/.cursor/rules/react-conventions.mdc +52 -0
- package/templates/frontend/react-ssr/.cursor/rules/testing-conventions.mdc +53 -0
- package/templates/frontend/react-ssr/.cursor/rules/ui-stack.mdc +47 -0
- package/templates/frontend/react-ssr/.cursor/skills/authjs-skills/SKILL.md +1149 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/SKILL.md +189 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/daisyUI5.skill +0 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/creating-components.md +412 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/data-display.md +341 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/feedback.md +240 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/input.md +283 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/layout.md +275 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/references/navigation.md +338 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/scripts/daisy-meta.ts +220 -0
- package/templates/frontend/react-ssr/.cursor/skills/daisyui-5/scripts/generate-daisy-safelist.ts +152 -0
- package/templates/frontend/react-ssr/.cursor/skills/docker-expert/SKILL.md +413 -0
- package/templates/frontend/react-ssr/.cursor/skills/nextjs-app-router-patterns/SKILL.md +537 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/SKILL.md +243 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-execute.md +75 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-pull.md +185 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-push.md +148 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/db-seed.md +191 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/debug.md +46 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/dev.md +157 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/format.md +48 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/generate.md +147 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/init.md +118 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-deploy.md +127 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-dev.md +143 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-diff.md +89 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-reset.md +72 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-resolve.md +57 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/migrate-status.md +65 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/studio.md +122 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-cli/references/validate.md +53 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/SKILL.md +216 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/client-methods.md +221 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/constructor.md +185 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/filters.md +256 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/model-queries.md +281 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/query-options.md +276 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/raw-queries.md +194 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/relations.md +308 -0
- package/templates/frontend/react-ssr/.cursor/skills/prisma-client-api/references/transactions.md +184 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/AGENTS.md +97 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/README.md +138 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/SKILL.md +116 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/assets/templates/_template.md +26 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/_sections.md +46 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-devtools-performance.md +69 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-formprovider-memo.md +78 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/adv-testing-wrapper.md +63 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-complete-default-objects.md +66 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-separate-crud-operations.md +76 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-unique-fieldarray-per-name.md +58 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-use-field-id-as-key.md +54 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/array-virtualization-formprovider.md +64 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-avoid-double-registration.md +46 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-controller-field-props.md +56 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-local-state-combination.md +69 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-single-usecontroller-per-component.md +62 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/ctrl-usecontroller-isolation.md +64 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-async-default-values.md +69 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-default-values.md +57 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-revalidate-mode.md +48 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-should-unregister.md +62 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-useeffect-dependency.md +54 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formcfg-validation-mode.md +51 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-avoid-isvalid-with-onsubmit.md +58 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-destructure-formstate.md +48 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-getfieldstate-for-single-field.md +49 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-subscribe-to-specific-fields.md +54 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/formstate-useformstate-isolation.md +62 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-mui-controller-pattern.md +59 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-shadcn-form-import.md +64 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-shadcn-select-wiring.md +64 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/integ-value-transform.md +59 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-avoid-watch-in-render.md +48 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-deep-subscription.md +62 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-useformcontext-sparingly.md +58 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-default-value.md +50 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-over-watch.md +58 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-usewatch-with-getvalues.md +54 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/sub-watch-specific-fields.md +54 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-delay-error.md +52 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-dynamic-schema-factory.md +57 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-error-message-strategy.md +65 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-inline-vs-resolver.md +63 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-native-validation.md +60 -0
- package/templates/frontend/react-ssr/.cursor/skills/react-hook-form/references/valid-resolver-caching.md +58 -0
- package/templates/frontend/react-ssr/.cursor/skills/recharts/SKILL.md +713 -0
- package/templates/frontend/react-ssr/.cursor/skills/recharts/references/api_reference.md +1121 -0
- package/templates/frontend/react-ssr/.cursor/skills/recharts/references/best_practices.md +782 -0
- package/templates/frontend/react-ssr/.cursor/skills/recharts/references/examples.md +940 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/SKILL.md +114 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-gc-time.md +93 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-invalidation.md +116 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-placeholder-vs-initial.md +156 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/cache-stale-time.md +80 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/err-error-boundaries.md +150 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/inf-page-params.md +132 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-invalidate-queries.md +118 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-mutation-state.md +169 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/mut-optimistic-updates.md +137 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/network-mode.md +179 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/parallel-use-queries.md +152 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/perf-select-transform.md +144 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/persist-queries.md +194 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/pf-intent-prefetch.md +143 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-array-structure.md +50 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-factory-pattern.md +102 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-hierarchical-organization.md +76 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-include-dependencies.md +62 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/qk-serializable.md +93 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/query-cancellation.md +171 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-query-best-practices/rules/ssr-dehydration.md +158 -0
- package/templates/frontend/react-ssr/.cursor/skills/tanstack-table/SKILL.md +582 -0
- package/templates/frontend/react-ssr/.cursor/skills/zod-4/SKILL.md +216 -0
- package/templates/frontend/react-ssr/.dockerignore +14 -0
- package/templates/frontend/react-ssr/.env.example +9 -0
- package/templates/frontend/react-ssr/.husky/pre-commit +1 -0
- package/templates/frontend/react-ssr/Dockerfile +41 -0
- package/templates/frontend/react-ssr/README.md +121 -0
- package/templates/frontend/react-ssr/components.json +22 -0
- package/templates/frontend/react-ssr/docker-compose.yml +21 -0
- package/templates/frontend/react-ssr/eslint.config.mjs +26 -0
- package/templates/frontend/react-ssr/next.config.ts +7 -0
- package/templates/frontend/react-ssr/package.json +86 -0
- package/templates/frontend/react-ssr/postcss.config.mjs +5 -0
- package/templates/frontend/react-ssr/prisma/schema.prisma +75 -0
- package/templates/frontend/react-ssr/prisma/seed.ts +109 -0
- package/templates/frontend/react-ssr/prisma.config.ts +17 -0
- package/templates/frontend/react-ssr/skills-lock.json +65 -0
- package/templates/frontend/react-ssr/src/__tests__/components/ui/badge.test.tsx +26 -0
- package/templates/frontend/react-ssr/src/__tests__/components/ui/button.test.tsx +38 -0
- package/templates/frontend/react-ssr/src/__tests__/components/ui/card.test.tsx +39 -0
- package/templates/frontend/react-ssr/src/__tests__/components/ui/input.test.tsx +32 -0
- package/templates/frontend/react-ssr/src/__tests__/hooks/useLocalStorage.test.ts +53 -0
- package/templates/frontend/react-ssr/src/__tests__/lib/queryClient.test.ts +19 -0
- package/templates/frontend/react-ssr/src/__tests__/lib/utils.test.ts +24 -0
- package/templates/frontend/react-ssr/src/actions/auth.ts +91 -0
- package/templates/frontend/react-ssr/src/actions/contacto.ts +46 -0
- package/templates/frontend/react-ssr/src/actions/proyectos.ts +159 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/dashboard/dashboard-client.tsx +321 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/dashboard/page.tsx +48 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/layout.tsx +34 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/perfil/page.tsx +85 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/proyectos-crud/page.tsx +23 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/proyectos-crud/proyectos-crud-client.tsx +472 -0
- package/templates/frontend/react-ssr/src/app/(authenticated)/ui-components/page.tsx +358 -0
- package/templates/frontend/react-ssr/src/app/api/auth/[...nextauth]/route.ts +3 -0
- package/templates/frontend/react-ssr/src/app/auth/iniciar-sesion/page.tsx +148 -0
- package/templates/frontend/react-ssr/src/app/auth/recuperar-password/page.tsx +100 -0
- package/templates/frontend/react-ssr/src/app/auth/registro/page.tsx +154 -0
- package/templates/frontend/react-ssr/src/app/contacto/contacto-form.tsx +189 -0
- package/templates/frontend/react-ssr/src/app/contacto/page.tsx +11 -0
- package/templates/frontend/react-ssr/src/app/globals.css +99 -0
- package/templates/frontend/react-ssr/src/app/layout.tsx +22 -0
- package/templates/frontend/react-ssr/src/app/loading.tsx +7 -0
- package/templates/frontend/react-ssr/src/app/not-found.tsx +14 -0
- package/templates/frontend/react-ssr/src/app/page.tsx +331 -0
- package/templates/frontend/react-ssr/src/app/proyectos/page.tsx +178 -0
- package/templates/frontend/react-ssr/src/auth.ts +64 -0
- package/templates/frontend/react-ssr/src/components/layout/navbar.tsx +68 -0
- package/templates/frontend/react-ssr/src/components/layout/sidebar.tsx +109 -0
- package/templates/frontend/react-ssr/src/components/layout/sign-out-button.tsx +16 -0
- package/templates/frontend/react-ssr/src/components/providers.tsx +33 -0
- package/templates/frontend/react-ssr/src/components/ui/avatar.tsx +53 -0
- package/templates/frontend/react-ssr/src/components/ui/badge.tsx +42 -0
- package/templates/frontend/react-ssr/src/components/ui/breadcrumb.tsx +114 -0
- package/templates/frontend/react-ssr/src/components/ui/button.tsx +58 -0
- package/templates/frontend/react-ssr/src/components/ui/card.tsx +95 -0
- package/templates/frontend/react-ssr/src/components/ui/dialog.tsx +136 -0
- package/templates/frontend/react-ssr/src/components/ui/form.tsx +168 -0
- package/templates/frontend/react-ssr/src/components/ui/input.tsx +22 -0
- package/templates/frontend/react-ssr/src/components/ui/label.tsx +26 -0
- package/templates/frontend/react-ssr/src/components/ui/password-input.tsx +43 -0
- package/templates/frontend/react-ssr/src/components/ui/separator.tsx +30 -0
- package/templates/frontend/react-ssr/src/components/ui/table.tsx +240 -0
- package/templates/frontend/react-ssr/src/components/ui/tabs.tsx +76 -0
- package/templates/frontend/react-ssr/src/components/ui/textarea.tsx +21 -0
- package/templates/frontend/react-ssr/src/data/dashboard.ts +179 -0
- package/templates/frontend/react-ssr/src/hooks/useLocalStorage.ts +38 -0
- package/templates/frontend/react-ssr/src/lib/prisma.ts +24 -0
- package/templates/frontend/react-ssr/src/lib/queryClient.ts +25 -0
- package/templates/frontend/react-ssr/src/lib/utils.ts +6 -0
- package/templates/frontend/react-ssr/src/proxy.ts +31 -0
- package/templates/frontend/react-ssr/src/test/mocks/next-navigation.ts +16 -0
- package/templates/frontend/react-ssr/src/test/setup.ts +1 -0
- package/templates/frontend/react-ssr/src/test/utils.tsx +30 -0
- package/templates/frontend/react-ssr/src/types/index.ts +36 -0
- package/templates/frontend/react-ssr/tsconfig.json +41 -0
- package/templates/frontend/react-ssr/vitest.config.ts +41 -0
|
@@ -0,0 +1,940 @@
|
|
|
1
|
+
# Recharts Examples
|
|
2
|
+
|
|
3
|
+
Common chart patterns and implementation examples.
|
|
4
|
+
|
|
5
|
+
> **Note**: Examples below use `ResponsiveContainer` for broad compatibility. In Recharts 3.3+, you can use the `responsive` prop instead:
|
|
6
|
+
> ```jsx
|
|
7
|
+
> <LineChart data={data} responsive style={{ width: '100%', height: 300 }}>
|
|
8
|
+
> ```
|
|
9
|
+
|
|
10
|
+
## Table of Contents
|
|
11
|
+
|
|
12
|
+
1. [Line Chart Patterns](#line-chart-patterns)
|
|
13
|
+
2. [Bar Chart Patterns](#bar-chart-patterns)
|
|
14
|
+
3. [Area Chart Patterns](#area-chart-patterns)
|
|
15
|
+
4. [Pie Chart Patterns](#pie-chart-patterns)
|
|
16
|
+
5. [Scatter Chart Patterns](#scatter-chart-patterns)
|
|
17
|
+
6. [Composed Chart Patterns](#composed-chart-patterns)
|
|
18
|
+
7. [Advanced Patterns](#advanced-patterns)
|
|
19
|
+
|
|
20
|
+
## Line Chart Patterns
|
|
21
|
+
|
|
22
|
+
### Basic Line Chart
|
|
23
|
+
|
|
24
|
+
```jsx
|
|
25
|
+
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts';
|
|
26
|
+
|
|
27
|
+
const data = [
|
|
28
|
+
{ month: 'Jan', sales: 4000, profit: 2400 },
|
|
29
|
+
{ month: 'Feb', sales: 3000, profit: 1398 },
|
|
30
|
+
{ month: 'Mar', sales: 2000, profit: 9800 },
|
|
31
|
+
{ month: 'Apr', sales: 2780, profit: 3908 },
|
|
32
|
+
{ month: 'May', sales: 1890, profit: 4800 },
|
|
33
|
+
{ month: 'Jun', sales: 2390, profit: 3800 },
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
function SimpleLineChart() {
|
|
37
|
+
return (
|
|
38
|
+
<ResponsiveContainer width="100%" height={300}>
|
|
39
|
+
<LineChart data={data}>
|
|
40
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
41
|
+
<XAxis dataKey="month" />
|
|
42
|
+
<YAxis />
|
|
43
|
+
<Tooltip />
|
|
44
|
+
<Legend />
|
|
45
|
+
<Line type="monotone" dataKey="sales" stroke="#8884d8" />
|
|
46
|
+
<Line type="monotone" dataKey="profit" stroke="#82ca9d" />
|
|
47
|
+
</LineChart>
|
|
48
|
+
</ResponsiveContainer>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Dashed Line Chart
|
|
54
|
+
|
|
55
|
+
```jsx
|
|
56
|
+
<LineChart data={data}>
|
|
57
|
+
<XAxis dataKey="month" />
|
|
58
|
+
<YAxis />
|
|
59
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
60
|
+
<Tooltip />
|
|
61
|
+
<Line
|
|
62
|
+
type="monotone"
|
|
63
|
+
dataKey="sales"
|
|
64
|
+
stroke="#8884d8"
|
|
65
|
+
strokeDasharray="5 5" // Dashed pattern
|
|
66
|
+
/>
|
|
67
|
+
</LineChart>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Vertical Line Chart
|
|
71
|
+
|
|
72
|
+
```jsx
|
|
73
|
+
<LineChart layout="vertical" data={data}>
|
|
74
|
+
<XAxis type="number" />
|
|
75
|
+
<YAxis type="category" dataKey="month" />
|
|
76
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
77
|
+
<Tooltip />
|
|
78
|
+
<Legend />
|
|
79
|
+
<Line type="monotone" dataKey="sales" stroke="#8884d8" />
|
|
80
|
+
</LineChart>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Line Chart with Custom Dots
|
|
84
|
+
|
|
85
|
+
```jsx
|
|
86
|
+
const CustomDot = (props) => {
|
|
87
|
+
const { cx, cy, stroke, payload, value } = props;
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<svg x={cx - 10} y={cy - 10} width={20} height={20} fill={stroke} viewBox="0 0 1024 1024">
|
|
91
|
+
<path d="M512 0C229.25 0 0 229.25 0 512s229.25 512 512 512 512-229.25 512-512S794.75 0 512 0z" />
|
|
92
|
+
</svg>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
<LineChart data={data}>
|
|
97
|
+
<XAxis dataKey="month" />
|
|
98
|
+
<YAxis />
|
|
99
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
100
|
+
<Tooltip />
|
|
101
|
+
<Line
|
|
102
|
+
type="monotone"
|
|
103
|
+
dataKey="sales"
|
|
104
|
+
stroke="#8884d8"
|
|
105
|
+
dot={<CustomDot />}
|
|
106
|
+
activeDot={{ r: 8 }}
|
|
107
|
+
/>
|
|
108
|
+
</LineChart>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Synchronized Multi-Chart
|
|
112
|
+
|
|
113
|
+
```jsx
|
|
114
|
+
<>
|
|
115
|
+
<ResponsiveContainer width="100%" height={200}>
|
|
116
|
+
<LineChart data={data} syncId="salesSync">
|
|
117
|
+
<XAxis dataKey="month" />
|
|
118
|
+
<YAxis />
|
|
119
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
120
|
+
<Tooltip />
|
|
121
|
+
<Line type="monotone" dataKey="sales" stroke="#8884d8" />
|
|
122
|
+
</LineChart>
|
|
123
|
+
</ResponsiveContainer>
|
|
124
|
+
|
|
125
|
+
<ResponsiveContainer width="100%" height={200}>
|
|
126
|
+
<LineChart data={data} syncId="salesSync">
|
|
127
|
+
<XAxis dataKey="month" />
|
|
128
|
+
<YAxis />
|
|
129
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
130
|
+
<Tooltip />
|
|
131
|
+
<Line type="monotone" dataKey="profit" stroke="#82ca9d" />
|
|
132
|
+
</LineChart>
|
|
133
|
+
</ResponsiveContainer>
|
|
134
|
+
|
|
135
|
+
<p>Charts share synchronized tooltips</p>
|
|
136
|
+
</>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Highlight and Zoom
|
|
140
|
+
|
|
141
|
+
```jsx
|
|
142
|
+
import { useState } from 'react';
|
|
143
|
+
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Brush } from 'recharts';
|
|
144
|
+
|
|
145
|
+
function HighlightZoomChart({ data }) {
|
|
146
|
+
const [refAreaLeft, setRefAreaLeft] = useState('');
|
|
147
|
+
const [refAreaRight, setRefAreaRight] = useState('');
|
|
148
|
+
const [zoomData, setZoomData] = useState(data);
|
|
149
|
+
|
|
150
|
+
const zoom = () => {
|
|
151
|
+
if (refAreaLeft === refAreaRight || refAreaRight === '') {
|
|
152
|
+
setRefAreaLeft('');
|
|
153
|
+
setRefAreaRight('');
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Filter data between selected range
|
|
158
|
+
const left = Math.min(refAreaLeft, refAreaRight);
|
|
159
|
+
const right = Math.max(refAreaLeft, refAreaRight);
|
|
160
|
+
|
|
161
|
+
const newData = data.filter(
|
|
162
|
+
(d) => d.index >= left && d.index <= right
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
setZoomData(newData);
|
|
166
|
+
setRefAreaLeft('');
|
|
167
|
+
setRefAreaRight('');
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
return (
|
|
171
|
+
<LineChart
|
|
172
|
+
data={zoomData}
|
|
173
|
+
onMouseDown={(e) => e && setRefAreaLeft(e.activeLabel)}
|
|
174
|
+
onMouseMove={(e) => e && refAreaLeft && setRefAreaRight(e.activeLabel)}
|
|
175
|
+
onMouseUp={zoom}
|
|
176
|
+
>
|
|
177
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
178
|
+
<XAxis dataKey="name" allowDataOverflow />
|
|
179
|
+
<YAxis allowDataOverflow />
|
|
180
|
+
<Tooltip />
|
|
181
|
+
<Line type="monotone" dataKey="value" stroke="#8884d8" />
|
|
182
|
+
|
|
183
|
+
{refAreaLeft && refAreaRight && (
|
|
184
|
+
<ReferenceArea
|
|
185
|
+
x1={refAreaLeft}
|
|
186
|
+
x2={refAreaRight}
|
|
187
|
+
strokeOpacity={0.3}
|
|
188
|
+
/>
|
|
189
|
+
)}
|
|
190
|
+
</LineChart>
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Bar Chart Patterns
|
|
196
|
+
|
|
197
|
+
### Basic Bar Chart
|
|
198
|
+
|
|
199
|
+
```jsx
|
|
200
|
+
import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts';
|
|
201
|
+
|
|
202
|
+
function SimpleBarChart() {
|
|
203
|
+
return (
|
|
204
|
+
<ResponsiveContainer width="100%" height={300}>
|
|
205
|
+
<BarChart data={data}>
|
|
206
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
207
|
+
<XAxis dataKey="month" />
|
|
208
|
+
<YAxis />
|
|
209
|
+
<Tooltip />
|
|
210
|
+
<Legend />
|
|
211
|
+
<Bar dataKey="sales" fill="#8884d8" />
|
|
212
|
+
<Bar dataKey="profit" fill="#82ca9d" />
|
|
213
|
+
</BarChart>
|
|
214
|
+
</ResponsiveContainer>
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Stacked Bar Chart
|
|
220
|
+
|
|
221
|
+
```jsx
|
|
222
|
+
<BarChart data={data}>
|
|
223
|
+
<XAxis dataKey="month" />
|
|
224
|
+
<YAxis />
|
|
225
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
226
|
+
<Tooltip />
|
|
227
|
+
<Legend />
|
|
228
|
+
<Bar dataKey="sales" stackId="a" fill="#8884d8" />
|
|
229
|
+
<Bar dataKey="profit" stackId="a" fill="#82ca9d" />
|
|
230
|
+
<Bar dataKey="expenses" stackId="a" fill="#ffc658" />
|
|
231
|
+
</BarChart>
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Horizontal Bar Chart
|
|
235
|
+
|
|
236
|
+
```jsx
|
|
237
|
+
<BarChart layout="vertical" data={data}>
|
|
238
|
+
<XAxis type="number" />
|
|
239
|
+
<YAxis type="category" dataKey="month" />
|
|
240
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
241
|
+
<Tooltip />
|
|
242
|
+
<Legend />
|
|
243
|
+
<Bar dataKey="sales" fill="#8884d8" />
|
|
244
|
+
</BarChart>
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Grouped Bar Chart
|
|
248
|
+
|
|
249
|
+
```jsx
|
|
250
|
+
<BarChart data={data}>
|
|
251
|
+
<XAxis dataKey="month" />
|
|
252
|
+
<YAxis />
|
|
253
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
254
|
+
<Tooltip />
|
|
255
|
+
<Legend />
|
|
256
|
+
{/* No stackId = side by side */}
|
|
257
|
+
<Bar dataKey="sales" fill="#8884d8" />
|
|
258
|
+
<Bar dataKey="profit" fill="#82ca9d" />
|
|
259
|
+
</BarChart>
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Bar Chart with Custom Shape
|
|
263
|
+
|
|
264
|
+
```jsx
|
|
265
|
+
const CustomBarShape = (props) => {
|
|
266
|
+
const { fill, x, y, width, height } = props;
|
|
267
|
+
|
|
268
|
+
return (
|
|
269
|
+
<g>
|
|
270
|
+
<rect x={x} y={y} width={width} height={height} rx={5} ry={5} fill={fill} />
|
|
271
|
+
<text x={x + width / 2} y={y - 5} textAnchor="middle" fill="#666">
|
|
272
|
+
{props.value}
|
|
273
|
+
</text>
|
|
274
|
+
</g>
|
|
275
|
+
);
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
<BarChart data={data}>
|
|
279
|
+
<XAxis dataKey="month" />
|
|
280
|
+
<YAxis />
|
|
281
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
282
|
+
<Tooltip />
|
|
283
|
+
<Bar dataKey="sales" fill="#8884d8" shape={<CustomBarShape />} />
|
|
284
|
+
</BarChart>
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Rounded Corners
|
|
288
|
+
|
|
289
|
+
```jsx
|
|
290
|
+
<BarChart data={data}>
|
|
291
|
+
<XAxis dataKey="month" />
|
|
292
|
+
<YAxis />
|
|
293
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
294
|
+
<Tooltip />
|
|
295
|
+
<Bar
|
|
296
|
+
dataKey="sales"
|
|
297
|
+
fill="#8884d8"
|
|
298
|
+
radius={[4, 4, 0, 0]} // [topLeft, topRight, bottomRight, bottomLeft]
|
|
299
|
+
/>
|
|
300
|
+
</BarChart>
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### Brush-enabled Bar Chart
|
|
304
|
+
|
|
305
|
+
```jsx
|
|
306
|
+
<BarChart data={data}>
|
|
307
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
308
|
+
<XAxis dataKey="name" />
|
|
309
|
+
<YAxis />
|
|
310
|
+
<Tooltip />
|
|
311
|
+
<Legend />
|
|
312
|
+
<Bar dataKey="pv" fill="#8884d8" />
|
|
313
|
+
<Bar dataKey="uv" fill="#82ca9d" />
|
|
314
|
+
<Brush dataKey="name" height={30} stroke="#8884d8" />
|
|
315
|
+
</BarChart>
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
## Area Chart Patterns
|
|
319
|
+
|
|
320
|
+
### Basic Area Chart
|
|
321
|
+
|
|
322
|
+
```jsx
|
|
323
|
+
import { AreaChart, Area, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts';
|
|
324
|
+
|
|
325
|
+
function SimpleAreaChart() {
|
|
326
|
+
return (
|
|
327
|
+
<ResponsiveContainer width="100%" height={300}>
|
|
328
|
+
<AreaChart data={data}>
|
|
329
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
330
|
+
<XAxis dataKey="month" />
|
|
331
|
+
<YAxis />
|
|
332
|
+
<Tooltip />
|
|
333
|
+
<Area type="monotone" dataKey="sales" stroke="#8884d8" fill="#8884d8" />
|
|
334
|
+
</AreaChart>
|
|
335
|
+
</ResponsiveContainer>
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### Area Chart with Gradient
|
|
341
|
+
|
|
342
|
+
```jsx
|
|
343
|
+
<AreaChart data={data}>
|
|
344
|
+
<defs>
|
|
345
|
+
<linearGradient id="colorSales" x1="0" y1="0" x2="0" y2="1">
|
|
346
|
+
<stop offset="5%" stopColor="#8884d8" stopOpacity={0.8}/>
|
|
347
|
+
<stop offset="95%" stopColor="#8884d8" stopOpacity={0}/>
|
|
348
|
+
</linearGradient>
|
|
349
|
+
</defs>
|
|
350
|
+
<XAxis dataKey="month" />
|
|
351
|
+
<YAxis />
|
|
352
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
353
|
+
<Tooltip />
|
|
354
|
+
<Area
|
|
355
|
+
type="monotone"
|
|
356
|
+
dataKey="sales"
|
|
357
|
+
stroke="#8884d8"
|
|
358
|
+
fillOpacity={1}
|
|
359
|
+
fill="url(#colorSales)"
|
|
360
|
+
/>
|
|
361
|
+
</AreaChart>
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Stacked Area Chart
|
|
365
|
+
|
|
366
|
+
```jsx
|
|
367
|
+
<AreaChart data={data}>
|
|
368
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
369
|
+
<XAxis dataKey="month" />
|
|
370
|
+
<YAxis />
|
|
371
|
+
<Tooltip />
|
|
372
|
+
<Legend />
|
|
373
|
+
<Area
|
|
374
|
+
type="monotone"
|
|
375
|
+
dataKey="sales"
|
|
376
|
+
stackId="1"
|
|
377
|
+
stroke="#8884d8"
|
|
378
|
+
fill="#8884d8"
|
|
379
|
+
/>
|
|
380
|
+
<Area
|
|
381
|
+
type="monotone"
|
|
382
|
+
dataKey="profit"
|
|
383
|
+
stackId="1"
|
|
384
|
+
stroke="#82ca9d"
|
|
385
|
+
fill="#82ca9d"
|
|
386
|
+
/>
|
|
387
|
+
</AreaChart>
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
### Percent Area Chart
|
|
391
|
+
|
|
392
|
+
```jsx
|
|
393
|
+
<AreaChart data={data} stackOffset="expand">
|
|
394
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
395
|
+
<XAxis dataKey="month" />
|
|
396
|
+
<YAxis tickFormatter={(value) => `${(value * 100).toFixed(0)}%`} />
|
|
397
|
+
<Tooltip formatter={(value) => `${(value * 100).toFixed(0)}%`} />
|
|
398
|
+
<Legend />
|
|
399
|
+
<Area type="monotone" dataKey="sales" stackId="1" stroke="#8884d8" fill="#8884d8" />
|
|
400
|
+
<Area type="monotone" dataKey="profit" stackId="1" stroke="#82ca9d" fill="#82ca9d" />
|
|
401
|
+
</AreaChart>
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
## Pie Chart Patterns
|
|
405
|
+
|
|
406
|
+
### Basic Pie Chart
|
|
407
|
+
|
|
408
|
+
```jsx
|
|
409
|
+
import { PieChart, Pie, Sector, Tooltip, Legend, ResponsiveContainer } from 'recharts';
|
|
410
|
+
|
|
411
|
+
const data = [
|
|
412
|
+
{ name: 'Group A', value: 400 },
|
|
413
|
+
{ name: 'Group B', value: 300 },
|
|
414
|
+
{ name: 'Group C', value: 300 },
|
|
415
|
+
{ name: 'Group D', value: 200 },
|
|
416
|
+
];
|
|
417
|
+
|
|
418
|
+
const COLORS = ['#0088FE', '#00C49F', '#FFBB28', '#FF8042'];
|
|
419
|
+
|
|
420
|
+
function SimplePieChart() {
|
|
421
|
+
return (
|
|
422
|
+
<ResponsiveContainer width="100%" height={300}>
|
|
423
|
+
<PieChart>
|
|
424
|
+
<Pie
|
|
425
|
+
data={data}
|
|
426
|
+
cx="50%"
|
|
427
|
+
cy="50%"
|
|
428
|
+
labelLine={false}
|
|
429
|
+
label={({ name, percent }) => `${name} ${(percent * 100).toFixed(0)}%`}
|
|
430
|
+
outerRadius={80}
|
|
431
|
+
dataKey="value"
|
|
432
|
+
shape={(props) => <Sector {...props} fill={COLORS[props.index % COLORS.length]} />}
|
|
433
|
+
/>
|
|
434
|
+
<Tooltip />
|
|
435
|
+
<Legend />
|
|
436
|
+
</PieChart>
|
|
437
|
+
</ResponsiveContainer>
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
### Donut Chart
|
|
443
|
+
|
|
444
|
+
```jsx
|
|
445
|
+
<PieChart>
|
|
446
|
+
<Pie
|
|
447
|
+
data={data}
|
|
448
|
+
cx="50%"
|
|
449
|
+
cy="50%"
|
|
450
|
+
innerRadius={60}
|
|
451
|
+
outerRadius={80}
|
|
452
|
+
paddingAngle={5}
|
|
453
|
+
dataKey="value"
|
|
454
|
+
shape={(props) => <Sector {...props} fill={COLORS[props.index % COLORS.length]} />}
|
|
455
|
+
/>
|
|
456
|
+
<Tooltip />
|
|
457
|
+
</PieChart>
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
### Two-Level Pie Chart
|
|
461
|
+
|
|
462
|
+
```jsx
|
|
463
|
+
<PieChart>
|
|
464
|
+
<Pie
|
|
465
|
+
data={data01}
|
|
466
|
+
dataKey="value"
|
|
467
|
+
nameKey="name"
|
|
468
|
+
cx="50%"
|
|
469
|
+
cy="50%"
|
|
470
|
+
outerRadius={50}
|
|
471
|
+
fill="#8884d8"
|
|
472
|
+
/>
|
|
473
|
+
<Pie
|
|
474
|
+
data={data02}
|
|
475
|
+
dataKey="value"
|
|
476
|
+
nameKey="name"
|
|
477
|
+
cx="50%"
|
|
478
|
+
cy="50%"
|
|
479
|
+
innerRadius={60}
|
|
480
|
+
outerRadius={80}
|
|
481
|
+
fill="#82ca9d"
|
|
482
|
+
label
|
|
483
|
+
/>
|
|
484
|
+
</PieChart>
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
### Pie Chart with Active Slice
|
|
488
|
+
|
|
489
|
+
```jsx
|
|
490
|
+
import { PieChart, Pie, Sector, Tooltip } from 'recharts';
|
|
491
|
+
|
|
492
|
+
// Use the `shape` prop with `isActive` to render active/inactive slices differently.
|
|
493
|
+
// `activeShape` and `activeIndex` props are deprecated — use `shape` instead.
|
|
494
|
+
|
|
495
|
+
const renderShape = (props) => {
|
|
496
|
+
const { cx, cy, midAngle, innerRadius, outerRadius, startAngle, endAngle, fill, payload, percent, value, isActive } = props;
|
|
497
|
+
|
|
498
|
+
if (!isActive) {
|
|
499
|
+
return <Sector {...props} />;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// Expanded active slice with label
|
|
503
|
+
return (
|
|
504
|
+
<g>
|
|
505
|
+
<text x={cx} y={cy} dy={8} textAnchor="middle" fill={fill}>
|
|
506
|
+
{payload.name}
|
|
507
|
+
</text>
|
|
508
|
+
<Sector
|
|
509
|
+
cx={cx}
|
|
510
|
+
cy={cy}
|
|
511
|
+
innerRadius={innerRadius}
|
|
512
|
+
outerRadius={outerRadius}
|
|
513
|
+
startAngle={startAngle}
|
|
514
|
+
endAngle={endAngle}
|
|
515
|
+
fill={fill}
|
|
516
|
+
/>
|
|
517
|
+
<Sector
|
|
518
|
+
cx={cx}
|
|
519
|
+
cy={cy}
|
|
520
|
+
startAngle={startAngle}
|
|
521
|
+
endAngle={endAngle}
|
|
522
|
+
innerRadius={outerRadius + 6}
|
|
523
|
+
outerRadius={outerRadius + 10}
|
|
524
|
+
fill={fill}
|
|
525
|
+
/>
|
|
526
|
+
</g>
|
|
527
|
+
);
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
function ActivePieChart() {
|
|
531
|
+
return (
|
|
532
|
+
<PieChart width={400} height={400}>
|
|
533
|
+
<Pie
|
|
534
|
+
data={data}
|
|
535
|
+
cx="50%"
|
|
536
|
+
cy="50%"
|
|
537
|
+
innerRadius={60}
|
|
538
|
+
outerRadius={80}
|
|
539
|
+
dataKey="value"
|
|
540
|
+
shape={renderShape}
|
|
541
|
+
/>
|
|
542
|
+
<Tooltip defaultIndex={0} />
|
|
543
|
+
</PieChart>
|
|
544
|
+
);
|
|
545
|
+
}
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
## Scatter Chart Patterns
|
|
549
|
+
|
|
550
|
+
### Basic Scatter Chart
|
|
551
|
+
|
|
552
|
+
```jsx
|
|
553
|
+
import { ScatterChart, Scatter, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts';
|
|
554
|
+
|
|
555
|
+
const data = [
|
|
556
|
+
{ x: 100, y: 200, z: 200 },
|
|
557
|
+
{ x: 120, y: 100, z: 260 },
|
|
558
|
+
{ x: 170, y: 300, z: 400 },
|
|
559
|
+
{ x: 140, y: 250, z: 280 },
|
|
560
|
+
{ x: 150, y: 400, z: 500 },
|
|
561
|
+
];
|
|
562
|
+
|
|
563
|
+
function SimpleScatterChart() {
|
|
564
|
+
return (
|
|
565
|
+
<ResponsiveContainer width="100%" height={300}>
|
|
566
|
+
<ScatterChart>
|
|
567
|
+
<CartesianGrid />
|
|
568
|
+
<XAxis type="number" dataKey="x" name="X" unit="px" />
|
|
569
|
+
<YAxis type="number" dataKey="y" name="Y" unit="px" />
|
|
570
|
+
<Tooltip cursor={{ strokeDasharray: '3 3' }} />
|
|
571
|
+
<Scatter name="Series A" data={data} fill="#8884d8" />
|
|
572
|
+
</ScatterChart>
|
|
573
|
+
</ResponsiveContainer>
|
|
574
|
+
);
|
|
575
|
+
}
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
### Bubble Chart
|
|
579
|
+
|
|
580
|
+
```jsx
|
|
581
|
+
<ScatterChart>
|
|
582
|
+
<CartesianGrid />
|
|
583
|
+
<XAxis type="number" dataKey="x" name="X" />
|
|
584
|
+
<YAxis type="number" dataKey="y" name="Y" />
|
|
585
|
+
<ZAxis type="number" dataKey="z" range={[100, 500]} name="Size" />
|
|
586
|
+
<Tooltip cursor={{ strokeDasharray: '3 3' }} />
|
|
587
|
+
<Legend />
|
|
588
|
+
<Scatter name="Group A" data={data01} fill="#8884d8" />
|
|
589
|
+
<Scatter name="Group B" data={data02} fill="#82ca9d" />
|
|
590
|
+
</ScatterChart>
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
### Scatter with Trend Line
|
|
594
|
+
|
|
595
|
+
```jsx
|
|
596
|
+
import { LineChart, Line, XAxis, YAxis, Tooltip, ReferenceLine } from 'recharts';
|
|
597
|
+
|
|
598
|
+
function ScatterWithTrend() {
|
|
599
|
+
// Calculate trend line
|
|
600
|
+
const n = data.length;
|
|
601
|
+
const sumX = data.reduce((sum, d) => sum + d.x, 0);
|
|
602
|
+
const sumY = data.reduce((sum, d) => sum + d.y, 0);
|
|
603
|
+
const sumXY = data.reduce((sum, d) => sum + d.x * d.y, 0);
|
|
604
|
+
const sumX2 = data.reduce((sum, d) => sum + d.x * d.x, 0);
|
|
605
|
+
|
|
606
|
+
const slope = (n * sumXY - sumX * sumY) / (n * sumX2 - sumX * sumX);
|
|
607
|
+
const intercept = (sumY - slope * sumX) / n;
|
|
608
|
+
|
|
609
|
+
const minX = Math.min(...data.map(d => d.x));
|
|
610
|
+
const maxX = Math.max(...data.map(d => d.x));
|
|
611
|
+
|
|
612
|
+
return (
|
|
613
|
+
<ScatterChart>
|
|
614
|
+
<CartesianGrid />
|
|
615
|
+
<XAxis type="number" dataKey="x" domain={[minX, maxX]} />
|
|
616
|
+
<YAxis type="number" dataKey="y" />
|
|
617
|
+
<Tooltip cursor={{ strokeDasharray: '3 3' }} />
|
|
618
|
+
<Scatter data={data} fill="#8884d8" />
|
|
619
|
+
<ReferenceLine
|
|
620
|
+
segment={[
|
|
621
|
+
{ x: minX, y: slope * minX + intercept },
|
|
622
|
+
{ x: maxX, y: slope * maxX + intercept }
|
|
623
|
+
]}
|
|
624
|
+
stroke="red"
|
|
625
|
+
strokeDasharray="3 3"
|
|
626
|
+
/>
|
|
627
|
+
</ScatterChart>
|
|
628
|
+
);
|
|
629
|
+
}
|
|
630
|
+
```
|
|
631
|
+
|
|
632
|
+
## Composed Chart Patterns
|
|
633
|
+
|
|
634
|
+
### Line + Bar + Area
|
|
635
|
+
|
|
636
|
+
```jsx
|
|
637
|
+
import { ComposedChart, Line, Bar, Area, XAxis, YAxis, CartesianGrid, Tooltip, Legend } from 'recharts';
|
|
638
|
+
|
|
639
|
+
function MixedChart() {
|
|
640
|
+
return (
|
|
641
|
+
<ResponsiveContainer width="100%" height={300}>
|
|
642
|
+
<ComposedChart data={data}>
|
|
643
|
+
<CartesianGrid stroke="#f5f5f5" />
|
|
644
|
+
<XAxis dataKey="name" />
|
|
645
|
+
<YAxis />
|
|
646
|
+
<Tooltip />
|
|
647
|
+
<Legend />
|
|
648
|
+
<Area type="monotone" dataKey="total" fill="#8884d8" stroke="#8884d8" />
|
|
649
|
+
<Bar dataKey="sales" barSize={20} fill="#413ea0" />
|
|
650
|
+
<Line type="monotone" dataKey="profit" stroke="#ff7300" />
|
|
651
|
+
</ComposedChart>
|
|
652
|
+
</ResponsiveContainer>
|
|
653
|
+
);
|
|
654
|
+
}
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
### Dual Y-Axis Chart
|
|
658
|
+
|
|
659
|
+
```jsx
|
|
660
|
+
<ComposedChart data={data}>
|
|
661
|
+
<CartesianGrid stroke="#f5f5f5" />
|
|
662
|
+
<XAxis dataKey="name" />
|
|
663
|
+
<YAxis yAxisId="left" />
|
|
664
|
+
<YAxis yAxisId="right" orientation="right" />
|
|
665
|
+
<Tooltip />
|
|
666
|
+
<Legend />
|
|
667
|
+
<Bar yAxisId="left" dataKey="sales" fill="#8884d8" />
|
|
668
|
+
<Line yAxisId="right" type="monotone" dataKey="rate" stroke="#ff7300" />
|
|
669
|
+
</ComposedChart>
|
|
670
|
+
```
|
|
671
|
+
|
|
672
|
+
## Advanced Patterns
|
|
673
|
+
|
|
674
|
+
### Real-time Chart
|
|
675
|
+
|
|
676
|
+
```jsx
|
|
677
|
+
import { useState, useEffect } from 'react';
|
|
678
|
+
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip } from 'recharts';
|
|
679
|
+
|
|
680
|
+
function RealtimeChart() {
|
|
681
|
+
const [data, setData] = useState([]);
|
|
682
|
+
|
|
683
|
+
useEffect(() => {
|
|
684
|
+
let counter = 0;
|
|
685
|
+
const interval = setInterval(() => {
|
|
686
|
+
setData(prev => {
|
|
687
|
+
const newData = [...prev, {
|
|
688
|
+
time: new Date().toLocaleTimeString(),
|
|
689
|
+
value: Math.floor(Math.random() * 100),
|
|
690
|
+
index: counter++
|
|
691
|
+
}].slice(-20); // Keep last 20 points
|
|
692
|
+
return newData;
|
|
693
|
+
});
|
|
694
|
+
}, 1000);
|
|
695
|
+
|
|
696
|
+
return () => clearInterval(interval);
|
|
697
|
+
}, []);
|
|
698
|
+
|
|
699
|
+
return (
|
|
700
|
+
<LineChart data={data}>
|
|
701
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
702
|
+
<XAxis dataKey="time" interval="preserveStartEnd" />
|
|
703
|
+
<YAxis domain={[0, 100]} />
|
|
704
|
+
<Tooltip />
|
|
705
|
+
<Line
|
|
706
|
+
type="monotone"
|
|
707
|
+
dataKey="value"
|
|
708
|
+
stroke="#8884d8"
|
|
709
|
+
isAnimationActive={false} // Disable for performance
|
|
710
|
+
dot={false}
|
|
711
|
+
/>
|
|
712
|
+
</LineChart>
|
|
713
|
+
);
|
|
714
|
+
}
|
|
715
|
+
```
|
|
716
|
+
|
|
717
|
+
### Chart with Custom Tooltip
|
|
718
|
+
|
|
719
|
+
```jsx
|
|
720
|
+
const CustomTooltip = ({ active, payload, label }) => {
|
|
721
|
+
if (active && payload && payload.length) {
|
|
722
|
+
return (
|
|
723
|
+
<div style={{
|
|
724
|
+
backgroundColor: '#fff',
|
|
725
|
+
padding: '10px',
|
|
726
|
+
border: '1px solid #ccc',
|
|
727
|
+
borderRadius: '4px',
|
|
728
|
+
boxShadow: '0 2px 4px rgba(0,0,0,0.1)'
|
|
729
|
+
}}>
|
|
730
|
+
<p style={{ margin: 0, fontWeight: 'bold' }}>{label}</p>
|
|
731
|
+
{payload.map((entry, index) => (
|
|
732
|
+
<p key={index} style={{
|
|
733
|
+
margin: '5px 0 0 0',
|
|
734
|
+
color: entry.color,
|
|
735
|
+
fontSize: '14px'
|
|
736
|
+
}}>
|
|
737
|
+
{entry.name}: {entry.value.toLocaleString()}
|
|
738
|
+
</p>
|
|
739
|
+
))}
|
|
740
|
+
</div>
|
|
741
|
+
);
|
|
742
|
+
}
|
|
743
|
+
return null;
|
|
744
|
+
};
|
|
745
|
+
|
|
746
|
+
<LineChart data={data}>
|
|
747
|
+
<XAxis dataKey="month" />
|
|
748
|
+
<YAxis />
|
|
749
|
+
<Tooltip content={<CustomTooltip />} />
|
|
750
|
+
<Line type="monotone" dataKey="sales" stroke="#8884d8" />
|
|
751
|
+
</LineChart>
|
|
752
|
+
```
|
|
753
|
+
|
|
754
|
+
### Chart with Reference Elements
|
|
755
|
+
|
|
756
|
+
```jsx
|
|
757
|
+
<LineChart data={data}>
|
|
758
|
+
<CartesianGrid strokeDasharray="3 3" />
|
|
759
|
+
<XAxis dataKey="month" />
|
|
760
|
+
<YAxis />
|
|
761
|
+
<Tooltip />
|
|
762
|
+
<Legend />
|
|
763
|
+
|
|
764
|
+
{/* Target line */}
|
|
765
|
+
<ReferenceLine
|
|
766
|
+
y={5000}
|
|
767
|
+
label="Target"
|
|
768
|
+
stroke="red"
|
|
769
|
+
strokeDasharray="3 3"
|
|
770
|
+
/>
|
|
771
|
+
|
|
772
|
+
{/* Highlighted period */}
|
|
773
|
+
<ReferenceArea
|
|
774
|
+
x1="Feb"
|
|
775
|
+
x2="Apr"
|
|
776
|
+
label="Campaign"
|
|
777
|
+
fill="#8884d8"
|
|
778
|
+
fillOpacity={0.1}
|
|
779
|
+
/>
|
|
780
|
+
|
|
781
|
+
{/* Important point */}
|
|
782
|
+
<ReferenceDot
|
|
783
|
+
x="Jun"
|
|
784
|
+
y={9800}
|
|
785
|
+
r={8}
|
|
786
|
+
fill="gold"
|
|
787
|
+
stroke="orange"
|
|
788
|
+
label="Peak"
|
|
789
|
+
/>
|
|
790
|
+
|
|
791
|
+
<Line type="monotone" dataKey="sales" stroke="#8884d8" />
|
|
792
|
+
</LineChart>
|
|
793
|
+
```
|
|
794
|
+
|
|
795
|
+
### Treemap
|
|
796
|
+
|
|
797
|
+
```jsx
|
|
798
|
+
import { Treemap, Tooltip } from 'recharts';
|
|
799
|
+
|
|
800
|
+
const treemapData = [
|
|
801
|
+
{ name: 'A', size: 100, children: [
|
|
802
|
+
{ name: 'A1', size: 30 },
|
|
803
|
+
{ name: 'A2', size: 40 },
|
|
804
|
+
{ name: 'A3', size: 30 },
|
|
805
|
+
]},
|
|
806
|
+
{ name: 'B', size: 80, children: [
|
|
807
|
+
{ name: 'B1', size: 25 },
|
|
808
|
+
{ name: 'B2', size: 55 },
|
|
809
|
+
]},
|
|
810
|
+
];
|
|
811
|
+
|
|
812
|
+
<Treemap
|
|
813
|
+
width={400}
|
|
814
|
+
height={200}
|
|
815
|
+
data={treemapData}
|
|
816
|
+
dataKey="size"
|
|
817
|
+
stroke="#fff"
|
|
818
|
+
fill="#8884d8"
|
|
819
|
+
content={({ x, y, width, height, index, name, value }) => (
|
|
820
|
+
<g>
|
|
821
|
+
<rect x={x} y={y} width={width} height={height} fill={COLORS[index % COLORS.length]} stroke="#fff" />
|
|
822
|
+
{width > 50 && height > 30 && (
|
|
823
|
+
<text x={x + 10} y={y + 20} fill="#fff" fontSize={12}>
|
|
824
|
+
{name} ({value})
|
|
825
|
+
</text>
|
|
826
|
+
)}
|
|
827
|
+
</g>
|
|
828
|
+
)}
|
|
829
|
+
/>
|
|
830
|
+
```
|
|
831
|
+
|
|
832
|
+
### Sankey Diagram
|
|
833
|
+
|
|
834
|
+
```jsx
|
|
835
|
+
import { Sankey } from 'recharts';
|
|
836
|
+
|
|
837
|
+
const sankeyData = {
|
|
838
|
+
nodes: [
|
|
839
|
+
{ name: 'Source A' },
|
|
840
|
+
{ name: 'Source B' },
|
|
841
|
+
{ name: 'Target X' },
|
|
842
|
+
{ name: 'Target Y' },
|
|
843
|
+
],
|
|
844
|
+
links: [
|
|
845
|
+
{ source: 0, target: 2, value: 10 },
|
|
846
|
+
{ source: 0, target: 3, value: 5 },
|
|
847
|
+
{ source: 1, target: 2, value: 8 },
|
|
848
|
+
{ source: 1, target: 3, value: 12 },
|
|
849
|
+
],
|
|
850
|
+
};
|
|
851
|
+
|
|
852
|
+
<Sankey
|
|
853
|
+
width={400}
|
|
854
|
+
height={300}
|
|
855
|
+
data={sankeyData}
|
|
856
|
+
nodePadding={20}
|
|
857
|
+
nodeWidth={20}
|
|
858
|
+
linkCurvature={0.5}
|
|
859
|
+
>
|
|
860
|
+
<Tooltip />
|
|
861
|
+
</Sankey>
|
|
862
|
+
```
|
|
863
|
+
|
|
864
|
+
### Radar Chart
|
|
865
|
+
|
|
866
|
+
```jsx
|
|
867
|
+
import { RadarChart, PolarGrid, PolarAngleAxis, PolarRadiusAxis, Radar, Legend } from 'recharts';
|
|
868
|
+
|
|
869
|
+
const radarData = [
|
|
870
|
+
{ subject: 'Math', A: 120, B: 110, fullMark: 150 },
|
|
871
|
+
{ subject: 'English', A: 98, B: 130, fullMark: 150 },
|
|
872
|
+
{ subject: 'Physics', A: 86, B: 130, fullMark: 150 },
|
|
873
|
+
{ subject: 'Chemistry', A: 99, B: 100, fullMark: 150 },
|
|
874
|
+
{ subject: 'Biology', A: 85, B: 90, fullMark: 150 },
|
|
875
|
+
{ subject: 'History', A: 65, B: 85, fullMark: 150 },
|
|
876
|
+
];
|
|
877
|
+
|
|
878
|
+
<RadarChart cx="50%" cy="50%" outerRadius="80%" data={radarData}>
|
|
879
|
+
<PolarGrid />
|
|
880
|
+
<PolarAngleAxis dataKey="subject" />
|
|
881
|
+
<PolarRadiusAxis angle={30} domain={[0, 150]} />
|
|
882
|
+
<Radar name="Student A" dataKey="A" stroke="#8884d8" fill="#8884d8" fillOpacity={0.6} />
|
|
883
|
+
<Radar name="Student B" dataKey="B" stroke="#82ca9d" fill="#82ca9d" fillOpacity={0.6} />
|
|
884
|
+
<Legend />
|
|
885
|
+
<Tooltip />
|
|
886
|
+
</RadarChart>
|
|
887
|
+
```
|
|
888
|
+
|
|
889
|
+
### Custom Axis Tick
|
|
890
|
+
|
|
891
|
+
```jsx
|
|
892
|
+
const CustomTick = ({ x, y, stroke, payload }) => (
|
|
893
|
+
<g transform={`translate(${x},${y})`}>
|
|
894
|
+
<text x={0} y={0} dy={16} textAnchor="end" fill="#666" transform="rotate(-35)">
|
|
895
|
+
{payload.value}
|
|
896
|
+
</text>
|
|
897
|
+
</g>
|
|
898
|
+
);
|
|
899
|
+
|
|
900
|
+
<XAxis dataKey="month" tick={<CustomTick />} height={60} />
|
|
901
|
+
```
|
|
902
|
+
|
|
903
|
+
### Performance-Optimized Large Dataset
|
|
904
|
+
|
|
905
|
+
```jsx
|
|
906
|
+
import { useMemo, useCallback } from 'react';
|
|
907
|
+
import { LineChart, Line, XAxis, YAxis, Tooltip } from 'recharts';
|
|
908
|
+
|
|
909
|
+
function OptimizedChart({ rawData }) {
|
|
910
|
+
// Memoize data processing
|
|
911
|
+
const data = useMemo(() => {
|
|
912
|
+
// Aggregate or sample data if too large
|
|
913
|
+
if (rawData.length > 1000) {
|
|
914
|
+
return rawData.filter((_, i) => i % Math.ceil(rawData.length / 500) === 0);
|
|
915
|
+
}
|
|
916
|
+
return rawData;
|
|
917
|
+
}, [rawData]);
|
|
918
|
+
|
|
919
|
+
// Stable callback for dataKey if using function
|
|
920
|
+
const dataKey = useCallback((entry) => entry.value, []);
|
|
921
|
+
|
|
922
|
+
// Memoized tooltip
|
|
923
|
+
const tooltipContent = useMemo(() => <CustomTooltip />, []);
|
|
924
|
+
|
|
925
|
+
return (
|
|
926
|
+
<LineChart data={data}>
|
|
927
|
+
<XAxis dataKey="time" interval="preserveStartEnd" />
|
|
928
|
+
<YAxis domain={['auto', 'auto']} />
|
|
929
|
+
<Tooltip content={tooltipContent} />
|
|
930
|
+
<Line
|
|
931
|
+
type="monotone"
|
|
932
|
+
dataKey={dataKey}
|
|
933
|
+
stroke="#8884d8"
|
|
934
|
+
dot={false} // Disable dots for performance
|
|
935
|
+
isAnimationActive={false} // Disable animation
|
|
936
|
+
/>
|
|
937
|
+
</LineChart>
|
|
938
|
+
);
|
|
939
|
+
}
|
|
940
|
+
```
|