What Is Dygraphs? A Fast, Open Source JavaScript Charting Library
Updated
Dygraphs is a fast, flexible open source JavaScript charting library for exploring and interpreting dense data sets in the browser. It fits best when you have large time-series or numeric data and need interactive charts—zoom, pan, and mouseover—without building those interactions yourself. It is not a general-purpose dashboard framework or a design-heavy charting tool; its strength is dense data and built-in interactivity.
What Dygraphs Does
Dygraphs creates interactive charts from JavaScript. The library is designed around a simple constructor pattern: you pass a container element, a data source, and an options object.
g = new Dygraph(div, "ny-vs-sf.txt", {
legend: 'always',
title: 'NYC vs. SF',
showRoller: true,
rollPeriod: 14,
customBars: true,
ylabel: 'Temperature (F)',
});
That single call produces a chart with several behaviors already enabled:
- Mouseover highlights individual values.
- Click and drag zooms into a region.
- Double-click zooms back out.
- Shift-drag pans across the data.
- Rolling period can be changed by typing a number and pressing enter, which adjusts the averaging period.
The key point is that these interactions are on by default. You do not need to wire up event handlers to get a usable exploratory chart.
Core Features
| Feature | What it means in practice |
|---|---|
| Handles huge data sets | Plots millions of points without getting bogged down |
| Interactive out of the box | Zoom, pan, and mouseover are enabled by default |
| High/low bands and confidence intervals | Strong built-in support for range-style data |
| Highly customizable | Options and custom callbacks let you change most behavior |
| Broad browser support | Works in all recent browsers, including pinch-to-zoom on mobile and tablet |
The "millions of points" claim matters most for time-series work: sensor logs, financial series, scientific measurements, and similar dense data where a chart that stutters on interaction is useless.
When to Choose Dygraphs
Choose Dygraphs when:
- Your data is dense and primarily numeric or time-series.
- You need zoom, pan, and hover behavior immediately, not after custom development.
- You want to display high/low bands or confidence intervals.
- You are comfortable writing JavaScript and configuring a chart via an options object.
Look elsewhere when:
- You need a full dashboard or UI component suite.
- You want a purely declarative, template-driven chart with no JavaScript.
- Your charts are simple and small, where a lighter library may be enough.
Getting Started
- Download Dygraphs from the official site.
- Read the Tutorial to learn the basic usage pattern, or experiment directly on jsFiddle.
- Browse the demo gallery for examples, and the list of users for real-world context.
If you use npm with a bundler such as webpack, browserify, or rollup:
npm install --save dygraphs
Then import and use it:
import Dygraph from 'dygraphs';
// or:
const Dygraph = require('dygraphs');
const g = new Dygraph(div, data, {});
An ES6 sample project is available for more detail on this approach.
Documentation and Community
The project publishes a full set of references:
- Tutorial
- Options Reference
- API Reference
- CSS Reference
- Data format documentation
- Version History
- Notes on Internet Explorer
For help, the community uses Stack Overflow and a mailing list. There is also a blog. The source lives on GitHub, with an issue tracker for bug reports.
One practical caution: if you land on a mirror of the documentation rather than the official homepage, the content may be outdated, incomplete, or locally patched, and links may not work. Use the official Dygraphs homepage as your reference point.