Accepted answer

d3.js is not a "charting" library. it is a library for creating and manipulating svg/html. it provides tools to help you visualize and manipulate your data. while you can use it to create conventional charts (bar, line, pie, etc...) it's capable of so much more. of course with this "capable of so much" comes a steeper learning curve. there are a lot of conventional charting libraries built on top of d3.js - nvd3.js, dimple.js, dc.js if you want to go that route.

i'm not familiar with chart.js but a quick look at the website tells me it's more of a run of the mill charting library. it supports 6 basic chart types and you aren't ever going to do stuff like this with it. but the api looks straightforward and i'm sure it's easy to use.

other than that the most obvious distinction between the two is that chart.js is canvas based, while d3.js is mainly about svg. (now i say mainly because d3.js can manipulate all types of html elements so you could even use it to help you draw on a canvas.) in general canvas will out perform svg for a large number of elements (i'm talking very large - thousands of points, lines, etc...). svg, on the other hand, is easier to manipulate and interact with. with svg each point, line, etc becomes part of the dom - you want that point green now, just change it. with canvas its a static drawing that was to be redrawn to make any change - of course it draws so fast you'll usually never notice. here's some good reading from microsoft.


  • it uses html5 canvas tag which is pixel dependent ,so when you resize the chart.js generated graph you loose clarity
  • it is declarative, means you have to just declare required inputs to generate graph
  • learning curve is less
  • types of charts generated are predefined and limited
  • it uses svg which is resolution independent,so when you resize the d3 generated graph you will not loose clarity
  • it is imperative, means you have to write some logic to generate charts
  • steep learning curve
  • types of charts generated are not predefined and you can create any chart you want


updated 2016

the general rule of thumb is:

d3.js - great for interactive visualizations

chart.js - great for quick and simple

a few other charting libraries are on the rise, so keep testing and don't forget to contribute to the open source!


since i am trying to find a fast charting library to show charts on mobile devices, performance was important for me. it also had to have a licence that makes it possible to use commercially. i compared:

  1. c3, which is based on d3 and therefore uses svg
  2. chart.js which is using canvas

the charts are loaded inside a webview component inside a native app and all data (including the js library) is local, so no slow down due to http requests. to maximize performance even more, i additionally put everything inside one single file.

i loaded 4 charts (line, bar, pie, line/bar combo) with together around 500 datapoints.

my time measuring exluded the actual loading of the html page. i measured form the moment i started using the charting library code until the end of rendering. all chart animation was turned off.

c3 took around 1500-1800 ms on modern android and iphone devices. iphone performed around 100ms better than android.

chart.js took around 400-800ms. android performed around 300ms better than iphone.

no surprise, the svg is slower. depending on your use case, maybe too slow.

on a desktop computer rendering in c3 was around 150-200ms and charts.js around 80-100ms. running the same test in android and iphone emulator had the same result as on desktop. so the slow down on mobile devices is definitely due to hardware/processing limits.

hope that helps

Related Query

More Query from same tag