Esta página se muestra en inglés. Una traducción al español está en curso.
SkillsApr 11, 2026·2 min de lectura

Chart.js — Simple Yet Flexible HTML5 Canvas Charts

Chart.js is the most popular charting library for the web — simple HTML5 canvas charts with 8 built-in chart types, responsive, animated, and mixable. The go-to choice when you need beautiful charts with minimal setup.

Listo para agents

Instalación lista para agent

Este activo puede instalarse después de elegir el runtime, revisar el plan y ejecutar el comando correspondiente.

Native · 98/100Política: permitir
Superficie agent
Cualquier agent MCP/CLI
Tipo
Skill
Instalación
Single
Confianza
Confianza: Established
Entrada
step-1.md
Comando de instalación directa
npx -y tokrepo@latest install 4fa5bf54-3580-11f1-9bc6-00163e2b0d79 --target codex

Ejecutar después de confirmar el plan con dry-run.

TL;DR
Most popular web charting library with 8 chart types, responsive design, and animations on HTML5 canvas.
§01

What it is

Chart.js is an open-source JavaScript charting library that renders beautiful, responsive charts on HTML5 canvas. It ships with 8 built-in chart types (line, bar, radar, doughnut, pie, polar area, bubble, scatter) and supports mixing chart types, custom plugins, and extensive theming. Chart.js is the go-to choice when you need charts with minimal setup and no heavy dependencies.

Frontend developers, data dashboard builders, and anyone adding visualizations to web applications benefit from Chart.js. Its simplicity makes it accessible to beginners while its plugin system satisfies advanced customization needs.

§02

How it saves time or tokens

Chart.js gets you from zero to a working chart in under 10 lines of code. No complex build configuration, no mandatory framework integration, no data transformation pipelines. For AI-generated dashboards and reports, Chart.js's simple API means coding agents produce working chart code with fewer iterations and less context.

§03

How to use

  1. Install Chart.js via npm or include from a CDN
  2. Add a canvas element to your HTML
  3. Create a Chart instance with your data and configuration
§04

Example

<canvas id="myChart" width="400" height="200"></canvas>
import Chart from 'chart.js/auto';

new Chart(document.getElementById('myChart') as HTMLCanvasElement, {
  type: 'bar',
  data: {
    labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
    datasets: [{
      label: 'Token Usage',
      data: [1200, 1900, 3000, 5000, 4200],
      backgroundColor: 'rgba(54, 162, 235, 0.5)',
      borderColor: 'rgba(54, 162, 235, 1)',
      borderWidth: 1
    }]
  },
  options: {
    responsive: true,
    scales: { y: { beginAtZero: true } }
  }
});
§05

Related on TokRepo

§06

Common pitfalls

  • Canvas-based rendering means charts are not accessible to screen readers by default; add ARIA labels and a data table fallback
  • Rendering many data points (10,000+) on canvas degrades performance; use decimation or switch to WebGL-based libraries for large datasets
  • Chart.js v4 has breaking changes from v3; check migration guides when upgrading

Preguntas frecuentes

How does Chart.js compare to D3.js?+

Chart.js provides ready-made chart types with simple configuration. D3.js is a low-level visualization library that gives you complete control but requires significantly more code. Use Chart.js for standard charts; use D3.js for custom, non-standard visualizations.

Does Chart.js work with React/Vue/Angular?+

Yes. Official wrapper libraries exist: react-chartjs-2 for React, vue-chartjs for Vue. Angular developers can use ng2-charts. These wrappers provide framework-native component interfaces around Chart.js.

Can I create custom chart types?+

Yes. Chart.js has a plugin and controller system that lets you create entirely new chart types. You extend an existing chart controller and override rendering methods. The plugin system also allows adding custom annotations, labels, and interactions.

Is Chart.js free for commercial use?+

Yes. Chart.js is open-source under the MIT license. There are no fees, restrictions, or attribution requirements for commercial use.

Does Chart.js support real-time data?+

Yes. You can update chart data dynamically by modifying the data arrays and calling chart.update(). For streaming data, use the chartjs-plugin-streaming plugin which adds automatic scrolling and time-based axis handling.

Referencias (3)

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados