{
 "kind": "tool",
 "slug": "react-chartjs-2",
 "path": "tools/react-chartjs-2/",
 "name": "React Chart.js 2",
 "maker": null,
 "density": "profile",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Charts and data visualisation",
   "tools/charts/"
  ]
 ],
 "lead": "React components wrapper for Chart.js enabling data visualization with charts.",
 "chips": [
  {
   "label": "Charts and data visualisation",
   "path": "tools/charts/"
  },
  {
   "label": "NPM"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "npm install react-chartjs-2"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/reactchartjs/react-chartjs-2"
  },
  {
   "label": "Website",
   "href": "https://github.com/reactchartjs/react-chartjs-2"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "MIT",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": null,
   "note": "License from npm.",
   "src": "https://github.com/reactchartjs/react-chartjs-2"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Nov 20, 2026",
   "note": "Latest GitHub release Oct 27, 2025. ",
   "src": "https://github.com/reactchartjs/react-chartjs-2"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "41 projects",
   "status": "info",
   "sub": "#8 of 95 in its category",
   "note": "Dependency in 41 public GitHub projects set up for AI coding agents that we scanned (0.7%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Install only",
   "status": "info",
   "sub": null,
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": null
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What React Chart.js 2 does",
   "parts": [
    {
     "t": "prose",
     "text": "react-chartjs-2 is a thin layer of React components over Chart.js. You choose and register the Chart.js parts your charts need, and typed components such as <code>Line</code> or <code>Doughnut</code> register their own controller."
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "React Chart.js 2 popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "64",
       "of": "/ 100",
       "l": "Gid Score, #763 overall"
      },
      {
       "n": "6.2M",
       "l": "downloads a week, npm"
      },
      {
       "n": "6,939",
       "l": "GitHub stars"
      },
      {
       "n": "41",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How React Chart.js 2 is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "React Chart.js 2 is a dependency in 41 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (0.8% of the 4,867 JavaScript/TypeScript ones), #8 of 95 in charts and data visualisation.",
      "Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 158; those are left out of every share on this page.",
      "The most used alternative in our scan is Recharts (576 projects).",
      "Projects that use it most often also use Chart.js (97.6%), Lucide React (85.4%), React (100.0%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "24 projects, 1.0%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "20 projects, 0.7%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "18 projects, 0.5%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 97.6% of its projects",
       "v": "Chart.js",
       "path": "tools/chart-js/"
      },
      {
       "l": "In 85.4% of its projects",
       "v": "Lucide React",
       "path": "tools/lucide-react/"
      },
      {
       "l": "In 100.0% of its projects",
       "v": "React",
       "path": "tools/react/"
      },
      {
       "l": "In 73.2% of its projects",
       "v": "clsx",
       "path": "tools/clsx/"
      },
      {
       "l": "In 65.9% of its projects",
       "v": "Radix UI",
       "path": "tools/radix-ui/"
      },
      {
       "l": "In 65.9% of its projects",
       "v": "Class Variance Authority",
       "path": "tools/class-variance-authority/"
      },
      {
       "l": "In 90.2% of its projects",
       "v": "Tailwind CSS",
       "path": "tools/tailwindcss/"
      },
      {
       "l": "In 68.3% of its projects",
       "v": "Tailwind Merge",
       "path": "tools/tailwind-merge/"
      }
     ]
    }
   ]
  },
  {
   "id": "profile",
   "nav": "Profile",
   "h2": "React Chart.js 2 in practice",
   "parts": [
    {
     "t": "h3",
     "text": "Strengths"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "You decide what goes in the bundle",
       "v": "The docs describe a \"lazy way\", <code>import 'chart.js/auto'</code>, and a tree-shakable way where you register only the parts you use. The maintainers recommend the second to keep the bundle smaller."
      },
      {
       "l": "Typed components register their own controller",
       "v": "With a component like <code>Line</code>, you do not register <code>LineController</code> yourself. You register only the elements, scales and plugins."
      },
      {
       "l": "Works with Chart.js v4 and v3",
       "v": "The site says both major Chart.js versions are supported and links a separate guide for v3."
      },
      {
       "l": "The chart instance is one ref away",
       "v": "A <code>ref</code> on the component gives you the Chart.js chart. The docs' gradient example reads <code>chart.ctx</code> from <code>chartRef.current</code> to build a background gradient."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Watch out for"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "Registration errors are a known question",
       "v": "The FAQ lists entries on fixing \"not a registered element\" and \"not a registered scale\" errors. It also lists questions about charts that do not keep their width or height, and background fills that do not work."
      },
      {
       "l": "Chart.js is a separate install",
       "v": "You add <code>chart.js</code> alongside <code>react-chartjs-2</code>. The README recommends a specific major version of Chart.js."
      },
      {
       "l": "v4 removed the chart.js re-exports",
       "v": "Imports like <code>defaults</code> and the Chart.js <code>Chart</code> class now come from <code>chart.js</code>, not from this package. The old default export became the named <code>Chart</code> component."
      }
     ]
    },
    {
     "t": "h3",
     "text": "Line component with tree-shaken registration"
    },
    {
     "t": "tabs",
     "label": "Example",
     "items": [
      {
       "tab": "Jsx",
       "code": "import { Line } from 'react-chartjs-2' ;\nimport { Chart as ChartJS , LineElement , PointElement , LinearScale , Title } from 'chart.js' ;\nChartJS . register ( LineElement , PointElement , LinearScale , Title ) ;\n< Line data = { chartData } />"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "profile",
   "h2": "More about React Chart.js 2",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Packages around it",
       "items": [
        "chart.js: Charting engine (peer dependency)",
        "framer-motion: Animation",
        "react: UI library",
        "lucide-react: Icons",
        "react-router-dom: Routing",
        "date-fns: Date utilities"
       ]
      },
      {
       "title": "More in Charts and data visualisation",
       "path": "tools/charts/",
       "items": [
        {
         "text": "Matplotlib",
         "path": "tools/matplotlib/"
        },
        {
         "text": "Chart.js",
         "path": "tools/chart-js/"
        },
        {
         "text": "Mermaid",
         "path": "tools/mermaid/"
        },
        {
         "text": "XY Flow",
         "path": "tools/xyflow/"
        },
        {
         "text": "Seaborn",
         "path": "tools/seaborn/"
        },
        {
         "text": "Plotly",
         "path": "tools/plotly/"
        },
        {
         "text": "Diagrams",
         "path": "tools/diagrams/"
        },
        {
         "text": "Apache ECharts",
         "path": "tools/echarts/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "React Chart.js 2",
       "me": true,
       "facts": [
        "MIT",
        "Gid 64",
        "6.2M/wk"
       ]
      },
      {
       "name": "Recharts",
       "why": "Composable React component library for building responsive charts.",
       "path": "tools/recharts/",
       "facts": [
        "MIT",
        "Gid 85",
        "71.4M/wk"
       ]
      },
      {
       "name": "D3.js",
       "why": "JavaScript library for creating data-driven documents with powerful data visualization capabilities.",
       "path": "tools/d3/",
       "facts": [
        "ISC",
        "Gid 81",
        "36M/wk"
       ]
      },
      {
       "name": "React ApexCharts",
       "why": "React wrapper for ApexCharts with server-side rendering support.",
       "path": "tools/react-apexcharts/",
       "facts": [
        "SEE LICENSE IN LICENSE.md",
        "Gid 48",
        "1.5M/wk"
       ]
      }
     ],
     "more": "Compare React Chart.js 2 with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "install",
     "intro": "Install it.",
     "code": "npm install react-chartjs-2"
    },
    {
     "t": "h3",
     "text": "Rules for your agent"
    },
    {
     "t": "rules",
     "label": "Paste into AGENTS.md or CLAUDE.md",
     "text": "## react-chartjs-2\n- Install both packages: `react-chartjs-2` and `chart.js`. The README recommends `chart.js@^4.0.0`.\n- Before rendering, register the Chart.js elements, scales and plugins a chart needs with `ChartJS.register(...)`. Typed components like `Line` already register their controller.\n- Prefer tree-shakable registration over `import 'chart.js/auto'`. The docs call the auto import the \"lazy way\".\n- Import `Chart as ChartJS`, `defaults` and the elements from `chart.js`. This package no longer re-exports them.\n- For click data, attach a `ref` and call `getDatasetAtEvent`, `getElementAtEvent` or `getElementsAtEvent` with `chartRef.current` and the event inside `onClick`.\n- Do not pass a function to `data`. For gradients, read `chart.ctx` from a ref in `useEffect` and set the data with state.\n"
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "npm react-chartjs-2"
  ],
  [
   "Category",
   "Charts and data visualisation"
  ],
  [
   "License",
   "MIT"
  ],
  [
   "Latest version",
   "v5.3.1, October 27, 2025"
  ],
  [
   "On GitHub since",
   "May 2016"
  ],
  [
   "Gid Score",
   "63.5"
  ],
  [
   "Rank in category",
   "#8 of 95"
  ],
  [
   "GitHub",
   "reactchartjs/react-chartjs-2"
  ],
  [
   "Last change",
   "Nov 20, 2026"
  ]
 ],
 "good": [],
 "checked_line": "From the package registry, GitHub and our scan of public agent projects; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/reactchartjs.png"
}