Create an Ordinal Scale

master
Matt Huntington 9 years ago
parent 543e7d8703
commit bc5a2f1ee2

@ -33,3 +33,23 @@ var dataset = [
{ label: 'Dijkstra', count: 40 }
];
```
## Create an Ordinal Scale
An ordinal scale maps discrete values (can't be interpolated) to discrete values.
```javascript
var mapper = d3.scaleOrdinal();
mapper.range([45, 63, 400]);
mapper.domain(['Bob', 'Sally', 'Zagthor']);
console.log(mapper('Bob'));
console.log(mapper('Sally'));
console.log(mapper('Zagthor'));
```
You cannot invert ordinal scales:
```javascript
console.log(mapper.invert(45));
```

Loading…
Cancel
Save