2018-10-12 15:37:13 -04:00
---
title: Create a Linear Scale with D3
---
2019-07-24 00:59:27 -07:00
# Create a Linear Scale with D3
2018-10-12 15:37:13 -04:00
2019-07-24 00:59:27 -07:00
---
## Problem Explanation
2018-11-07 04:00:21 +05:30
In this D3 challenge you are required to change the scale variable to create a linear scale. Then set the output variable to the scale called with an input argument of 50.
2018-10-12 15:37:13 -04:00
2019-07-24 00:59:27 -07:00
---
## Hints
2018-11-07 04:00:21 +05:30
### Hint 1
2018-10-12 15:37:13 -04:00
2018-11-07 04:00:21 +05:30
The syntax for creating a scale is:
```javascript
const scale = d3.scaleLinear();
```
### Hint 2
The `const` scale is a method, which accepts a value.
### Hint 3
The scaling factor should be set to `50` .
### Hint 4
The scaling factor is set like this:
```javascript
const output = scale(scalingFactor);
```
Where `scalingFactor` is a number.
2019-07-24 00:59:27 -07:00
---
## Solutions
< details > < summary > Solution 1 (Click to Show/Hide)< / summary >
2018-11-07 04:00:21 +05:30
To solve this challenge, the `scale` variable has to be re-initialized with a D3 scale ans the scaling factor in the output has to be set to `50` , to do this, change you code to look like this:
2019-07-24 00:59:27 -07:00
```html
2018-11-07 04:00:21 +05:30
< body >
< script >
const scale = d3.scaleLinear();
const output = scale(50);
d3.select("body")
.append("h2")
.text(output);
< / script >
< / body >
```
2019-07-24 00:59:27 -07:00
< / details >