1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = _default;
|
7 |
|
8 | var _index = require("../../../lib-vendor/d3-path/src/index.js");
|
9 |
|
10 | var _array = _interopRequireDefault(require("./array.js"));
|
11 |
|
12 | var _constant = _interopRequireDefault(require("./constant.js"));
|
13 |
|
14 | var _linear = _interopRequireDefault(require("./curve/linear.js"));
|
15 |
|
16 | var _point = require("./point.js");
|
17 |
|
18 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19 |
|
20 | function _default(x, y) {
|
21 | var defined = (0, _constant.default)(true),
|
22 | context = null,
|
23 | curve = _linear.default,
|
24 | output = null;
|
25 | x = typeof x === "function" ? x : x === undefined ? _point.x : (0, _constant.default)(x);
|
26 | y = typeof y === "function" ? y : y === undefined ? _point.y : (0, _constant.default)(y);
|
27 |
|
28 | function line(data) {
|
29 | var i,
|
30 | n = (data = (0, _array.default)(data)).length,
|
31 | d,
|
32 | defined0 = false,
|
33 | buffer;
|
34 | if (context == null) output = curve(buffer = (0, _index.path)());
|
35 |
|
36 | for (i = 0; i <= n; ++i) {
|
37 | if (!(i < n && defined(d = data[i], i, data)) === defined0) {
|
38 | if (defined0 = !defined0) output.lineStart();else output.lineEnd();
|
39 | }
|
40 |
|
41 | if (defined0) output.point(+x(d, i, data), +y(d, i, data));
|
42 | }
|
43 |
|
44 | if (buffer) return output = null, buffer + "" || null;
|
45 | }
|
46 |
|
47 | line.x = function (_) {
|
48 | return arguments.length ? (x = typeof _ === "function" ? _ : (0, _constant.default)(+_), line) : x;
|
49 | };
|
50 |
|
51 | line.y = function (_) {
|
52 | return arguments.length ? (y = typeof _ === "function" ? _ : (0, _constant.default)(+_), line) : y;
|
53 | };
|
54 |
|
55 | line.defined = function (_) {
|
56 | return arguments.length ? (defined = typeof _ === "function" ? _ : (0, _constant.default)(!!_), line) : defined;
|
57 | };
|
58 |
|
59 | line.curve = function (_) {
|
60 | return arguments.length ? (curve = _, context != null && (output = curve(context)), line) : curve;
|
61 | };
|
62 |
|
63 | line.context = function (_) {
|
64 | return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), line) : context;
|
65 | };
|
66 |
|
67 | return line;
|
68 | } |
\ | No newline at end of file |