UNPKG

844 BJavaScriptView Raw
1import { test } from 'tape';
2import * as d3 from '../';
3
4test('lines don\'t have a draw function', function(t){
5 var _3d = d3._3d().shape('LINE');
6 t.equal(_3d.draw(), undefined);
7 t.end();
8});
9
10test('centroid calculation for lines', function(t){
11 var _3d = d3._3d().shape('LINE').x(function(d){ return d.x; }).y(function(d){ return d.y; }).z(function(d){ return d.z; });
12 var data = [
13 [{x: 0, y: 0, z: 0}, {x: 0, y: 0, z: 0}],
14 [{x: 1, y: 2, z: 3}, {x: 3, y: 2, z: 1}],
15 [{x: 10, y: 9.5, z: 8.6}, {x: 34.3, y: 11.2, z: 27.4}]
16 ];
17 var line0 = _3d(data)[0];
18 var line1 = _3d(data)[1];
19 var line2 = _3d(data)[2];
20 t.deepEqual(line0.centroid, {x: 0, y: 0, z: 0});
21 t.deepEqual(line1.centroid, {x: 2, y: 2, z: 2});
22 t.deepEqual(line2.centroid, {x: 22.15, y: 10.35, z: 18});
23 t.end();
24});