score:227
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.
score:0
-
chart.js
- 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
-
d3.js
- 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
score:25
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!
score:41
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:
- c3, which is based on d3 and therefore uses SVG
- 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
Source: stackoverflow.com
Related Query
- Comparison between d3.js and chart.js (only for charts)
- Charts JS: Doughnut chart and hiding tooltip for specific data index within each dataset
- Chart Js Change Label orientation on x-Axis for Line Charts
- Chart.js - Increase spacing between legend and chart
- How to save Chart JS charts as image without black background using blobs and filesaver?
- How to add second Y-axis for Bar and Line chart in Chart.js?
- Problem for display a chart with Chart.js and Angular
- How to hide the y axis and x axis line and label in my bar chart for chart.js
- Remove the label and show only value in tooltips of a bar chart
- Increase padding between legend and chart with react-chartjs-2
- Chart,js Pie Chart can the gap between a pie chart and the legend be adjusted
- chart js data-point between bar charts
- to increase space between x axis and first horizontal bar in chart js
- How to create a chart that uses strings for both the X and Y axes?
- ChartsJS make number in middle for only one chart
- How to draw outer labels for polar chart using ng2-charts and chart.js at fixed positions outside the rings?
- In Chart.js >3.0, on axis of type time, how to show labels and ticks only for existing data points (make labels reflect data)?
- Setting Common labels and background color common for all the charts in ChartJs
- How to retain spacing between bars for two different bar charts in Chart.js 2
- change space between horizontal (grid) lines for line chart
- React chartjs-2 - Increase spacing between legend and chart
- How do I customize y-axis labels and randomly pick the value from the data range for x-axis in Chart js
- Empty circle - only point strok in line chart for ChartJS
- How can I have different values for the chart and the tooltip in chart.js?
- Charts js and laravel: Render chart after passing in json data
- Click on interactive chart.js bar chart and get value for labels and groups in JS
- Increase space between legend and chart
- ng2Charts/chart.js changing chart type for one is impacting many charts
- How to increase space between label and chart area in chart.js
- how to increase space between legend and chart in chartjs (ng2charts ) using angular
More Query from same tag
- zeroLineColor and zeroLineWidth not working for the x-axis in Chartjs
- Is there a way to highlight a line on a line graph with hover?
- chartJS label on each side of the chart
- Is it possible to set up 0 as a minimum number for bar chart? react-chart.js-2
- Pass data to Chart Js Laravel
- Chart.js v3.7.1 Chart is not a Constructor
- Chart.js: Is it able to connect two points of data where there are no data between them?
- Angular js pie chart styling
- Prime NG Customise tool tip on Bar Chart
- How do I change the appearance of tooltips with mode: index in Chart.js
- Why don't my datasets show up on line graph using Chart.js?
- Chart JS Error : Uncaught TypeError: Cannot read property 'top' of undefined
- How we can set our own colors for each label in charts
- Chartjs how to show scale label horizontally
- Trying to create a custom tooltip in a doughnut chart using chartsjs, but it is not working
- Draw line charts by days/weeks/months from a timestamp
- Difference between DXTREME and PhoneGap
- I can't change the legend position in Laravel Charts & ChartJS
- give values to Chartjs
- Chart.js animations ignoring global default configuration
- How to stop resizing chart.js in case hovered and out of boundaries?
- ChartJs - displaying data dynamically from back-end
- Doughnut chart adjusting problem in chart.js
- chart.js time scatter with true scale
- ChartJS display tooltip at maximum/minimum value
- ChartJs custom tooltip position
- Is there any way to use 2 different color for the same bar in a chart?
- Chartjs not rendering chart and no error thrown
- Javascript / JSON error: TypeError: myObj is undefined
- Show values on top of bars in chart.js