Skip to content

Commit 01b1b40

Browse files
committed
linting
1 parent 745d91b commit 01b1b40

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

src/gridding.js

+19-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as d3Scale from 'd3-scale';
22
import * as d3Shape from "d3-shape";
3+
import * as d3Array from "d3-array";
34
import * as d3Hierarchy from "d3-hierarchy";
45

56
export default function() {
@@ -54,7 +55,7 @@ export default function() {
5455

5556
function identity(nodes) {
5657

57-
nodes.forEach(function(n, i) {
58+
nodes.forEach(function(n) {
5859
n.x = n.x || 0;
5960
n.y = n.y || 0;
6061
n.width = n.width || size[0];
@@ -104,7 +105,7 @@ export default function() {
104105

105106
cols = rows = 1;
106107

107-
nodes.forEach(function(n, i) {
108+
nodes.forEach(function(n) {
108109
n.x = 0 + offset[0];
109110
n.y = 0 + offset[1];
110111
n.width = size[0];
@@ -158,17 +159,17 @@ export default function() {
158159
valueX = function() { return Math.random(); }
159160
x.domain([0, 1]).range([0, size[0]]);
160161
} else {
161-
x.domain(d3.extent(nodes, valueX)).range([0, size[0]]);
162+
x.domain(d3Array.extent(nodes, valueX)).range([0, size[0]]);
162163
}
163164

164165
if(!valueY) {
165166
valueY = function() { return Math.random(); }
166167
y.domain([0, 1]).range([0, size[1]]);
167168
} else {
168-
y.domain(d3.extent(nodes, valueY)).range([0, size[1]]);
169+
y.domain(d3Array.extent(nodes, valueY)).range([0, size[1]]);
169170
}
170171

171-
nodes.forEach(function(n, i) {
172+
nodes.forEach(function(n) {
172173
n.x = x(valueX(n)) + offset[0];
173174
n.y = y(valueY(n)) + offset[1];
174175
n.width = cellSize ? cellSize[0]: size[0] / nodes.length;
@@ -192,7 +193,7 @@ export default function() {
192193

193194
var pie = d3Shape.pie()
194195
.sort(sort)
195-
.value(function(d) { return 1; });
196+
.value(function() { return 1; });
196197

197198
var arcs = pie(nodes);
198199

@@ -210,17 +211,16 @@ export default function() {
210211

211212
function treemap(nodes) {
212213

213-
var treemap = d3.treemap()
214+
var treemap = d3Hierarchy.treemap()
214215
.size([size[0], size[1]])
215216
.padding(padding);
216217

217-
var tree = treemap(d3.stratify()
218+
var tree = treemap(d3Hierarchy.stratify()
218219
.id(function(d, i) { return i; })
219220
.parentId(function(d, i) {
220221
return i === 0 ? "": 0;
221-
})
222-
([{}].concat(nodes))
223-
.sum(function(d, i) { return 1; })
222+
})([{}].concat(nodes))
223+
.sum(function() { return 1; })
224224
);
225225

226226
nodes.forEach(function(n, i) {
@@ -237,17 +237,16 @@ export default function() {
237237

238238
function pack(nodes) {
239239

240-
var pack = d3.pack()
240+
var pack = d3Hierarchy.pack()
241241
.size([size[0], size[1]])
242242
.padding(padding);
243243

244-
var packed = pack(d3.stratify()
244+
var packed = pack(d3Hierarchy.stratify()
245245
.id(function(d, i) { return i; })
246246
.parentId(function(d, i) {
247247
return i === 0 ? "": 0;
248-
})
249-
([{}].concat(nodes))
250-
.sum(function(d, i) { return 1; })
248+
})([{}].concat(nodes))
249+
.sum(function() { return 1; })
251250
);
252251

253252
nodes.forEach(function(n, i) {
@@ -264,11 +263,11 @@ export default function() {
264263

265264
function stack(nodes) {
266265

267-
var stack = d3.stack()
266+
var stack = d3Hierarchy.stack()
268267
.keys(nodes.map(function(d, i) { return i + "_"; })) // Creates unique ids for nodes
269268
.value(function(d, key) { return nodes.indexOf(d[key]); });
270269

271-
y.domain([0, d3.sum(d3.range(nodes.length)) + nodes.length]).range([0, size[1]]);
270+
y.domain([0, d3Array.sum(d3Array.range(nodes.length)) + nodes.length]).range([0, size[1]]);
272271

273272
var new_data = {};
274273

@@ -300,7 +299,7 @@ export default function() {
300299

301300
if(orient == "up") {
302301
n.x = x(i) + offset[0];
303-
n.y = height - (y(i) + offset[1]) - size[1] / nodes.length;
302+
n.y = size[1] - (y(i) + offset[1]) - size[1] / nodes.length;
304303
} else {
305304
n.x = x(i) + offset[0];
306305
n.y = y(i) + offset[1];
@@ -338,8 +337,6 @@ export default function() {
338337

339338
function pyramid(nodes) {
340339

341-
var spacing = size[0] * 2;
342-
343340
var shiftX = size[0] / (2 * nodes.length );
344341
var shiftY = size[1] / (2 * nodes.length );
345342

@@ -485,4 +482,4 @@ export default function() {
485482
}
486483

487484
return gridding;
488-
};
485+
}

0 commit comments

Comments
 (0)