From the course: DC.js for Data Science Essential Training

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

Making a stacked bar chart

Making a stacked bar chart - JavaScript Tutorial

From the course: DC.js for Data Science Essential Training

Start my 1-month free trial

Making a stacked bar chart

- [Instructor] We've already seen stack with an area chart, but in that case, we were stacking two different fields, total and tip. What if we wanted to split one field up in two ways? Well, that's what this stacked bar chart does. Here's one I've prepared earlier. And you can see the total spend in our payments on cash, I think was 330, but in this stacked bar, we're splitting it into people who dined alone and people who dined together. So we're not stacking one field on top of another, we have split one field up in two ways. So we're going to create this now starting with our bar chart document, and we'll change that into stackBarChart. And we can get rid of totalDimension, because we're going to be using typeDimension, and modifying them. So the first thing we can do is make our bar chart run off of our basic type dimensions. So we're going to get our columns right before we start splitting up our data. So we're going to have one bar for each payment method, and payment methods…

Contents