Friday, December 5, 2014

dygraphs 1.1.0

Earlier this week I released dygraphs 1.1.0, a major new release which contains the last ~15 months of work. The dygraphs site is running it. You can learn more about hosted versions and installing it with NPM or bower from the download page.

There have been far too many changes to cover them exhaustively, but here are a few highlights.

dygraphs is now "retina" compatible

As anyone with a "retina" screen will tell you, low resolution graphics really stand out. Resolution independence is a natural advantage for SVG charting tools like D3. To get crisp charts on high resolution screens, dygraphs creates a larger canvas which is scaled down to fit the logical pixels on your screen. A big thanks to Paul Holden for his work on this.


Using a non-existent option now throws

dygraphs has a lot of options. Previously, if you had a typo in one of your option names, dygraphs would silently drop it. With 1.1.0, if you source dygraph-combined-dev.js,  an invalid option or series name will throw. Say goodbye to mysterious misconfigurations!


More sensible date ticks

dygraphs has displayed ticks like "Jan 08" (for January 2008) and "29Jan" (for January 29th) since it was first released. As we entered the current decade, the former has become a source of confusion: does "Jan 12" mean January 12th or January 2012? With this release, dygraphs uses the more sensible formats "Jan 2008" and "29 Jan".

Dramatically improved performance for filled charts

If you're plotting a million points on a 1000px wide chart, there's no sense in drawing all of them (this is called "overplotting"). For many years, dygraphs has dropped segments on line charts which would have no visible impact. This was not true for filled charts, however. If you turned a line chart into a filled chart, you could easily see a 1000x slowdown. For this release, I reworked the drawing code for filled charts and added the dropped point optimization. Click that link to see a diagram.

x-axis log scales

Previously you could only have log scales on the y-axis. Now you can have them on the x-axis! This allows log-log plots. Thanks to kberg for making this happen.

The labelsUTC option forces UTC formatting for all labels

Time zones are a mess. Sometimes you just want to use UTC and pretend they didn't exist. And now you can! Set the new labelsUTC option and specify your dates using either ISO-8601 format or new Date(Date.UTC(...)). Thanks to joanpau for contributing this great new option!

The new DataHandler system allows for more flexibility in data loading

DataHandlers unify the way that dygraphs loads and processes data. This API is exposed via the dataHandler option, and it should allow dygraphs users to create their own custom data formats. You can read more about this feature in its design doc. Stay tuned for a blog post exploring this! Thanks to David Eberlein for this.

"this" is set to the dygraph in all callbacks

dygraphs has more than a few callback options. Some of them take the relevant dygraph object as a parameter while others don't. In retrospect this was poor API design, but it's a design that we're stuck with. Most JavaScript libraries pass a relevant object to functions via this and now dygraphs does the same.

You can now get a reference to the relevant dygraph from any callback via this.

dygraphs has also shrunk, because we moved some stuff into "extras" (133kb→122kb). Hopefully this won't affect you, but if it does, you can find the missing functionality in that directory.
This will be the last release of dygraphs which supports older versions of Internet Explorer. We've already begun ripping out the shims for older browsers. Expect a leaner, meaner dygraphs soon!

Finally, a big thanks to everyone who contributed to this release. GitHub lists an amazing 54 contributors to dygraphs over the years!

2 comments: