UNPKG

@xintao1105/rose-pie

Version:

```bash npm install @xintao1105/rose-pie ```

1,393 lines (1,390 loc) 54.3 kB
var ht = Object.defineProperty; var mt = (f, l, o) => l in f ? ht(f, l, { enumerable: !0, configurable: !0, writable: !0, value: o }) : f[l] = o; var Te = (f, l, o) => (mt(f, typeof l != "symbol" ? l + "" : l, o), o); import $e, { forwardRef as xt, useState as vt, useImperativeHandle as St } from "react"; import { createDebug as bt } from "@feige0629/debug-console"; import * as ie from "d3"; import X from "clone"; var Me = { exports: {} }, Fe = {}; /** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var qe; function yt() { if (qe) return Fe; qe = 1; var f = $e, l = Symbol.for("react.element"), o = Symbol.for("react.fragment"), u = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 }; function m(d, p, E) { var t, y = {}, $ = null, C = null; E !== void 0 && ($ = "" + E), p.key !== void 0 && ($ = "" + p.key), p.ref !== void 0 && (C = p.ref); for (t in p) u.call(p, t) && !s.hasOwnProperty(t) && (y[t] = p[t]); if (d && d.defaultProps) for (t in p = d.defaultProps, p) y[t] === void 0 && (y[t] = p[t]); return { $$typeof: l, type: d, key: $, ref: C, props: y, _owner: n.current }; } return Fe.Fragment = o, Fe.jsx = m, Fe.jsxs = m, Fe; } var je = {}; /** * @license React * react-jsx-runtime.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var Xe; function _t() { return Xe || (Xe = 1, process.env.NODE_ENV !== "production" && function() { var f = $e, l = Symbol.for("react.element"), o = Symbol.for("react.portal"), u = Symbol.for("react.fragment"), n = Symbol.for("react.strict_mode"), s = Symbol.for("react.profiler"), m = Symbol.for("react.provider"), d = Symbol.for("react.context"), p = Symbol.for("react.forward_ref"), E = Symbol.for("react.suspense"), t = Symbol.for("react.suspense_list"), y = Symbol.for("react.memo"), $ = Symbol.for("react.lazy"), C = Symbol.for("react.offscreen"), G = Symbol.iterator, h = "@@iterator"; function r(e) { if (e === null || typeof e != "object") return null; var a = G && e[G] || e[h]; return typeof a == "function" ? a : null; } var T = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; function _(e) { { for (var a = arguments.length, i = new Array(a > 1 ? a - 1 : 0), g = 1; g < a; g++) i[g - 1] = arguments[g]; W("error", e, i); } } function W(e, a, i) { { var g = T.ReactDebugCurrentFrame, b = g.getStackAddendum(); b !== "" && (a += "%s", i = i.concat([b])); var R = i.map(function(v) { return String(v); }); R.unshift("Warning: " + a), Function.prototype.apply.call(console[e], console, R); } } var Z = !1, D = !1, le = !1, te = !1, S = !1, O; O = Symbol.for("react.module.reference"); function k(e) { return !!(typeof e == "string" || typeof e == "function" || e === u || e === s || S || e === n || e === E || e === t || te || e === C || Z || D || le || typeof e == "object" && e !== null && (e.$$typeof === $ || e.$$typeof === y || e.$$typeof === m || e.$$typeof === d || e.$$typeof === p || // This needs to include all possible module reference object // types supported by any Flight configuration anywhere since // we don't know which Flight build this will end up being used // with. e.$$typeof === O || e.getModuleId !== void 0)); } function V(e, a, i) { var g = e.displayName; if (g) return g; var b = a.displayName || a.name || ""; return b !== "" ? i + "(" + b + ")" : i; } function ve(e) { return e.displayName || "Context"; } function M(e) { if (e == null) return null; if (typeof e.tag == "number" && _("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function") return e.displayName || e.name || null; if (typeof e == "string") return e; switch (e) { case u: return "Fragment"; case o: return "Portal"; case s: return "Profiler"; case n: return "StrictMode"; case E: return "Suspense"; case t: return "SuspenseList"; } if (typeof e == "object") switch (e.$$typeof) { case d: var a = e; return ve(a) + ".Consumer"; case m: var i = e; return ve(i._context) + ".Provider"; case p: return V(e, e.render, "ForwardRef"); case y: var g = e.displayName || null; return g !== null ? g : M(e.type) || "Memo"; case $: { var b = e, R = b._payload, v = b._init; try { return M(v(R)); } catch { return null; } } } return null; } var H = Object.assign, Q = 0, Se, z, L, B, A, I, se; function be() { } be.__reactDisabledLog = !0; function ke() { { if (Q === 0) { Se = console.log, z = console.info, L = console.warn, B = console.error, A = console.group, I = console.groupCollapsed, se = console.groupEnd; var e = { configurable: !0, enumerable: !0, value: be, writable: !0 }; Object.defineProperties(console, { info: e, log: e, warn: e, error: e, group: e, groupCollapsed: e, groupEnd: e }); } Q++; } } function Pe() { { if (Q--, Q === 0) { var e = { configurable: !0, enumerable: !0, writable: !0 }; Object.defineProperties(console, { log: H({}, e, { value: Se }), info: H({}, e, { value: z }), warn: H({}, e, { value: L }), error: H({}, e, { value: B }), group: H({}, e, { value: A }), groupCollapsed: H({}, e, { value: I }), groupEnd: H({}, e, { value: se }) }); } Q < 0 && _("disabledDepth fell below zero. This is a bug in React. Please file an issue."); } } var ce = T.ReactCurrentDispatcher, ye; function fe(e, a, i) { { if (ye === void 0) try { throw Error(); } catch (b) { var g = b.stack.trim().match(/\n( *(at )?)/); ye = g && g[1] || ""; } return ` ` + ye + e; } } var _e = !1, re; { var Re = typeof WeakMap == "function" ? WeakMap : Map; re = new Re(); } function pe(e, a) { if (!e || _e) return ""; { var i = re.get(e); if (i !== void 0) return i; } var g; _e = !0; var b = Error.prepareStackTrace; Error.prepareStackTrace = void 0; var R; R = ce.current, ce.current = null, ke(); try { if (a) { var v = function() { throw Error(); }; if (Object.defineProperty(v.prototype, "props", { set: function() { throw Error(); } }), typeof Reflect == "object" && Reflect.construct) { try { Reflect.construct(v, []); } catch (q) { g = q; } Reflect.construct(e, [], v); } else { try { v.call(); } catch (q) { g = q; } e.call(v.prototype); } } else { try { throw Error(); } catch (q) { g = q; } e(); } } catch (q) { if (q && g && typeof q.stack == "string") { for (var x = q.stack.split(` `), N = g.stack.split(` `), j = x.length - 1, P = N.length - 1; j >= 1 && P >= 0 && x[j] !== N[P]; ) P--; for (; j >= 1 && P >= 0; j--, P--) if (x[j] !== N[P]) { if (j !== 1 || P !== 1) do if (j--, P--, P < 0 || x[j] !== N[P]) { var Y = ` ` + x[j].replace(" at new ", " at "); return e.displayName && Y.includes("<anonymous>") && (Y = Y.replace("<anonymous>", e.displayName)), typeof e == "function" && re.set(e, Y), Y; } while (j >= 1 && P >= 0); break; } } } finally { _e = !1, ce.current = R, Pe(), Error.prepareStackTrace = b; } var xe = e ? e.displayName || e.name : "", Je = xe ? fe(xe) : ""; return typeof e == "function" && re.set(e, Je), Je; } function Ve(e, a, i) { return pe(e, !1); } function we(e) { var a = e.prototype; return !!(a && a.isReactComponent); } function ue(e, a, i) { if (e == null) return ""; if (typeof e == "function") return pe(e, we(e)); if (typeof e == "string") return fe(e); switch (e) { case E: return fe("Suspense"); case t: return fe("SuspenseList"); } if (typeof e == "object") switch (e.$$typeof) { case p: return Ve(e.render); case y: return ue(e.type, a, i); case $: { var g = e, b = g._payload, R = g._init; try { return ue(R(b), a, i); } catch { } } } return ""; } var de = Object.prototype.hasOwnProperty, ge = {}, J = T.ReactDebugCurrentFrame; function ne(e) { if (e) { var a = e._owner, i = ue(e.type, e._source, a ? a.type : null); J.setExtraStackFrame(i); } else J.setExtraStackFrame(null); } function oe(e, a, i, g, b) { { var R = Function.call.bind(de); for (var v in e) if (R(e, v)) { var x = void 0; try { if (typeof e[v] != "function") { var N = Error((g || "React class") + ": " + i + " type `" + v + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[v] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."); throw N.name = "Invariant Violation", N; } x = e[v](a, v, g, i, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"); } catch (j) { x = j; } x && !(x instanceof Error) && (ne(b), _("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", g || "React class", i, v, typeof x), ne(null)), x instanceof Error && !(x.message in ge) && (ge[x.message] = !0, ne(b), _("Failed %s type: %s", i, x.message), ne(null)); } } } var ee = Array.isArray; function c(e) { return ee(e); } function Ce(e) { { var a = typeof Symbol == "function" && Symbol.toStringTag, i = a && e[Symbol.toStringTag] || e.constructor.name || "Object"; return i; } } function he(e) { try { return ae(e), !1; } catch { return !0; } } function ae(e) { return "" + e; } function F(e) { if (he(e)) return _("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Ce(e)), ae(e); } var Ee = T.ReactCurrentOwner, Qe = { key: !0, ref: !0, __self: !0, __source: !0 }, Ae, Ye, Ie; Ie = {}; function et(e) { if (de.call(e, "ref")) { var a = Object.getOwnPropertyDescriptor(e, "ref").get; if (a && a.isReactWarning) return !1; } return e.ref !== void 0; } function tt(e) { if (de.call(e, "key")) { var a = Object.getOwnPropertyDescriptor(e, "key").get; if (a && a.isReactWarning) return !1; } return e.key !== void 0; } function rt(e, a) { if (typeof e.ref == "string" && Ee.current && a && Ee.current.stateNode !== a) { var i = M(Ee.current.type); Ie[i] || (_('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', M(Ee.current.type), e.ref), Ie[i] = !0); } } function nt(e, a) { { var i = function() { Ae || (Ae = !0, _("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", a)); }; i.isReactWarning = !0, Object.defineProperty(e, "key", { get: i, configurable: !0 }); } } function ot(e, a) { { var i = function() { Ye || (Ye = !0, _("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", a)); }; i.isReactWarning = !0, Object.defineProperty(e, "ref", { get: i, configurable: !0 }); } } var at = function(e, a, i, g, b, R, v) { var x = { // This tag allows us to uniquely identify this as a React Element $$typeof: l, // Built-in properties that belong on the element type: e, key: a, ref: i, props: v, // Record the component responsible for creating this element. _owner: R }; return x._store = {}, Object.defineProperty(x._store, "validated", { configurable: !1, enumerable: !1, writable: !0, value: !1 }), Object.defineProperty(x, "_self", { configurable: !1, enumerable: !1, writable: !1, value: g }), Object.defineProperty(x, "_source", { configurable: !1, enumerable: !1, writable: !1, value: b }), Object.freeze && (Object.freeze(x.props), Object.freeze(x)), x; }; function it(e, a, i, g, b) { { var R, v = {}, x = null, N = null; i !== void 0 && (F(i), x = "" + i), tt(a) && (F(a.key), x = "" + a.key), et(a) && (N = a.ref, rt(a, b)); for (R in a) de.call(a, R) && !Qe.hasOwnProperty(R) && (v[R] = a[R]); if (e && e.defaultProps) { var j = e.defaultProps; for (R in j) v[R] === void 0 && (v[R] = j[R]); } if (x || N) { var P = typeof e == "function" ? e.displayName || e.name || "Unknown" : e; x && nt(v, P), N && ot(v, P); } return at(e, x, N, b, g, Ee.current, v); } } var Oe = T.ReactCurrentOwner, Le = T.ReactDebugCurrentFrame; function me(e) { if (e) { var a = e._owner, i = ue(e.type, e._source, a ? a.type : null); Le.setExtraStackFrame(i); } else Le.setExtraStackFrame(null); } var Ne; Ne = !1; function We(e) { return typeof e == "object" && e !== null && e.$$typeof === l; } function De() { { if (Oe.current) { var e = M(Oe.current.type); if (e) return ` Check the render method of \`` + e + "`."; } return ""; } } function lt(e) { { if (e !== void 0) { var a = e.fileName.replace(/^.*[\\\/]/, ""), i = e.lineNumber; return ` Check your code at ` + a + ":" + i + "."; } return ""; } } var He = {}; function st(e) { { var a = De(); if (!a) { var i = typeof e == "string" ? e : e.displayName || e.name; i && (a = ` Check the top-level render call using <` + i + ">."); } return a; } } function Be(e, a) { { if (!e._store || e._store.validated || e.key != null) return; e._store.validated = !0; var i = st(a); if (He[i]) return; He[i] = !0; var g = ""; e && e._owner && e._owner !== Oe.current && (g = " It was passed a child from " + M(e._owner.type) + "."), me(e), _('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', i, g), me(null); } } function Ue(e, a) { { if (typeof e != "object") return; if (c(e)) for (var i = 0; i < e.length; i++) { var g = e[i]; We(g) && Be(g, a); } else if (We(e)) e._store && (e._store.validated = !0); else if (e) { var b = r(e); if (typeof b == "function" && b !== e.entries) for (var R = b.call(e), v; !(v = R.next()).done; ) We(v.value) && Be(v.value, a); } } } function ct(e) { { var a = e.type; if (a == null || typeof a == "string") return; var i; if (typeof a == "function") i = a.propTypes; else if (typeof a == "object" && (a.$$typeof === p || // Note: Memo only checks outer props here. // Inner props are checked in the reconciler. a.$$typeof === y)) i = a.propTypes; else return; if (i) { var g = M(a); oe(i, e.props, "prop", g, e); } else if (a.PropTypes !== void 0 && !Ne) { Ne = !0; var b = M(a); _("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", b || "Unknown"); } typeof a.getDefaultProps == "function" && !a.getDefaultProps.isReactClassApproved && _("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead."); } } function ft(e) { { for (var a = Object.keys(e.props), i = 0; i < a.length; i++) { var g = a[i]; if (g !== "children" && g !== "key") { me(e), _("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", g), me(null); break; } } e.ref !== null && (me(e), _("Invalid attribute `ref` supplied to `React.Fragment`."), me(null)); } } function Ge(e, a, i, g, b, R) { { var v = k(e); if (!v) { var x = ""; (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (x += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."); var N = lt(b); N ? x += N : x += De(); var j; e === null ? j = "null" : c(e) ? j = "array" : e !== void 0 && e.$$typeof === l ? (j = "<" + (M(e.type) || "Unknown") + " />", x = " Did you accidentally export a JSX literal instead of a component?") : j = typeof e, _("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", j, x); } var P = it(e, a, i, b, R); if (P == null) return P; if (v) { var Y = a.children; if (Y !== void 0) if (g) if (c(Y)) { for (var xe = 0; xe < Y.length; xe++) Ue(Y[xe], e); Object.freeze && Object.freeze(Y); } else _("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."); else Ue(Y, e); } return e === u ? ft(P) : ct(P), P; } } function pt(e, a, i) { return Ge(e, a, i, !0); } function ut(e, a, i) { return Ge(e, a, i, !1); } var dt = ut, gt = pt; je.Fragment = u, je.jsx = dt, je.jsxs = gt; }()), je; } process.env.NODE_ENV === "production" ? Me.exports = yt() : Me.exports = _t(); var w = Me.exports; const Rt = "_legend_wrapper_1nuwc_1", wt = "_legend_wrapper_ul_1nuwc_5", Ct = "_legend_wrapper_li_1nuwc_10", Et = "_legend_module_contentStyle_1nuwc_15", Tt = "_label_line_1nuwc_22", Ft = "_dash_1nuwc_1", jt = "_label_text_1nuwc_27", $t = "_show_1nuwc_1", kt = "_inner_arc_1nuwc_31", K = { legend_wrapper: Rt, legend_wrapper_ul: wt, legend_wrapper_li: Ct, legend_module_contentStyle: Et, label_line: Tt, dash: Ft, label_text: jt, show: $t, inner_arc: kt }, Pt = (f, l) => { const { category: o, proportion: u, trueValue: n, legendSpacing: s, layoutSpacing: m, layoutNumberColumns: d, layoutDeviation: p, legendPosition: E } = f; if (f && typeof f != "boolean") { let t = {}, y = {}, $ = {}, C = {}; if (o && typeof o != "boolean") { const r = o.textStyle; t = { fontSize: (r == null ? void 0 : r.fontSize) + "px", color: r == null ? void 0 : r.color, fontFamily: r == null ? void 0 : r.fontFamily, fontWeight: r == null ? void 0 : r.fontWeight, fontStyle: r == null ? void 0 : r.fontStyle, lineHeight: (r == null ? void 0 : r.lineHeight) + "px", letterSpacing: (r == null ? void 0 : r.letterSpacing) + "px", paddingLeft: s + "px" }; } if (u && typeof u != "boolean") { const r = u.textStyle; y = { fontSize: (r == null ? void 0 : r.fontSize) + "px", color: r == null ? void 0 : r.color, fontFamily: r == null ? void 0 : r.fontFamily, fontWeight: r == null ? void 0 : r.fontWeight, fontStyle: r == null ? void 0 : r.fontStyle, lineHeight: (r == null ? void 0 : r.lineHeight) + "px", letterSpacing: (r == null ? void 0 : r.letterSpacing) + "px", marginLeft: u.spacing + "px" }; } if (n && typeof n != "boolean") { const r = n.textStyle; if ($ = { fontSize: (r == null ? void 0 : r.fontSize) + "px", color: r == null ? void 0 : r.color, fontFamily: r == null ? void 0 : r.fontFamily, fontWeight: r == null ? void 0 : r.fontWeight, fontStyle: r == null ? void 0 : r.fontStyle, lineHeight: (r == null ? void 0 : r.lineHeight) + "px", letterSpacing: (r == null ? void 0 : r.letterSpacing) + "px", marginLeft: n.spacing + "px", display: "flex", alignItems: "center", justifyContent: "flex-start" }, n.suffix && typeof n.suffix != "boolean") { const T = n.suffix.deviation; C = { fontSize: n.suffix.fontSize + "px", transform: "translate3d(0px, 0px, 0px)", color: r == null ? void 0 : r.color, fontFamily: r == null ? void 0 : r.fontFamily, fontWeight: r == null ? void 0 : r.fontWeight, fontStyle: r == null ? void 0 : r.fontStyle, lineHeight: (r == null ? void 0 : r.lineHeight) + "px", letterSpacing: (r == null ? void 0 : r.letterSpacing) + "px", marginLeft: T.x + "px", marginTop: T.y + "px" }; } } const G = { display: "grid", gap: `${m == null ? void 0 : m.row}px ${m == null ? void 0 : m.column}px`, gridTemplateColumns: `repeat(${d}, ${d}fr)` }; return { show: !0, legendStyle: { position: "absolute", height: "auto", display: "flex", // pointerEvents: "none", ...It(E, p) }, ulStyle: G, // 类目 a: t, // 占比值 b: y, // 真实值 c: $, // 后缀 d: C }; } else return { show: !1 }; }, Vt = (f, l) => { const { tipSpacing: o, category: u, trueValue: n, proportion: s } = f; let m = {}, d = {}, p = {}, E = {}; if (u && typeof u != "boolean") { const t = u.textStyle; m = { fontSize: (t == null ? void 0 : t.fontSize) + "px", color: t == null ? void 0 : t.color, fontFamily: t == null ? void 0 : t.fontFamily, fontWeight: t == null ? void 0 : t.fontWeight, fontStyle: t == null ? void 0 : t.fontStyle, lineHeight: (t == null ? void 0 : t.lineHeight) + "px", letterSpacing: (t == null ? void 0 : t.letterSpacing) + "px", paddingLeft: o + "px" }; } if (s && typeof s != "boolean") { const t = s.textStyle; d = { fontSize: (t == null ? void 0 : t.fontSize) + "px", color: t == null ? void 0 : t.color, fontFamily: t == null ? void 0 : t.fontFamily, fontWeight: t == null ? void 0 : t.fontWeight, fontStyle: t == null ? void 0 : t.fontStyle, lineHeight: (t == null ? void 0 : t.lineHeight) + "px", letterSpacing: (t == null ? void 0 : t.letterSpacing) + "px", marginLeft: s.spacing + "px" }; } if (n && typeof n != "boolean") { const t = n.textStyle; if (p = { fontSize: (t == null ? void 0 : t.fontSize) + "px", color: t == null ? void 0 : t.color, fontFamily: t == null ? void 0 : t.fontFamily, fontWeight: t == null ? void 0 : t.fontWeight, fontStyle: t == null ? void 0 : t.fontStyle, lineHeight: (t == null ? void 0 : t.lineHeight) + "px", letterSpacing: (t == null ? void 0 : t.letterSpacing) + "px", marginLeft: n.spacing + "px", display: "flex", alignItems: "center", justifyContent: "flex-start" }, n.suffix && typeof n.suffix != "boolean") { const y = n.suffix.deviation; E = { fontSize: n.suffix.fontSize + "px", transform: "translate3d(0px, 0px, 0px)", color: t == null ? void 0 : t.color, fontFamily: t == null ? void 0 : t.fontFamily, fontWeight: t == null ? void 0 : t.fontWeight, fontStyle: t == null ? void 0 : t.fontStyle, lineHeight: (t == null ? void 0 : t.lineHeight) + "px", letterSpacing: (t == null ? void 0 : t.letterSpacing) + "px", marginLeft: y.x + "px", marginTop: y.y + "px" }; } } return { show: !0, // 类目 a: m, // 占比值 b: d, // 真实值 c: p, // 后缀 d: E }; }, It = (f = 5, l) => { let o = {}; return f === 0 ? o = { left: 0, top: 5, justifyContent: "flex-start", transform: `translate3d(${l.x}px, ${l.y}px, 0px)` } : f === 1 ? o = { left: "50%", top: 5, justifyContent: "center", transform: `translate3d(${l.x}px, ${l.y}px, 0px) translateX(-50%)` } : f === 2 ? o = { right: 0, top: 5, justifyContent: "flex-end", transform: `translate3d(${l.x}px, ${l.y}px, 0px)` } : f === 3 ? o = { left: 0, top: "50%", alignItems: "center", transform: `translate3d(${l.x}px, ${l.y}px, 0px) translateY(-50%)` } : f === 4 ? o = { left: "50%", top: "50%", alignItems: "center", justifyContent: "center", transform: `translate3d(${l.x}px, ${l.y}px, 0px) translate(-50%,-50%)` } : f === 5 ? o = { right: 0, top: "50%", alignItems: "center", justifyContent: "flex-end", transform: `translate3d(${l.x}px, ${l.y}px, 0px) translateY(-50%)` } : f === 6 ? o = { left: 0, bottom: 0, justifyContent: "flex-start", alignItems: "flex-end", transform: `translate3d(${l.x}px, ${l.y}px, 0px)` } : f === 7 ? o = { left: "50%", bottom: 0, justifyContent: "center", alignItems: "flex-end", transform: `translate3d(${l.x}px, ${l.y}px, 0px) translateX(-50%)` } : f === 8 && (o = { right: 0, bottom: 0, justifyContent: "flex-end", alignItems: "flex-end", transform: `translate3d(${l.x}px, ${l.y}px, 0px)` }), o; }, ze = (f = 0) => { const l = (s, m, d) => { const p = s[0], E = s[1], t = m[0], y = m[1], $ = Math.cos(d), C = Math.sin(d); return [(p - t) * $ - (E - y) * C + t, (p - t) * C + (E - y) * $ + y]; }, o = (s) => s / (180 / Math.PI); let u = [0, 0], n = [1, 0]; if (f) { const s = [0, 0]; u = l(u, s, o(f)), n = l(n, s, o(f)); } return { x: u[0], y: u[1], x2: n[0], y2: n[1] }; }; let U = 0; const Ze = (f = 0, l, o, u) => { u == 1 ? U += f : U = 0; for (let n = 0; n < l.length - U; n++) { if (o.length < n + 1) { Ze(n, l, o, 1); return; } l[U + n].color = { type: "linear", ...ze(o[n].color.direction), colorStops: [ { offset: 0, color: o[n].color.startVal // 0% 处的颜色 }, { offset: 1, color: o[n].color.endVal // 100% 处的颜色 } ] }, l[U + n].startVal = o[n].color.startVal, l[U + n].endVal = o[n].color.endVal, l[U + n].direction = o[n].color.direction, l[U + n].displayName = o[n].displayName, l[U + n].seriesLegendIcon = o[n].seriesLegendIcon; } return l; }, Ot = (f, l) => { for (let o = 0; o < l.length; o++) { const u = l[o]; u.name === f.seriesMapping.fieldName && (u.color = { type: "linear", ...ze(f.seriesColor.direction), colorStops: [ { offset: 0, color: f.seriesColor.startVal // 0% 处的颜色 }, { offset: 1, color: f.seriesColor.endVal // 100% 处的颜色 } ], global: !1 // 缺省为 false }, u.startVal = f.seriesColor.startVal, u.endVal = f.seriesColor.endVal, u.direction = f.seriesColor.direction, u.displayName = f.seriesMapping.displayName, u.seriesLegendIcon = f.seriesLegendIcon); } return l; }, Ke = (f, l) => { const { dataSeries: o = [] } = f, u = [], n = []; let s = []; const m = []; if (o.length === 0) return []; for (let d = 0; d < o.length; d++) { const p = o[d]; p.seriesMapping.fieldName && !u.includes(p.seriesMapping.fieldName) && u.push(p.seriesMapping.fieldName), m.push({ color: p.seriesColor, displayName: p.seriesMapping.displayName, seriesLegendIcon: p.seriesLegendIcon }); } if (u.length > 0) { for (let d = 0; d < l.length; d++) l[d].color = { type: "linear", ...ze( o[o.length - 1].seriesColor.direction ), colorStops: [ { offset: 0, color: o[o.length - 1].seriesColor.startVal // 0% 处的颜色 }, { offset: 1, color: o[o.length - 1].seriesColor.endVal // 100% 处的颜色 } ] }, l[d].startVal = o[o.length - 1].seriesColor.startVal, l[d].endVal = o[o.length - 1].seriesColor.endVal, l[d].direction = o[o.length - 1].seriesColor.direction, s.push(l[d]); for (let d = 0; d < o.length; d++) { const p = o[d]; p.seriesMapping.fieldName && (n.includes(p.seriesMapping.fieldName) || (n.push(p.seriesMapping.fieldName), s = Ot(p, l))); } } else U = 0, Ze(0, l, m, 0), s = l; return s; }, Nt = (f) => { const l = f.data; let o = X(l); const u = f.filterData, n = f.params.legend; if (!n || typeof n == "boolean") return; if (n.order === "desc" && (o = l.sort((h, r) => r.value - h.value)), n.order === "asc" && (o = l.sort((h, r) => h.value - r.value)), n.order === "") { const h = []; for (let r = 0; r < u.length; r++) { const T = u[r]; for (let _ = 0; _ < l.length; _++) { const W = l[_]; T.s === W.s && h.push(W); } } o = h; } let s = 0; for (let h = 0; h < o.length; h++) { const r = o[h].value; o[h].custom || (s += r); } const m = Pt(n), d = (h) => { var _, W, Z, D; const r = { minWidth: ((_ = n.legendGraphicalSize) == null ? void 0 : _.width) || "0px", minHeight: ((W = n.legendGraphicalSize) == null ? void 0 : W.height) || "0px", marginRight: n.legendSpacing + "px", background: `linear-gradient(${h.direction}deg, ${h.startVal} 0%, ${h.endVal} 100%)`, borderRadius: n.graphicFillet + "px" }, T = { minWidth: ((Z = n.legendGraphicalSize) == null ? void 0 : Z.width) || "0px", minHeight: ((D = n.legendGraphicalSize) == null ? void 0 : D.height) || "0px", marginRight: n.legendSpacing + "px", backgroundImage: `url(${h.seriesLegendIcon ? h.seriesLegendIcon : n.legendIcon})`, backgroundRepeat: "no-repeat", backgroundPosition: "50%", backgroundSize: "contain", borderRadius: n.graphicFillet + "px" }; return n.legendType === "legendTypePreset" ? r : T; }, p = m.legendStyle, E = m.ulStyle, t = m.a, y = m.c, $ = m.d, C = m.b, G = (h) => { const r = u.filter((T) => T.s === h); f.onClick && typeof f.onClick == "function" && f.onClick(r[0]); }; return /* @__PURE__ */ w.jsx("div", { className: K.legend_wrapper, style: p, children: /* @__PURE__ */ w.jsx("ul", { style: E, children: o.map((h) => !h.custom && /* @__PURE__ */ w.jsxs( "li", { className: K.legend_wrapper_li, onClick: () => G(h.name), children: [ /* @__PURE__ */ w.jsx("span", { style: d(h) }), /* @__PURE__ */ w.jsxs("span", { className: K.legend_module_contentStyle, children: [ n.category && /* @__PURE__ */ w.jsx("span", { style: t, children: h.displayName ? h.displayName : h.name }), /* @__PURE__ */ w.jsxs("div", { style: { display: "flex" }, children: [ n.trueValue && typeof n.trueValue != "boolean" && /* @__PURE__ */ w.jsxs( "span", { style: n.trueValue.colorFollow ? { ...y, color: h.endVal } : y, children: [ /* @__PURE__ */ w.jsx("span", { children: h.value }), n.trueValue.suffix && typeof n.trueValue.suffix != "boolean" && /* @__PURE__ */ w.jsx( "span", { style: n.trueValue.colorFollow ? { ...$, color: h.endVal } : $, children: n.trueValue.suffix.content } ) ] } ), n.proportion && typeof n.proportion != "boolean" && /* @__PURE__ */ w.jsxs( "span", { style: n.proportion.colorFollow ? { ...C, color: h.endVal } : C, children: [ s === 0 ? 0 : (h.value / s * 100).toFixed( n.proportion.decimalPlaces ), "%" ] } ) ] }) ] }) ] }, h.name )) }) }); }, Wt = xt((f, l) => { const [o, u] = vt(0); St(l, () => ({ setIndex: (S) => u(S) })); let n = f.data; const s = { tipGraphicalSize: { width: 10, height: 10 }, tipSpacing: 5, tipgraphicFillet: 0, tipIconSize: { width: 20, height: 20 }, tipIcon: "", tipType: "Preset", category: { textStyle: { fontFamily: "Microsoft Yahei", fontSize: 12, color: "rgba(230,247,255,0.7)", fontWeight: "normal", fontStyle: "normal", letterSpacing: 0 } }, trueValue: !1, proportion: { decimalPlaces: 0, spacing: 15, colorFollow: !0, textStyle: { fontFamily: "Microsoft Yahei", fontSize: 12, color: "#E5F1FF", fontWeight: "normal", fontStyle: "normal", letterSpacing: 0 } } }, { seriesOrder: m, promptBoxTabs: d = s } = f.params, { tipGraphicalSize: p, tipSpacing: E, tipgraphicFillet: t, tipIconSize: y, tipIcon: $, tipType: C, category: G, trueValue: h, proportion: r } = d; m === "desc" && (n = f.data.sort((S, O) => O.value - S.value)), m === "asc" && (n = f.data.sort((S, O) => S.value - O.value)); let T = 0; for (let S = 0; S < n.length; S++) { const O = n[S].value; n[S].custom || (T += O); } const _ = Vt(d), W = (S) => { const O = { minWidth: (p == null ? void 0 : p.width) || "0px", minHeight: (p == null ? void 0 : p.height) || "0px", marginRight: E + "px", background: `linear-gradient(${S.direction}deg, ${S.startVal} 0%, ${S.endVal} 100%)`, borderRadius: t + "px" }, k = { minWidth: (y == null ? void 0 : y.width) || "0px", minHeight: (y == null ? void 0 : y.height) || "0px", marginRight: E + "px", backgroundImage: `url(${S.seriestipIcon ? S.seriestipIcon : $})`, backgroundRepeat: "no-repeat", backgroundPosition: "50%", backgroundSize: "contain", borderRadius: t + "px" }; return C === "Preset" ? O : k; }, Z = _.a, D = _.c, le = _.d, te = _.b; return /* @__PURE__ */ w.jsx("div", { className: K.legend_wrapper, children: /* @__PURE__ */ w.jsx("ul", { children: n.map((S, O) => !S.custom && O === o && /* @__PURE__ */ w.jsxs("li", { className: K.legend_wrapper_li, children: [ /* @__PURE__ */ w.jsx("span", { style: W(S) }), /* @__PURE__ */ w.jsxs("span", { className: K.legend_module_contentStyle, children: [ G && /* @__PURE__ */ w.jsx("span", { style: Z, children: S.displayName ? S.displayName : S.name }), h && typeof h != "boolean" && /* @__PURE__ */ w.jsxs( "span", { style: h.colorFollow ? { ...D, color: S.endVal } : D, children: [ /* @__PURE__ */ w.jsx("span", { children: S.value }), h.suffix && typeof h.suffix != "boolean" && /* @__PURE__ */ w.jsx( "span", { style: h.colorFollow ? { ...le, color: S.endVal } : le, children: h.suffix.content } ) ] } ), r && typeof r != "boolean" && /* @__PURE__ */ w.jsxs( "span", { style: r.colorFollow ? { ...te, color: S.endVal } : te, children: [ T === 0 ? 0 : (S.value / T * 100).toFixed( r.decimalPlaces ), "%" ] } ) ] }) ] }, S.name)) }) }); }), Mt = bt( "false", "dateTimePicker", { scope: "Green", desc: "RedBackground" } ); Mt("13213"); const zt = [ { s: "系列一", y: 67 }, { s: "系列二", y: 34 }, { s: "系列三", y: 18 }, { s: "系列四", y: 9 }, { s: "系列五", y: 6 } ], At = [ { seriesMapping: { fieldName: "", displayName: "" }, seriesColor: { startVal: "rgba(0,214,138,1)", endVal: "rgba(0,214,138,1)", direction: 30 }, seriesLegendIcon: "" }, { seriesMapping: { fieldName: "", displayName: "" }, seriesColor: { startVal: "rgba(186,231,255,1)", endVal: "rgba(186,231,255,1)", direction: 30 }, seriesLegendIcon: "" }, { seriesMapping: { fieldName: "", displayName: "" }, seriesColor: { startVal: "rgba(47,84,235,1)", endVal: "rgba(47,84,235,1)", direction: 30 }, seriesLegendIcon: "" }, { seriesMapping: { fieldName: "", displayName: "" }, seriesColor: { startVal: "rgba(30,231,231,1)", endVal: "rgba(30,231,231,1)", direction: 30 }, seriesLegendIcon: "" }, { seriesMapping: { fieldName: "", displayName: "" }, seriesColor: { startVal: "rgba(24,144,255,1)", endVal: "rgba(24,144,255,1)", direction: 30 }, seriesLegendIcon: "" } ]; class Yt extends $e.Component { constructor(o) { super(o); Te(this, "d3Node"); Te(this, "domRef", $e.createRef()); Te(this, "tooltipRef", $e.createRef()); this.state = {}; } setData() { return (this.props.data || []).map((n) => ({ s: n.s, y: n.y, name: n.s, value: n.y, displayName: "", extra: n })); } getSort() { const o = this.props, u = this.setData(); let n = X(u), s = 0, m = 0; if (n && n.length > 0) { o.seriesOrder === "desc" ? (n = X(u).sort((d, p) => p.y - d.y), s = n[0].y) : o.seriesOrder === "asc" ? (n = X(u).sort((d, p) => d.y - p.y), s = n[n.length - 1].y) : s = X(u).sort((p, E) => E.y - p.y)[0].y; for (let d = 0; d < u.length; d++) { const p = u[d]; m += p.y; } } return { data: n, maxValue: s, total: m }; } init() { const { data: o, maxValue: u, total: n } = this.getSort(); if (o.length == 0) return !1; const s = this.props.base.width, m = this.props.base.height, d = (this.props.innerRadius || 0) * Math.min(s, m) / 2, p = (this.props.outerRadius || 1) * Math.min(s, m) / 2, E = "none", t = 0, $ = (this.props.graphicalSpacing || 4) / p, C = this.props.margin, h = ie.select(this.d3Node).attr("width", s).attr("height", m).attr("style", `width: ${s}px; height: ${m}px;`).append("g").attr( "transform", `translate(${(C == null ? void 0 : C.left) || 0}, ${(C == null ? void 0 : C.top) || 0})` ), r = `transition: transform 0.3s ease-in-out 0s; transform: translate(${s / 2 - (((C == null ? void 0 : C.right) || 0) - p / 2)}px, ${m / 2}px) rotate(0deg);`, T = h.append("g").attr("style", r), _ = T.append("g"), W = (k, V) => [Math.cos(k) * V, Math.sin(k) * V], Z = (k, V) => k ? V == "vertical" ? "" : "0.5em" : "", D = o.map(() => 10), le = ie.range(o.length).filter((k) => !isNaN(D[k])), te = ie.pie().padAngle($).sort(null).value((k) => D[k])(le), S = Ke(this.props, X(o)), O = Math.ceil(Math.PI * d * 2 / S.length); S.map((k, V) => { const ve = "rose_pie_linear_" + V, M = o[V].y / u * (p - d), H = M > 5 ? M : 5, Q = ie.arc().innerRadius(d).outerRadius(d + H).cornerRadius(2); T.append("path").attr("class", K.inner_arc).style("stroke-dasharray", `${O},${2 * O}`).style("stroke-dashoffset", `${O}`).style("animation-delay", `${2e3 * V}ms`).attr("data-index", V).attr("d", Q(te[V])).attr("stroke", E).attr("stroke-width", t).attr("fill", `url(#${ve})`).attr("fill-opacity", 1).on("click", (z) => { z.preventDefault(), z.stopPropagation(), this.onClick(k); }).on("mousemove", (z) => { var L, B, A; if ((L = this.props.promptBoxTabs) != null && L.hoverTrigger) { const I = (B = this.domRef) != null && B.clientHeight ? (A = this.domRef) == null ? void 0 : A.clientHeight : 50; this.domRef.style.transform = `translate3d(${z.offsetX}px, ${z.offsetY - (I + 10)}px, 0px)`, this.domRef.style.display = "flex", this.tooltipRef.setIndex(V); } }).on("mouseleave", (z) => { var L, B, A; if ((L = this.props.promptBoxTabs) != null && L.hoverTrigger) { const I = (B = this.domRef) != null && B.clientHeight ? (A = this.domRef) == null ? void 0 : A.clientHeight : 50; this.domRef.style.transform = `translate3d(0px, ${0 - (I + 10)}px, 0px)`, this.domRef.style.display = "none"; } }); const Se = T.append("defs").append("linearGradient").attr("id", ve).attr("x1", 0).attr("y1", 0).attr("x2", 0).attr("y2", 1).attr("gradientTransform", `rotate(${k.direction + 180}, 0.5, 0.5)`); if (Se.append("stop").attr("key", 0).attr("offset", k.color.colorStops[0].offset).attr("stop-color", k.color.colorStops[0].color).attr("stop-opacity", 1), Se.append("stop").attr("key", 1).attr("offset", k.color.colorStops[1].offset).attr("stop-color", k.color.colorStops[1].color).attr("stop-opacity", 1), this.props.valueLabel && typeof this.props.valueLabel != "boolean") { const { lineLength: z, deviation: L, layout: B, category: A, trueValue: I, proportion: se } = this.props.valueLabel, be = d + H, ke = Q.centroid(te[V]), Pe = Math.atan2(ke[1], ke[0]), ce = W(Pe, be), ye = ce[0], fe = ce[1], _e = W(Pe, be + z.line1), re = _e, Re = re[0], pe = re[1], Ve = Re < 0 ? -1 : 1, we = Re + z.line2 * Ve, ue = L.x, de = L.y, ge = we + (ue + 6) * Ve, J = B, ne = _.append("g"); ne.append("path").attr("class", K.label_line).style("animation-delay", `${2e3 * (V + 1) - 800}ms`).attr("d", `M${ye}, ${fe}L${Re}, ${pe}L${we}, ${pe}`).attr("stroke", k.color.colorStops[0].color).attr("fill", "none"); const oe = ne.append("text"); if (oe.attr("class", K.label_text).style("animation-delay", `${2e3 * (V + 1) - 800}ms`).attr("x", ge).attr("y", pe + de).attr("dominant-baseline", "middle").attr("text-anchor", we >= 0 ? "start" : "end"), A && typeof A != "boolean") { const c = A.textStyle; oe.append("tspan").attr("font-size", (c == null ? void 0 : c.fontSize) || "12px").attr("fill", (c == null ? void 0 : c.color) || "rgba(230,247,255,0.7)").attr("font-family", (c == null ? void 0 : c.fontFamily) || "Microsoft Yahei").attr("letter-spacing", (c == null ? void 0 : c.letterSpacing) || "0px").attr("font-weight", (c == null ? void 0 : c.fontWeight) || "normal").attr("font-style", (c == null ? void 0 : c.fontStyle) || "normal").text(o[V].s + ":"); } const ee = typeof I == "boolean" ? I : !0; if (I && typeof I != "boolean") { const c = I.textStyle; if (oe.append("tspan").attr("x", ee && J === "vertical" ? ge : "").attr("dx", Z(ee, J)).attr("dy", ee && J === "vertical" ? "1.5em" : "").attr("font-size", (c == null ? void 0 : c.fontSize) || "12px").attr("fill", (c == null ? void 0 : c.color) || "rgba(230,247,255,0.7)").attr("font-family", (c == null ? void 0 : c.fontFamily) || "Microsoft Yahei").attr("letter-spacing", (c == null ? void 0 : c.letterSpacing) || "0px").attr("font-weight", (c == null ? void 0 : c.fontWeight) || "normal").attr("font-style", (c == null ? void 0 : c.fontStyle) || "normal").text(o[V].y), I != null && I.suffix && typeof I.suffix != "boolean") { const { content: Ce, fontSize: he, deviation: ae } = I.suffix; oe.append("tspan").attr("dx", ae.x).attr("dy", ae.y).attr("font-size", he + "px").attr("fill", (c == null ? void 0 : c.color) || "rgba(230,247,255,0.7)").attr("font-family", (c == null ? void 0 : c.fontFamily) || "Microsoft Yahei").attr("letter-spacing", (c == null ? void 0 : c.letterSpacing) || "0px").attr("font-weight", (c == null ? void 0 : c.fontWeight) || "normal").attr("font-style", (c == null ? void 0 : c.fontStyle) || "normal").text(Ce); } } if (se && typeof se != "boolean") { const { decimalPlaces: c, textStyle: Ce } = se, he = Math.round(o[V].y / n * 100).toFixed( c || 0 ), ae = I ? `(${he}%)` : `${he}%`, F = Ce; oe.append("tspan").attr("x", !ee && J === "vertical" ? ge : "").attr("dx", !ee && J === "vertical" ? 0 : "0.5em").attr("dy", !ee && J === "vertical" ? "1.5em" : 0).attr("font-size", (F == null ? void 0 : F.fontSize) || "12px").attr("fill", (F == null ? void 0 : F.color) || "rgba(230,247,255,1)").attr("font-family", (F == null ? void 0 : F.fontFamily) || "Microsoft Yahei").attr("letter-spacing", (F == null ? void 0 : F.letterSpacing) || "0px").attr("font-weight", (F == null ? void 0 : F.fontWeight) || "normal").attr("font-style", (F == null ? void 0 : F.fontStyle) || "normal").text(ae); } } }); } onClick(o) { this.props.onClick && typeof this.props.onClick == "function" && this.props.onClick(o); } async componentDidMount() { await ie.select(this.d3Node).selectAll("*").remove(), this.init(); } componentWillUnmount() { ie.select(this.d3Node).selectAll("*").remove(); } async componentDidUpdate() { await ie.select(this.d3Node).selectAll("*").remove(), this.init(); } render() { const { data: o } = this.getSort(), u = Ke(this.props, X(o)), n = () => { if (this.props.promptBoxTabs && typeof this.props.promptBoxTabs != "boolean") { const { margin: s, bgColor: m } = this.props.promptBoxTabs; return { position: "absolute", display: "none", whiteSpace: "nowrap", zIndex: 9999999, willChange: "transform", boxShadow: "rgb(0 0 0 / 20 %) 1px 2px 10px", padding: `${s == null ? void 0 : s.top}px ${s == null ? void 0 : s.right}px ${s == null ? void 0 : s.bottom}px ${s == null ? void 0 : s.left}px`, top: "0px", left: "0px", transition: "all linear 10ms", background: m, pointerEvents: "none", alignItems: "center", justifyContent: "center" }; } return {}; }; return /* @__PURE__ */ w.jsxs( "div", { style: { height: this.props.base.height + "px", width: this.props.base.width + "px", position: "relative" }, children: [ o && o.length > 0 && /* @__PURE__ */ w.jsx("svg", { className: "d3-node", ref: (s) => this.d3Node =