D3.js Zoomable Line Chart

March 23, 2024 Length: 1 min Back to Posts

A simple line graph that allows for zooming, updated to version 7 of d3.js. The maintainers really need to update the examples for their site as they are stuck on version 4.

I am still not convinced d3.js is focused on making charts. It seems more of a library for making SVG graphics.

See working example

Everything is all in one HTML page, so you can view the source to see what is going on. I have been working with D3.js a bit the past few weeks and wanted to leave myself this note for future reference.

A few notes with how to work it:

  • drag with mouse to zoom into selected area
  • When you are zoomed in, you can drag the mouse to pan
  • When you are zoomed in, you can double click to zoom back out

Page Contents

Hi, I'm Scott

I mostly keep this blog to help me remember things. Writing is also a great way to understand things at a deeper level. I would highly recommend it if you don't write at all.