simplereach.com

Why we use D3 and Ember for Data Visualization

When visualizing data on the web, there are two things that we need to think of, the DATA and the DOM.

D3 is the go-to visualization library because it’s a flexible and data-driven approach to DOM manipulation; D3 does the complicated math so we can think more about data and visualization.

Ember is a MVC javascript framework for creating ambitious web applications. But, why should we use Ember with D3 for DATA and DOM manipulation? Ember gives you tools to easily manage things like async requests and the MVC architecture helps to manage complexity.

Let’s see the reasons why we use D3 and Ember.

We use D3 for all our data visualizations like donut, area and bubble charts. In the example below, there are three large donut charts representing the percentage of social actions and referrals from different social networks. The charts are updated in real-time and clicking on each one displays a breakdown of the data by network also in real-time.

A screenshot of our dashboard, complete with real-time donut and area charts.

You can also see many smaller donut charts in the trending articles list. We use the donut charts throughout the application. They all function the same – the only difference is the data and size – so we wanted to make them reusable. We also work with a lot of real-time data so we have to be very careful about performance and DOM manipulation.

D3 is great for data visualization, but when dealing with complex applications your code can quickly turn into complicated spaghetti. I am not the only one who realized the problem. Sam Selikoff wrote an great article about getting started with Ember + D3 and sums it up nicely:

Ember’s opinionated architecture and design are exactly what I’d been looking for. I could now scaffold a project and be confident in its foundation. Interactive data visualizations can get tricky really fast, but I’ve already caught a glimpse of several Ember features that can smooth out these rough spots. I’m just starting out, but I’d like to share what I’ve learned about how these two technologies can work together.

 

Let’s see how we solved the issues with Ember:

1. Managing the asynchronous behavior of the d3.json method
With d3.json a callback function is used to wrap all methods that change the DOM elements. In large applications, this become unwieldy because it is hard to separate out concerns. With Ember you move the logic out of the callback and into Ember’s model, controller and view objects. If you are interested, read more about the benefits of Ember’s approach.

2. Performance of DATA handling and DOM manipulations
Without Ember, this quickly becomes a problem with real-time updates as DOM manipulations are computationally expensive and often event based actions send redundant signals. The Ember run loop is a solution to both these problems because it’s a smart queuing system that restricts DOM changes to only those necessary and transforms event based actions into streamlined method calls. It also gives you many ways to control when and how your data comes into the application, allowing you to debounce, throttle and delay when data gets to the DOM in a very clean and concise way. This is a major performance win with DOM-related changes and updates the DOM when it makes sense.

3. Responsive and reusable charts with SVG
With HTML/CSS based charts, it’s easy to make charts responsive, but with SVG many properties need to be updated simultaneously, Ember computed properties and data bindings provide a perfect way to do that.

We use Ember Component to make charts reusable. Ember Components adhere closely to the W3C Web Components standard.

Web Components enable Web application authors to define widgets with a level of visual richness and interactivity not possible with CSS alone, and ease of composition and reuse not possible with script libraries today.

But until Web Components are standard in browsers, Ember is the best way to create modular reusable code. For additional details, please read my article about Reusable D3 charts with Ember.js Components.

Focus on the story

One of Ember’s core promises is that it gives you a separation of concerns for DATA and DOM. You know where the code belongs, it makes it difficult for you to put it in the wrong place. In combination with D3, it allows you to create responsive, reusable charts and focus on telling your data story.

P.S: Did you notice the publish date? December 3rd. D3Ember!

 

 

About heyjin

Heyjin is a full-stack programmer who loves Ember, D3 and of course Javascript. Frequently in Heyjinland with beer and dogs.

View all posts by heyjin »
6 comments
charmanderizard
charmanderizard

if u like ember can i have learning of ember chart in html? thanks u!

KennyChung
KennyChung

Hi Hyejin, 


The dashboard looks wonderful! Cheers!


Kenny

JRHE
JRHE

Great post. Will almost certainly be using D3+Ember for an upcoming project and its good to know that something as droolworthy as the simplereach dashboard is created with it!

heyjinkim
heyjinkim

@JRHE  Thanks! I'd love to see how you use D3+Ember in your project :)

Trackbacks

  1. […] Why we use D3 and Ember for Data Visualization http://t.co/jF3FHhWXXJ  […]

  2. […] When visualizing data on the web, there are two things that we need to think of, the DATA and the DOM.D3 is the go-to visualization library because it’s a flexible and data-driven approach to DOM manipulation; D3 does the complicated math so we can think more about data and visualization.Ember is a MVC javascript framework for creating ambitious web applications. But, why should we use Ember with D3 for DATA and DOM manipulation? Ember gives you tools to easily manage things like async requests and the MVC architecture helps to manage complexity.  […]

  3. […] Why we use D3 and Ember for Data Visualization | SimpleReach Blog: http://t.co/xjtPtlq6Eo  […]

  4. […] Why we use D3 and Ember for Data Visualization | SimpleReach […]

  5. […] Why we use D3 and Ember for Data Visualization […]

  6. […] III has it’s heroes and D3 a library for data visualization in Ember.JS has Heyjin Kim. I was lucky to find her at the NYC […]

Contact
  • 122 W. 27th St, 7th Floor
  • New York, NY 10001
  • info@simplereach.com

Privacy Policy