Now we have a barchart, but it doesn't look great. It would be nice to make it fit our space better. Start by using linear scales to control the amount of vertical space this chart takes up.
- [Instructor] So now we have a bar chart,…but it doesn't look that great and that's because…our data doesn't really fit our space for our graphics.…So it would be nice to make these fit the space vertically,…regardless of their actual values.…In order to do that, we're going to need to learn…about linear scales.…A scale is a method that allows us to redefine data…so that it fits a certain range of values.…The simplest type of scale is called the Linear Scale.…It has a method called scaleLinear.…
It's also known as a continuous scale because it maps…a serial set of input values to output values.…We can use that in our table to make our data grow…to fit a specific range.…Now it needs two things:…First is the domain, which you can use by…using the domain method.…And that will be an array of values…that you feed to your scale.…Now it defines the original values that…you're going to modify.…So in this case, this will be pretty much our data.…The range is another set of values that you feed…in an array to the linear scale.…
- What is D3.js?
- Controlling HTML within selections
- Binding data to the DOM
- Drawing SVG graphics with D3
- Using ordinal scales
- Adding events and transitions
- Working with data