UNPKG

1.1 kBJavaScriptView Raw
1import { test } from 'tape';
2import * as d3 from '../';
3
4test('test if the number of planes per row are calculated correct when it\'s a quadratic grid', function(t){
5 var j = 10, points = [];
6
7 for(var z = -j; z < j; z++){
8 for(var x = -j; x < j; x++){
9 points.push({x: x, y: 1, z: z});
10 }
11 }
12
13 const grid3d = d3._3d()
14 .shape('GRID', j * 2)
15 .x(function(d){ return d.x; })
16 .y(function(d){ return d.y; })
17 .z(function(d){ return d.z; })(points);
18
19 const row = Math.sqrt(points.length) - 1;
20
21 t.equal(grid3d.length, row*row);
22 t.end();
23});
24
25test('test if the number of planes per row are calculated correct when it\'s not a quadratic grid', function(t){
26
27 var points = [], pointsPerRow = 5;
28
29 for (var z = 0; z < 3; z++) {
30 for (var x = 0; x < 5; x++) {
31 points.push({x: x, y: 1, z: z});
32 }
33 }
34 var grid3d = d3._3d().shape('GRID', pointsPerRow).x(function(d){ return d.x; }).y(function(d){ return d.y; }).z(function(d){ return d.z; })(points);
35
36 t.equal(8, grid3d.length);
37
38 t.end();
39});