UNPKG

1.76 kBJavaScriptView Raw
1import { a as array } from "./array-b7dcf730.js";
2import { c as constant, p as path } from "./constant-b644328d.js";
3import { o as curveLinear } from "./mermaid-4b4b971d.js";
4function x(p) {
5 return p[0];
6}
7function y(p) {
8 return p[1];
9}
10function line(x$1, y$1) {
11 var defined = constant(true), context = null, curve = curveLinear, output = null;
12 x$1 = typeof x$1 === "function" ? x$1 : x$1 === void 0 ? x : constant(x$1);
13 y$1 = typeof y$1 === "function" ? y$1 : y$1 === void 0 ? y : constant(y$1);
14 function line2(data) {
15 var i, n = (data = array(data)).length, d, defined0 = false, buffer;
16 if (context == null)
17 output = curve(buffer = path());
18 for (i = 0; i <= n; ++i) {
19 if (!(i < n && defined(d = data[i], i, data)) === defined0) {
20 if (defined0 = !defined0)
21 output.lineStart();
22 else
23 output.lineEnd();
24 }
25 if (defined0)
26 output.point(+x$1(d, i, data), +y$1(d, i, data));
27 }
28 if (buffer)
29 return output = null, buffer + "" || null;
30 }
31 line2.x = function(_) {
32 return arguments.length ? (x$1 = typeof _ === "function" ? _ : constant(+_), line2) : x$1;
33 };
34 line2.y = function(_) {
35 return arguments.length ? (y$1 = typeof _ === "function" ? _ : constant(+_), line2) : y$1;
36 };
37 line2.defined = function(_) {
38 return arguments.length ? (defined = typeof _ === "function" ? _ : constant(!!_), line2) : defined;
39 };
40 line2.curve = function(_) {
41 return arguments.length ? (curve = _, context != null && (output = curve(context)), line2) : curve;
42 };
43 line2.context = function(_) {
44 return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), line2) : context;
45 };
46 return line2;
47}
48export {
49 line as l
50};