From the course: DC.js for Data Science Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Making a stack area chart with legend - JavaScript Tutorial
From the course: DC.js for Data Science Essential Training
Making a stack area chart with legend
- [Instructor] We can add another section to our area chart using stack, so let's do that with tip because our area chart shows total, so it's a legitimate, meaningful thing to show the tip on top of the total. So the first thing we need to do is change our cross-filter data because the HTML structure of our div is absolutely fine. We can say, total payment plus tip, for good measure there, and then we could say, var dateGroupTip equals dateDimension, so we're using the same dimension that we used for the original layer of data, and this is normal in a stack chart, you'd normally share the dimension because you share the x-axis, so we say, dateDimension.group(), or group 0, .reduceSum and the function then returns d.tip instead of d.total, and that's because we have a tip property up here. Now we supply the new group into a parameter of .stack, like so, and we can say, dateGroupTip and when we do this, in order to distinguish between the two we make use of an optional second…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Making a bar chart11m 5s
-
(Locked)
Modifying our bar chart15m 57s
-
(Locked)
Working with dates to make a line or area chart15m 28s
-
(Locked)
Making a stack area chart with legend3m 43s
-
(Locked)
Exploring SVG with a pie chart13m 13s
-
(Locked)
Making a scatter plot9m 29s
-
(Locked)
Making a bubble chart13m 28s
-
(Locked)
Making a data table with bootstrap17m 46s
-
(Locked)
Understanding common attributes5m 25s
-
-
-
-