Skip to content

Commit

Permalink
Use clusters instead of breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
schnerd committed Sep 15, 2016
1 parent 7f39d36 commit bcd4cf2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ D3 scale that clusters data into discrete groups

###Usage

This scale largely has the same API as [d3.scaleQuantile](https://github.com/d3/d3-scale/blob/master/README.md#scaleQuantile) (however we use `breaks()` instead of `quantiles()`)
This scale largely has the same API as [d3.scaleQuantile](https://github.com/d3/d3-scale/blob/master/README.md#scaleQuantile) (however we use `clusters()` instead of `quantiles()`)

```js
var scale = d3.scaleCluster()
.domain([1, 2, 4, 5, 12, 43, 52, 123, 234, 1244])
.range(['#E5D6EA', '#C798D3', '#9E58AF', '#7F3391', '#581F66', '#30003A']);

var breaks = scale.breaks(); // [12, 43, 123, 234, 1244]
var clusters = scale.clusters(); // [12, 43, 123, 234, 1244]
var color = scale(52); // '#9E58AF'
var extent = scale.invertExtent('#9E58AF'); // [43, 123]
```
Expand Down
2 changes: 1 addition & 1 deletion dist/d3-scale-cluster.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions spec/ScaleSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ describe('Scale', function () {
scale = d3scaleCluster();
});

it('should find natural breaks', function () {
it('should find clusters', function () {
scale
.domain(DEFAULT_DOMAIN)
.range(DEFAULT_RANGE);

var breaks = scale.breaks();
expect(breaks).toEqual([12, 43, 123, 234, 1244]);
var clusters = scale.clusters();
expect(clusters).toEqual([12, 43, 123, 234, 1244]);
expect(scale(52)).toEqual('c');
});

Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function d3scaleCluster () {
return [extentA, extentB];
};

scale.breaks = function () {
scale.clusters = function () {
return breakpoints.slice(1);
};

Expand Down

0 comments on commit bcd4cf2

Please sign in to comment.