In the era of big data, presenting information clearly is more important than ever. However, modern charting libraries are often bloated, slow, and difficult to customize. When you are rendering thousands of data points, standard DOM-based charts (like SVG) can bring your browser to a crawl.
Canvas Chart Library is a lightweight, ultra-fast, open-source charting engine built entirely on the HTML5 <canvas> element. Unlike traditional libraries, it renders charts using a single canvas, allowing it to draw millions of data points at a smooth 60 frames per second. It is designed for developers who need complete control over their visualizations without sacrificing performance.
This repository provides a comprehensive suite of chart types: line charts, bar charts, pie charts, scatter plots, and radar charts. It includes a powerful, fluent API that makes it incredibly easy to pass data, customize colors, and add animations. Whether you are building a real-time financial dashboard or a simple analytics page, this library delivers stunning results with minimal footprint.
| Feature | Description |
|---|---|
| β‘ Canvas Rendering | Renders thousands of data points without UI freezing |
| π¨ Highly Customizable | Control every pixel: colors, fonts, grid lines, and tooltips |
| π Multiple Chart Types | Line, Bar, Pie, Doughnut, Radar, and Scatter plots |
| π±οΈ Interactive Elements | Hover tooltips, click events, and zoom/pan support |
| π Tiny Footprint | Less than 15KB minified and gzipped, with zero dependencies |
| π Dark Mode Support | Adapts automatically to your app's theme |
| π± Responsive | Automatically resizes to fit any screen or container |
| π§© Framework Agnostic | Works seamlessly with React, Vue, Svelte, or Vanilla JS |
We have designed this library to be incredibly developer-friendly. Here is how you can integrate it into your projects.
To get started, you simply create a <canvas> element in your HTML and pass its ID to the library. The library automatically calculates the optimal rendering context and prepares the canvas for drawing.
We use a simple, JSON-based configuration object. You define your datasets, labels, and chart type. The library then processes this data and maps it to the canvas coordinates. Because it uses a highly optimized mapping algorithm, rendering is instantaneous.
You can customize every aspect of the chart. Want a gradient fill for your line chart? Just pass a CanvasGradient object. Want a smooth easing animation when the chart loads? Just set animation: { duration: 1000, easing: 'easeOutQuart' }. The library handles the frame interpolation for you.
Why use Canvas instead of SVG? It comes down to how browsers handle rendering.
SVG (Scalable Vector Graphics) creates a DOM node for every element. If you have a line chart with 1,000 points, it creates 1,000 DOM nodes. The browser has to calculate the layout and style for each node, which causes massive performance issues.
The HTML5 <canvas> is a single bitmap element. The library draws the chart using imperative JavaScript commands (moveTo, lineTo, arc). The browser doesn't need to create thousands of DOM nodes. It simply paints the pixels onto the screen. This makes Canvas orders of magnitude faster for complex visualizations.
Our library uses a technique called "Dirty Rectangle" rendering. When you hover over a data point, instead of re-rendering the entire chart, it only redraws the small rectangular area where the tooltip appears. This keeps the CPU usage incredibly low, ensuring your app remains perfectly responsive.
Data visualization is a constantly evolving field. If you have ideas for new chart types, optimizations for the rendering engine, or want to help translate the documentation, we welcome your contributions!
- Fork the repository.
- Create your feature branch (
git checkout -b feature/new-chart). - Commit your changes (
git commit -m 'Add new chart type'). - Push to the branch (
git push origin feature/new-chart). - Open a Pull Request.
Please read our CONTRIBUTING.md for detailed coding standards and testing requirements. We also have an active Discord server where you can share your dashboards, ask for help with chart configuration, and discuss the latest trends in web performance.
- π¬ Discussions: Join the conversation in the GitHub Discussions tab.
- π Issues: Found a bug? Let us know via the Issues tracker.
- π§ Email: Reach out directly at support@canvas-chart.dev.