@antv/gpt-vis 1.3.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +261 -137
- package/README.zh-CN.md +263 -116
- package/dist/cjs/annotation/components/bottom-n.d.ts +2 -0
- package/dist/cjs/annotation/components/bottom-n.js +57 -0
- package/dist/cjs/annotation/components/centroid.d.ts +2 -0
- package/dist/cjs/annotation/components/centroid.js +75 -0
- package/dist/cjs/annotation/components/connector.d.ts +25 -0
- package/dist/cjs/annotation/components/connector.js +298 -0
- package/dist/cjs/annotation/components/contribution.d.ts +3 -0
- package/dist/cjs/annotation/components/contribution.js +136 -0
- package/dist/cjs/annotation/components/crossing.d.ts +3 -0
- package/dist/cjs/annotation/components/crossing.js +504 -0
- package/dist/cjs/annotation/components/event.d.ts +2 -0
- package/dist/cjs/annotation/components/event.js +62 -0
- package/dist/cjs/annotation/components/first.d.ts +2 -0
- package/dist/cjs/annotation/components/first.js +42 -0
- package/dist/cjs/annotation/components/group.d.ts +3 -0
- package/dist/cjs/annotation/components/group.js +73 -0
- package/dist/cjs/annotation/components/highlight.d.ts +14 -0
- package/dist/cjs/annotation/components/highlight.js +552 -0
- package/dist/cjs/annotation/components/index.d.ts +34 -0
- package/dist/cjs/annotation/components/index.js +128 -0
- package/dist/cjs/annotation/components/last.d.ts +2 -0
- package/dist/cjs/annotation/components/last.js +42 -0
- package/dist/cjs/annotation/components/max-x.d.ts +2 -0
- package/dist/cjs/annotation/components/max-x.js +41 -0
- package/dist/cjs/annotation/components/max-y.d.ts +2 -0
- package/dist/cjs/annotation/components/max-y.js +41 -0
- package/dist/cjs/annotation/components/mean.d.ts +2 -0
- package/dist/cjs/annotation/components/mean.js +50 -0
- package/dist/cjs/annotation/components/median.d.ts +2 -0
- package/dist/cjs/annotation/components/median.js +49 -0
- package/dist/cjs/annotation/components/min-x.d.ts +2 -0
- package/dist/cjs/annotation/components/min-x.js +41 -0
- package/dist/cjs/annotation/components/min-y.d.ts +2 -0
- package/dist/cjs/annotation/components/min-y.js +41 -0
- package/dist/cjs/annotation/components/outlier.d.ts +3 -0
- package/dist/cjs/annotation/components/outlier.js +83 -0
- package/dist/cjs/annotation/components/path.d.ts +20 -0
- package/dist/cjs/annotation/components/path.js +147 -0
- package/dist/cjs/annotation/components/peak.d.ts +2 -0
- package/dist/cjs/annotation/components/peak.js +42 -0
- package/dist/cjs/annotation/components/point.d.ts +26 -0
- package/dist/cjs/annotation/components/point.js +241 -0
- package/dist/cjs/annotation/components/quadrant.d.ts +3 -0
- package/dist/cjs/annotation/components/quadrant.js +97 -0
- package/dist/cjs/annotation/components/quantile.d.ts +2 -0
- package/dist/cjs/annotation/components/quantile.js +49 -0
- package/dist/cjs/annotation/components/range-inside.d.ts +2 -0
- package/dist/cjs/annotation/components/range-inside.js +65 -0
- package/dist/cjs/annotation/components/range-outside.d.ts +2 -0
- package/dist/cjs/annotation/components/range-outside.js +65 -0
- package/dist/cjs/annotation/components/range-x.d.ts +2 -0
- package/dist/cjs/annotation/components/range-x.js +39 -0
- package/dist/cjs/annotation/components/range-y.d.ts +2 -0
- package/dist/cjs/annotation/components/range-y.js +39 -0
- package/dist/cjs/annotation/components/range.d.ts +15 -0
- package/dist/cjs/annotation/components/range.js +87 -0
- package/dist/cjs/annotation/components/target.d.ts +2 -0
- package/dist/cjs/annotation/components/target.js +51 -0
- package/dist/cjs/annotation/components/text.d.ts +15 -0
- package/dist/cjs/annotation/components/text.js +74 -0
- package/dist/cjs/annotation/components/threshold-highlight.d.ts +3 -0
- package/dist/cjs/annotation/components/threshold-highlight.js +223 -0
- package/dist/cjs/annotation/components/threshold-x.d.ts +2 -0
- package/dist/cjs/annotation/components/threshold-x.js +39 -0
- package/dist/cjs/annotation/components/threshold-y.d.ts +2 -0
- package/dist/cjs/annotation/components/threshold-y.js +40 -0
- package/dist/cjs/annotation/components/top-n.d.ts +2 -0
- package/dist/cjs/annotation/components/top-n.js +57 -0
- package/dist/cjs/annotation/components/valley.d.ts +2 -0
- package/dist/cjs/annotation/components/valley.js +42 -0
- package/dist/cjs/annotation/index.d.ts +1 -0
- package/dist/cjs/annotation/index.js +29 -0
- package/dist/cjs/annotation/label.d.ts +38 -0
- package/dist/cjs/annotation/label.js +347 -0
- package/dist/cjs/annotation/layout.d.ts +12 -0
- package/dist/cjs/annotation/layout.js +142 -0
- package/dist/cjs/annotation/merge.d.ts +19 -0
- package/dist/cjs/annotation/merge.js +60 -0
- package/dist/cjs/annotation/registry.d.ts +190 -0
- package/dist/cjs/annotation/registry.js +134 -0
- package/dist/cjs/annotation/runtime/g2.d.ts +90 -0
- package/dist/cjs/annotation/runtime/g2.js +521 -0
- package/dist/cjs/annotation/runtime/g6.d.ts +40 -0
- package/dist/cjs/annotation/runtime/g6.js +310 -0
- package/dist/cjs/annotation/runtime/index.d.ts +11 -0
- package/dist/cjs/annotation/runtime/index.js +41 -0
- package/dist/cjs/annotation/runtime/summary.d.ts +17 -0
- package/dist/cjs/annotation/runtime/summary.js +39 -0
- package/dist/cjs/annotation/runtime/table.d.ts +16 -0
- package/dist/cjs/annotation/runtime/table.js +39 -0
- package/dist/cjs/annotation/utils.d.ts +40 -0
- package/dist/cjs/annotation/utils.js +275 -0
- package/dist/cjs/theme/annotation.d.ts +236 -0
- package/dist/cjs/theme/annotation.js +167 -0
- package/dist/cjs/theme/g2.js +13 -15
- package/dist/cjs/theme/g6.js +2 -2
- package/dist/cjs/theme/summary.js +2 -2
- package/dist/cjs/types/annotation.d.ts +310 -0
- package/dist/cjs/types/annotation.js +17 -0
- package/dist/cjs/types/index.d.ts +1 -0
- package/dist/cjs/util/axis.d.ts +28 -0
- package/dist/cjs/util/axis.js +184 -0
- package/dist/cjs/util/components.d.ts +0 -10
- package/dist/cjs/util/components.js +9 -64
- package/dist/cjs/util/index.d.ts +7 -4
- package/dist/cjs/util/index.js +53 -9
- package/dist/cjs/vis/area/index.d.ts +2 -0
- package/dist/cjs/vis/area/index.js +30 -13
- package/dist/cjs/vis/bar/index.d.ts +2 -0
- package/dist/cjs/vis/bar/index.js +37 -7
- package/dist/cjs/vis/boxplot/index.js +14 -3
- package/dist/cjs/vis/column/index.d.ts +2 -0
- package/dist/cjs/vis/column/index.js +28 -9
- package/dist/cjs/vis/dual-axes/index.js +9 -9
- package/dist/cjs/vis/fishbone-diagram/index.js +2 -2
- package/dist/cjs/vis/flow-diagram/index.js +2 -2
- package/dist/cjs/vis/funnel/index.js +10 -13
- package/dist/cjs/vis/histogram/index.js +2 -2
- package/dist/cjs/vis/indented-tree/index.js +2 -2
- package/dist/cjs/vis/line/index.d.ts +2 -0
- package/dist/cjs/vis/line/index.js +26 -10
- package/dist/cjs/vis/liquid/index.js +2 -2
- package/dist/cjs/vis/mindmap/index.js +2 -2
- package/dist/cjs/vis/network-graph/index.d.ts +2 -0
- package/dist/cjs/vis/network-graph/index.js +24 -3
- package/dist/cjs/vis/organization-chart/index.js +2 -2
- package/dist/cjs/vis/pie/index.d.ts +2 -0
- package/dist/cjs/vis/pie/index.js +21 -10
- package/dist/cjs/vis/radar/index.js +4 -6
- package/dist/cjs/vis/sankey/index.js +14 -1
- package/dist/cjs/vis/scatter/index.d.ts +10 -3
- package/dist/cjs/vis/scatter/index.js +18 -7
- package/dist/cjs/vis/summary/index.d.ts +9 -2
- package/dist/cjs/vis/summary/index.js +25 -8
- package/dist/cjs/vis/table/index.d.ts +2 -0
- package/dist/cjs/vis/table/index.js +48 -30
- package/dist/cjs/vis/venn/index.js +2 -2
- package/dist/cjs/vis/violin/index.js +14 -3
- package/dist/cjs/vis/waterfall/index.js +17 -9
- package/dist/cjs/vis/word-cloud/index.js +4 -6
- package/dist/cjs/vis-wrapper/index.js +2 -1
- package/dist/esm/annotation/components/bottom-n.d.ts +2 -0
- package/dist/esm/annotation/components/bottom-n.js +42 -0
- package/dist/esm/annotation/components/centroid.d.ts +2 -0
- package/dist/esm/annotation/components/centroid.js +73 -0
- package/dist/esm/annotation/components/connector.d.ts +25 -0
- package/dist/esm/annotation/components/connector.js +332 -0
- package/dist/esm/annotation/components/contribution.d.ts +3 -0
- package/dist/esm/annotation/components/contribution.js +174 -0
- package/dist/esm/annotation/components/crossing.d.ts +3 -0
- package/dist/esm/annotation/components/crossing.js +665 -0
- package/dist/esm/annotation/components/event.d.ts +2 -0
- package/dist/esm/annotation/components/event.js +46 -0
- package/dist/esm/annotation/components/first.d.ts +2 -0
- package/dist/esm/annotation/components/first.js +18 -0
- package/dist/esm/annotation/components/group.d.ts +3 -0
- package/dist/esm/annotation/components/group.js +64 -0
- package/dist/esm/annotation/components/highlight.d.ts +14 -0
- package/dist/esm/annotation/components/highlight.js +838 -0
- package/dist/esm/annotation/components/index.d.ts +34 -0
- package/dist/esm/annotation/components/index.js +34 -0
- package/dist/esm/annotation/components/last.d.ts +2 -0
- package/dist/esm/annotation/components/last.js +18 -0
- package/dist/esm/annotation/components/max-x.d.ts +2 -0
- package/dist/esm/annotation/components/max-x.js +17 -0
- package/dist/esm/annotation/components/max-y.d.ts +2 -0
- package/dist/esm/annotation/components/max-y.js +17 -0
- package/dist/esm/annotation/components/mean.d.ts +2 -0
- package/dist/esm/annotation/components/mean.js +40 -0
- package/dist/esm/annotation/components/median.d.ts +2 -0
- package/dist/esm/annotation/components/median.js +32 -0
- package/dist/esm/annotation/components/min-x.d.ts +2 -0
- package/dist/esm/annotation/components/min-x.js +17 -0
- package/dist/esm/annotation/components/min-y.d.ts +2 -0
- package/dist/esm/annotation/components/min-y.js +17 -0
- package/dist/esm/annotation/components/outlier.d.ts +3 -0
- package/dist/esm/annotation/components/outlier.js +98 -0
- package/dist/esm/annotation/components/path.d.ts +20 -0
- package/dist/esm/annotation/components/path.js +165 -0
- package/dist/esm/annotation/components/peak.d.ts +2 -0
- package/dist/esm/annotation/components/peak.js +20 -0
- package/dist/esm/annotation/components/point.d.ts +26 -0
- package/dist/esm/annotation/components/point.js +277 -0
- package/dist/esm/annotation/components/quadrant.d.ts +3 -0
- package/dist/esm/annotation/components/quadrant.js +83 -0
- package/dist/esm/annotation/components/quantile.d.ts +2 -0
- package/dist/esm/annotation/components/quantile.js +32 -0
- package/dist/esm/annotation/components/range-inside.d.ts +2 -0
- package/dist/esm/annotation/components/range-inside.js +55 -0
- package/dist/esm/annotation/components/range-outside.d.ts +2 -0
- package/dist/esm/annotation/components/range-outside.js +55 -0
- package/dist/esm/annotation/components/range-x.d.ts +2 -0
- package/dist/esm/annotation/components/range-x.js +15 -0
- package/dist/esm/annotation/components/range-y.d.ts +2 -0
- package/dist/esm/annotation/components/range-y.js +15 -0
- package/dist/esm/annotation/components/range.d.ts +15 -0
- package/dist/esm/annotation/components/range.js +92 -0
- package/dist/esm/annotation/components/target.d.ts +2 -0
- package/dist/esm/annotation/components/target.js +44 -0
- package/dist/esm/annotation/components/text.d.ts +15 -0
- package/dist/esm/annotation/components/text.js +78 -0
- package/dist/esm/annotation/components/threshold-highlight.d.ts +3 -0
- package/dist/esm/annotation/components/threshold-highlight.js +297 -0
- package/dist/esm/annotation/components/threshold-x.d.ts +2 -0
- package/dist/esm/annotation/components/threshold-x.js +23 -0
- package/dist/esm/annotation/components/threshold-y.d.ts +2 -0
- package/dist/esm/annotation/components/threshold-y.js +24 -0
- package/dist/esm/annotation/components/top-n.d.ts +2 -0
- package/dist/esm/annotation/components/top-n.js +42 -0
- package/dist/esm/annotation/components/valley.d.ts +2 -0
- package/dist/esm/annotation/components/valley.js +20 -0
- package/dist/esm/annotation/index.d.ts +1 -0
- package/dist/esm/annotation/index.js +1 -0
- package/dist/esm/annotation/label.d.ts +38 -0
- package/dist/esm/annotation/label.js +449 -0
- package/dist/esm/annotation/layout.d.ts +12 -0
- package/dist/esm/annotation/layout.js +182 -0
- package/dist/esm/annotation/merge.d.ts +19 -0
- package/dist/esm/annotation/merge.js +67 -0
- package/dist/esm/annotation/registry.d.ts +190 -0
- package/dist/esm/annotation/registry.js +220 -0
- package/dist/esm/annotation/runtime/g2.d.ts +90 -0
- package/dist/esm/annotation/runtime/g2.js +754 -0
- package/dist/esm/annotation/runtime/g6.d.ts +40 -0
- package/dist/esm/annotation/runtime/g6.js +447 -0
- package/dist/esm/annotation/runtime/index.d.ts +11 -0
- package/dist/esm/annotation/runtime/index.js +26 -0
- package/dist/esm/annotation/runtime/summary.d.ts +17 -0
- package/dist/esm/annotation/runtime/summary.js +21 -0
- package/dist/esm/annotation/runtime/table.d.ts +16 -0
- package/dist/esm/annotation/runtime/table.js +21 -0
- package/dist/esm/annotation/utils.d.ts +40 -0
- package/dist/esm/annotation/utils.js +370 -0
- package/dist/esm/theme/annotation.d.ts +236 -0
- package/dist/esm/theme/annotation.js +186 -0
- package/dist/esm/theme/g2.js +2 -10
- package/dist/esm/theme/g6.js +1 -1
- package/dist/esm/theme/summary.js +1 -1
- package/dist/esm/types/annotation.d.ts +310 -0
- package/dist/esm/types/annotation.js +1 -0
- package/dist/esm/types/index.d.ts +1 -0
- package/dist/esm/util/axis.d.ts +28 -0
- package/dist/esm/util/axis.js +222 -0
- package/dist/esm/util/components.d.ts +0 -10
- package/dist/esm/util/components.js +24 -69
- package/dist/esm/util/index.d.ts +7 -4
- package/dist/esm/util/index.js +7 -4
- package/dist/esm/vis/area/index.d.ts +2 -0
- package/dist/esm/vis/area/index.js +32 -9
- package/dist/esm/vis/bar/index.d.ts +2 -0
- package/dist/esm/vis/bar/index.js +37 -6
- package/dist/esm/vis/boxplot/index.js +10 -2
- package/dist/esm/vis/column/index.d.ts +2 -0
- package/dist/esm/vis/column/index.js +33 -12
- package/dist/esm/vis/dual-axes/index.js +10 -10
- package/dist/esm/vis/fishbone-diagram/index.js +1 -1
- package/dist/esm/vis/flow-diagram/index.js +1 -1
- package/dist/esm/vis/funnel/index.js +2 -7
- package/dist/esm/vis/histogram/index.js +4 -3
- package/dist/esm/vis/indented-tree/index.js +1 -1
- package/dist/esm/vis/line/index.d.ts +2 -0
- package/dist/esm/vis/line/index.js +31 -9
- package/dist/esm/vis/liquid/index.js +1 -1
- package/dist/esm/vis/mindmap/index.js +1 -1
- package/dist/esm/vis/network-graph/index.d.ts +2 -0
- package/dist/esm/vis/network-graph/index.js +29 -2
- package/dist/esm/vis/organization-chart/index.js +1 -1
- package/dist/esm/vis/pie/index.d.ts +2 -0
- package/dist/esm/vis/pie/index.js +25 -8
- package/dist/esm/vis/radar/index.js +1 -3
- package/dist/esm/vis/sankey/index.js +15 -1
- package/dist/esm/vis/scatter/index.d.ts +10 -3
- package/dist/esm/vis/scatter/index.js +28 -5
- package/dist/esm/vis/summary/index.d.ts +9 -2
- package/dist/esm/vis/summary/index.js +31 -13
- package/dist/esm/vis/table/index.d.ts +2 -0
- package/dist/esm/vis/table/index.js +50 -33
- package/dist/esm/vis/venn/index.js +1 -1
- package/dist/esm/vis/violin/index.js +10 -2
- package/dist/esm/vis/waterfall/index.js +16 -13
- package/dist/esm/vis/word-cloud/index.js +1 -3
- package/dist/esm/vis-wrapper/index.js +2 -1
- package/dist/umd/index.min.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,838 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
5
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
6
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
10
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
12
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
13
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
14
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
15
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
16
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
17
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
18
|
+
import { bindLabels, bindPieLabels, getLabelColorWidth, groupLabels, labelConnectors, rankedLabels } from "../label";
|
|
19
|
+
import { mergeResults } from "../merge";
|
|
20
|
+
import { getDimOpacity } from "../utils";
|
|
21
|
+
import { point } from "./point";
|
|
22
|
+
|
|
23
|
+
/** Highlight batches share selection and dimming so overlapping targets form a union. */
|
|
24
|
+
export var highlight = {
|
|
25
|
+
create: createHighlight,
|
|
26
|
+
g2: function g2(annotations, context) {
|
|
27
|
+
return [drawG2].concat(_toConsumableArray(createSeriesMarkers(annotations, context)));
|
|
28
|
+
},
|
|
29
|
+
g6: function g6() {
|
|
30
|
+
return drawG6;
|
|
31
|
+
},
|
|
32
|
+
table: function table() {
|
|
33
|
+
return drawTable;
|
|
34
|
+
},
|
|
35
|
+
summary: function summary() {
|
|
36
|
+
return drawSummary;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Computed targets retain observation identity; user selectors still match by field values.
|
|
41
|
+
var computedHighlights = new WeakSet();
|
|
42
|
+
/** Create configurations for later merging and drawing; empty selections are a no-op. */
|
|
43
|
+
function createHighlight(options) {
|
|
44
|
+
var computed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
45
|
+
if (Array.isArray(options.data) && !options.data.length) return [];
|
|
46
|
+
var annotation = {
|
|
47
|
+
type: 'highlight',
|
|
48
|
+
data: options.data,
|
|
49
|
+
label: options.label,
|
|
50
|
+
style: options.style
|
|
51
|
+
};
|
|
52
|
+
if (computed) computedHighlights.add(annotation);
|
|
53
|
+
return [annotation];
|
|
54
|
+
}
|
|
55
|
+
var drawG2 = function drawG2(annotations, context) {
|
|
56
|
+
var selections = selectHighlights(context.mapping.data, annotations);
|
|
57
|
+
var labelSelections = selections;
|
|
58
|
+
var results = [];
|
|
59
|
+
switch (context.chartType) {
|
|
60
|
+
case 'line':
|
|
61
|
+
case 'area':
|
|
62
|
+
if (selections.length) applySeriesHighlights(selections, context);
|
|
63
|
+
break;
|
|
64
|
+
case 'bar':
|
|
65
|
+
case 'column':
|
|
66
|
+
if (selections.length) applyNativeHighlights(context.sourceMarks, selections, context, 'interval');
|
|
67
|
+
break;
|
|
68
|
+
case 'scatter':
|
|
69
|
+
if (selections.length) applyNativeHighlights(context.sourceMarks, selections, context, 'point');
|
|
70
|
+
break;
|
|
71
|
+
case 'pie':
|
|
72
|
+
if (selections.length) applyNativeHighlights(context.sourceMarks, selections, context, 'interval');
|
|
73
|
+
results.push(bindPieLabels(selections, context));
|
|
74
|
+
labelSelections = selections.filter(function (_ref) {
|
|
75
|
+
var annotation = _ref.annotation;
|
|
76
|
+
return !rankedLabels.has(annotation);
|
|
77
|
+
});
|
|
78
|
+
break;
|
|
79
|
+
default:
|
|
80
|
+
throw new Error("Unsupported ".concat(context.chartType, " highlight."));
|
|
81
|
+
}
|
|
82
|
+
results.push({
|
|
83
|
+
marks: createHighlightLabels(labelSelections, context)
|
|
84
|
+
});
|
|
85
|
+
return mergeResults(results);
|
|
86
|
+
};
|
|
87
|
+
var drawG6 = function drawG6(annotations, context) {
|
|
88
|
+
// The G6 runtime applies native appearance before render; place explanations after layout.
|
|
89
|
+
var _iterator = _createForOfIteratorHelper(selectHighlights(context.data, annotations)),
|
|
90
|
+
_step;
|
|
91
|
+
try {
|
|
92
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
93
|
+
var _step$value = _step.value,
|
|
94
|
+
annotation = _step$value.annotation,
|
|
95
|
+
rows = _step$value.rows;
|
|
96
|
+
if (!annotation.label) continue;
|
|
97
|
+
var positions = rows.flatMap(function (row) {
|
|
98
|
+
var point = context.position(row);
|
|
99
|
+
return point ? [point] : [];
|
|
100
|
+
});
|
|
101
|
+
var anchor = positions.length ? [positions.reduce(function (sum, point) {
|
|
102
|
+
return sum + point[0];
|
|
103
|
+
}, 0) / positions.length, positions.reduce(function (sum, point) {
|
|
104
|
+
return sum + point[1];
|
|
105
|
+
}, 0) / positions.length] : undefined;
|
|
106
|
+
if (anchor) context.label(annotation, anchor);
|
|
107
|
+
}
|
|
108
|
+
} catch (err) {
|
|
109
|
+
_iterator.e(err);
|
|
110
|
+
} finally {
|
|
111
|
+
_iterator.f();
|
|
112
|
+
}
|
|
113
|
+
return {};
|
|
114
|
+
};
|
|
115
|
+
var drawTable = function drawTable(annotations, context) {
|
|
116
|
+
return {
|
|
117
|
+
cleanup: bindTableHighlights(context.container, context.content, context.data, annotations, context.defaults)
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
var drawSummary = function drawSummary(annotations, context) {
|
|
121
|
+
return {
|
|
122
|
+
cleanup: bindSummaryHighlights(context.container, context.content, annotations, context.defaults)
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
/** Preserve native paint and borders unless an annotation explicitly overrides them. */
|
|
126
|
+
function applyNativeHighlights(marks, selections, context, outline) {
|
|
127
|
+
var defaults = context.defaults;
|
|
128
|
+
var annotations = selections.map(function (_ref2) {
|
|
129
|
+
var annotation = _ref2.annotation;
|
|
130
|
+
return annotation;
|
|
131
|
+
});
|
|
132
|
+
var pie = context.chartType === 'pie';
|
|
133
|
+
var dim = getDimOpacity(annotations, pie ? defaults.highlight.pieDimOpacity : annotations.some(function (annotation) {
|
|
134
|
+
return labelConnectors.has(annotation);
|
|
135
|
+
}) ? defaults.highlight.contributionDimOpacity : defaults.highlight.dimOpacity);
|
|
136
|
+
var _iterator2 = _createForOfIteratorHelper(marks),
|
|
137
|
+
_step2;
|
|
138
|
+
try {
|
|
139
|
+
var _loop = function _loop() {
|
|
140
|
+
var mark = _step2.value;
|
|
141
|
+
var style = _objectSpread({}, mark.style);
|
|
142
|
+
var original = function original(key, fallback, args) {
|
|
143
|
+
var _style$key;
|
|
144
|
+
return typeof style[key] === 'function' ? style[key].apply(style, _toConsumableArray(args)) : (_style$key = style[key]) !== null && _style$key !== void 0 ? _style$key : fallback;
|
|
145
|
+
};
|
|
146
|
+
var selectedAnnotations = function selectedAnnotations(datum) {
|
|
147
|
+
var rows = Array.isArray(datum) ? datum : [datum];
|
|
148
|
+
return selections.filter(function (selection) {
|
|
149
|
+
return rows.every(selection.matches);
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
mark.style = _objectSpread(_objectSpread({}, style), {}, {
|
|
153
|
+
opacity: function opacity() {
|
|
154
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
155
|
+
args[_key] = arguments[_key];
|
|
156
|
+
}
|
|
157
|
+
var rows = Array.isArray(args[0]) ? args[0] : [args[0]];
|
|
158
|
+
return Number(original('opacity', 1, args)) * (rows.some(function (row) {
|
|
159
|
+
return selections.some(function (selection) {
|
|
160
|
+
return selection.matches(row);
|
|
161
|
+
});
|
|
162
|
+
}) ? 1 : dim);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
// Closed areas retain their own fill and border; the companion line owns the contour.
|
|
166
|
+
if (outline !== 'none') {
|
|
167
|
+
var _iterator3 = _createForOfIteratorHelper(['stroke', 'lineWidth']),
|
|
168
|
+
_step3;
|
|
169
|
+
try {
|
|
170
|
+
var _loop2 = function _loop2() {
|
|
171
|
+
var key = _step3.value;
|
|
172
|
+
if (!annotations.some(function (annotation) {
|
|
173
|
+
var _annotation$style;
|
|
174
|
+
return ((_annotation$style = annotation.style) === null || _annotation$style === void 0 ? void 0 : _annotation$style[key]) !== undefined;
|
|
175
|
+
})) return 1; // continue
|
|
176
|
+
mark.style[key] = function () {
|
|
177
|
+
var _selectedAnnotations$;
|
|
178
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
179
|
+
args[_key2] = arguments[_key2];
|
|
180
|
+
}
|
|
181
|
+
return (_selectedAnnotations$ = selectedAnnotations(args[0]).map(function (_ref3) {
|
|
182
|
+
var _annotation$style2;
|
|
183
|
+
var annotation = _ref3.annotation;
|
|
184
|
+
return (_annotation$style2 = annotation.style) === null || _annotation$style2 === void 0 ? void 0 : _annotation$style2[key];
|
|
185
|
+
}).filter(function (value) {
|
|
186
|
+
return value !== undefined;
|
|
187
|
+
}).at(-1)) !== null && _selectedAnnotations$ !== void 0 ? _selectedAnnotations$ : original(key, key === 'lineWidth' ? outline === 'series' ? defaults.lineWidth.path : outline === 'point' ? defaults.lineWidth.point : 0 : outline === 'interval' ? 'none' : context.color(Array.isArray(args[0]) ? args[0][0] : args[0]), args);
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
191
|
+
if (_loop2()) continue;
|
|
192
|
+
}
|
|
193
|
+
} catch (err) {
|
|
194
|
+
_iterator3.e(err);
|
|
195
|
+
} finally {
|
|
196
|
+
_iterator3.f();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
var _iterator4 = _createForOfIteratorHelper(['fill', 'fillOpacity']),
|
|
200
|
+
_step4;
|
|
201
|
+
try {
|
|
202
|
+
var _loop3 = function _loop3() {
|
|
203
|
+
var key = _step4.value;
|
|
204
|
+
if (!annotations.some(function (annotation) {
|
|
205
|
+
var _annotation$style3;
|
|
206
|
+
return ((_annotation$style3 = annotation.style) === null || _annotation$style3 === void 0 ? void 0 : _annotation$style3[key]) !== undefined;
|
|
207
|
+
})) return 1; // continue
|
|
208
|
+
mark.style[key] = function () {
|
|
209
|
+
var _selectedAnnotations$2;
|
|
210
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
211
|
+
args[_key3] = arguments[_key3];
|
|
212
|
+
}
|
|
213
|
+
return (_selectedAnnotations$2 = selectedAnnotations(args[0]).map(function (_ref4) {
|
|
214
|
+
var _annotation$style4;
|
|
215
|
+
var annotation = _ref4.annotation;
|
|
216
|
+
return (_annotation$style4 = annotation.style) === null || _annotation$style4 === void 0 ? void 0 : _annotation$style4[key];
|
|
217
|
+
}).filter(function (v) {
|
|
218
|
+
return v !== undefined;
|
|
219
|
+
}).at(-1)) !== null && _selectedAnnotations$2 !== void 0 ? _selectedAnnotations$2 : original(key, key === 'fill' ? context.color(Array.isArray(args[0]) ? args[0][0] : args[0]) : 1, args);
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
223
|
+
if (_loop3()) continue;
|
|
224
|
+
}
|
|
225
|
+
} catch (err) {
|
|
226
|
+
_iterator4.e(err);
|
|
227
|
+
} finally {
|
|
228
|
+
_iterator4.f();
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
232
|
+
_loop();
|
|
233
|
+
}
|
|
234
|
+
} catch (err) {
|
|
235
|
+
_iterator2.e(err);
|
|
236
|
+
} finally {
|
|
237
|
+
_iterator2.f();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** Native series paint stays on the source geometry; observation markers expand separately. */
|
|
242
|
+
function applySeriesHighlights(selections, context) {
|
|
243
|
+
var _iterator5 = _createForOfIteratorHelper(context.sourceMarks),
|
|
244
|
+
_step5;
|
|
245
|
+
try {
|
|
246
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
247
|
+
var mark = _step5.value;
|
|
248
|
+
var outline = mark.type === 'area' ? 'none' : mark.type === 'line' ? 'series' : 'point';
|
|
249
|
+
applyNativeHighlights([mark], selections, context, outline);
|
|
250
|
+
}
|
|
251
|
+
} catch (err) {
|
|
252
|
+
_iterator5.e(err);
|
|
253
|
+
} finally {
|
|
254
|
+
_iterator5.f();
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/** Resolve the union before creating markers; a fully selected series needs no extra points. */
|
|
259
|
+
function createSeriesMarkers(annotations, _ref5) {
|
|
260
|
+
var chartType = _ref5.chartType,
|
|
261
|
+
mapping = _ref5.mapping,
|
|
262
|
+
sourceMarks = _ref5.sourceMarks;
|
|
263
|
+
switch (chartType) {
|
|
264
|
+
case 'line':
|
|
265
|
+
case 'area':
|
|
266
|
+
{
|
|
267
|
+
var _mapping$series, _series$encode;
|
|
268
|
+
var selections = selectHighlights(mapping.data, annotations);
|
|
269
|
+
var selected = new Set(selections.flatMap(function (_ref6) {
|
|
270
|
+
var rows = _ref6.rows;
|
|
271
|
+
return rows;
|
|
272
|
+
}));
|
|
273
|
+
var series = sourceMarks === null || sourceMarks === void 0 ? void 0 : sourceMarks.find(function (mark) {
|
|
274
|
+
return mark.type === 'line' || mark.type === 'area';
|
|
275
|
+
});
|
|
276
|
+
var field = (_mapping$series = mapping.series) !== null && _mapping$series !== void 0 ? _mapping$series : typeof (series === null || series === void 0 || (_series$encode = series.encode) === null || _series$encode === void 0 ? void 0 : _series$encode.color) === 'string' ? series.encode.color : undefined;
|
|
277
|
+
return _toConsumableArray(selected).flatMap(function (row) {
|
|
278
|
+
var seriesRows = mapping.data.filter(function (datum) {
|
|
279
|
+
return !field || datum[field] === row[field];
|
|
280
|
+
});
|
|
281
|
+
if (seriesRows.every(function (datum) {
|
|
282
|
+
return selected.has(datum);
|
|
283
|
+
})) return [];
|
|
284
|
+
var style = selections.findLast(function (selection) {
|
|
285
|
+
return selection.matches(row);
|
|
286
|
+
}).annotation.style;
|
|
287
|
+
return point.create({
|
|
288
|
+
data: row,
|
|
289
|
+
style: {
|
|
290
|
+
fill: style === null || style === void 0 ? void 0 : style.fill,
|
|
291
|
+
stroke: style === null || style === void 0 ? void 0 : style.stroke,
|
|
292
|
+
lineWidth: style === null || style === void 0 ? void 0 : style.lineWidth
|
|
293
|
+
}
|
|
294
|
+
}, {
|
|
295
|
+
useSourceGeometry: true,
|
|
296
|
+
fillOpacity: style === null || style === void 0 ? void 0 : style.fillOpacity
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
default:
|
|
301
|
+
return [];
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
function createHighlightLabels(selections, context) {
|
|
305
|
+
var defaults = context.defaults;
|
|
306
|
+
var connectorIndex = 0;
|
|
307
|
+
var connectorCount = selections.filter(function (_ref7) {
|
|
308
|
+
var annotation = _ref7.annotation;
|
|
309
|
+
return annotation.label && labelConnectors.has(annotation);
|
|
310
|
+
}).length;
|
|
311
|
+
// Invisible anchors share the primitive label layout without adding native data labels.
|
|
312
|
+
return selections.filter(function (_ref8) {
|
|
313
|
+
var annotation = _ref8.annotation;
|
|
314
|
+
return annotation.label;
|
|
315
|
+
}).map(function (_ref9) {
|
|
316
|
+
var _annotation$style$str, _annotation$style7, _annotation$style$str2, _annotation$style8, _annotation$style$str3, _annotation$style9;
|
|
317
|
+
var annotation = _ref9.annotation,
|
|
318
|
+
rows = _ref9.rows;
|
|
319
|
+
var row = rows[0];
|
|
320
|
+
var note = groupLabels.has(annotation);
|
|
321
|
+
var pie = context.chartType === 'pie';
|
|
322
|
+
var connect = labelConnectors.get(annotation);
|
|
323
|
+
var index = connect ? connectorIndex++ : 0;
|
|
324
|
+
var anchors = [];
|
|
325
|
+
var bracket;
|
|
326
|
+
var colors = function colors() {
|
|
327
|
+
return _toConsumableArray(new Set(rows.filter(function (row) {
|
|
328
|
+
return context.isVisible(row);
|
|
329
|
+
}).map(function (row) {
|
|
330
|
+
var _ref10, _annotation$style5, _annotation$style6;
|
|
331
|
+
return (_ref10 = context.chartType === 'line' ? (_annotation$style5 = annotation.style) === null || _annotation$style5 === void 0 ? void 0 : _annotation$style5.stroke : (_annotation$style6 = annotation.style) === null || _annotation$style6 === void 0 ? void 0 : _annotation$style6.fill) !== null && _ref10 !== void 0 ? _ref10 : context.color(row);
|
|
332
|
+
})));
|
|
333
|
+
};
|
|
334
|
+
var _defaults$labels$high = _slicedToArray(defaults.labels.highlight.padding, 2),
|
|
335
|
+
py = _defaults$labels$high[0],
|
|
336
|
+
px = _defaults$labels$high[1];
|
|
337
|
+
var textStyle = context.getTextStyle(annotation);
|
|
338
|
+
return context.createMark(_objectSpread(_objectSpread({}, annotation), {}, {
|
|
339
|
+
data: row
|
|
340
|
+
}), {
|
|
341
|
+
nativeType: 'point',
|
|
342
|
+
style: {
|
|
343
|
+
fill: 'none',
|
|
344
|
+
stroke: 'none'
|
|
345
|
+
},
|
|
346
|
+
label: _objectSpread(_objectSpread(_objectSpread({
|
|
347
|
+
connectorStroke: (_annotation$style$str = (_annotation$style7 = annotation.style) === null || _annotation$style7 === void 0 ? void 0 : _annotation$style7.stroke) !== null && _annotation$style$str !== void 0 ? _annotation$style$str : defaults.stroke
|
|
348
|
+
}, connect ? {
|
|
349
|
+
annotationBracket: function annotationBracket() {
|
|
350
|
+
return bracket;
|
|
351
|
+
},
|
|
352
|
+
connectorStroke: (_annotation$style$str2 = (_annotation$style8 = annotation.style) === null || _annotation$style8 === void 0 ? void 0 : _annotation$style8.stroke) !== null && _annotation$style$str2 !== void 0 ? _annotation$style$str2 : defaults.labels.highlight.fill,
|
|
353
|
+
connectorLineWidth: 1.5
|
|
354
|
+
} : {}), pie && !connect ? {
|
|
355
|
+
annotationRadial: true,
|
|
356
|
+
annotationAnchors: function annotationAnchors() {
|
|
357
|
+
return anchors;
|
|
358
|
+
},
|
|
359
|
+
connectorStroke: (_annotation$style$str3 = (_annotation$style9 = annotation.style) === null || _annotation$style9 === void 0 ? void 0 : _annotation$style9.stroke) !== null && _annotation$style$str3 !== void 0 ? _annotation$style$str3 : defaults.labels.highlight.fill,
|
|
360
|
+
connectorLineWidth: 1.5
|
|
361
|
+
} : {}), note ? {
|
|
362
|
+
annotationNote: true,
|
|
363
|
+
annotationColors: colors,
|
|
364
|
+
connector: false,
|
|
365
|
+
position: 'inside',
|
|
366
|
+
textAlign: 'right',
|
|
367
|
+
textBaseline: 'top',
|
|
368
|
+
dx: -px,
|
|
369
|
+
dy: py,
|
|
370
|
+
backgroundPadding: function backgroundPadding() {
|
|
371
|
+
return [py, px, py, px + getLabelColorWidth(colors())];
|
|
372
|
+
},
|
|
373
|
+
wordWrapWidth: function wordWrapWidth() {
|
|
374
|
+
var _annotation$style$lab, _annotation$style10;
|
|
375
|
+
return Math.max((_annotation$style$lab = (_annotation$style10 = annotation.style) === null || _annotation$style10 === void 0 ? void 0 : _annotation$style10.labelFontSize) !== null && _annotation$style$lab !== void 0 ? _annotation$style$lab : defaults.labelFontSize, textStyle.wordWrapWidth() - getLabelColorWidth(colors()));
|
|
376
|
+
}
|
|
377
|
+
} : {}),
|
|
378
|
+
// Nonzero invisible geometry keeps AntV's transform origin well-defined.
|
|
379
|
+
draw: function draw(scene) {
|
|
380
|
+
return scene.createElement('circle', {
|
|
381
|
+
style: {
|
|
382
|
+
r: 1,
|
|
383
|
+
fill: 'none',
|
|
384
|
+
stroke: 'none'
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
},
|
|
388
|
+
decorate: function decorate(element, _ref11) {
|
|
389
|
+
var _ref12 = _slicedToArray(_ref11, 1),
|
|
390
|
+
anchor = _ref12[0];
|
|
391
|
+
element.attr({
|
|
392
|
+
cx: anchor[0],
|
|
393
|
+
cy: anchor[1]
|
|
394
|
+
});
|
|
395
|
+
element.setAttribute('annotationIgnoreObstacle', true);
|
|
396
|
+
element.setAttribute('annotationSelection', annotation);
|
|
397
|
+
},
|
|
398
|
+
geometry: function geometry() {
|
|
399
|
+
return function (_index, _scale, _value, coordinate) {
|
|
400
|
+
var points = rows.flatMap(function (row) {
|
|
401
|
+
var position = context.position(row, coordinate, true);
|
|
402
|
+
// Connect within each selected sector, away from both the hole and its edges.
|
|
403
|
+
var point = position && coordinate.map(pie ? [0.18, position[1]] : position);
|
|
404
|
+
return point !== null && point !== void 0 && point.every(Number.isFinite) ? [point] : [];
|
|
405
|
+
});
|
|
406
|
+
anchors = points;
|
|
407
|
+
if (connect) {
|
|
408
|
+
var geometry = rows.flatMap(function (row) {
|
|
409
|
+
var source = context.getGeometry(row);
|
|
410
|
+
return source ? [source] : [];
|
|
411
|
+
});
|
|
412
|
+
bracket = connect(points, geometry, coordinate, index, connectorCount);
|
|
413
|
+
}
|
|
414
|
+
if (!points.length) return [[], []];
|
|
415
|
+
if (bracket) return [[0], [[bracket.anchor]], [[0]]];
|
|
416
|
+
if (pie) return [[0], [[coordinate.getCenter()]], [[0]]];
|
|
417
|
+
if (note) {
|
|
418
|
+
var _coordinate$getSize = coordinate.getSize(),
|
|
419
|
+
_coordinate$getSize2 = _slicedToArray(_coordinate$getSize, 1),
|
|
420
|
+
width = _coordinate$getSize2[0];
|
|
421
|
+
return [[0], [[[width - defaults.labels.highlight.gap, defaults.labels.highlight.gap]]], [[0]]];
|
|
422
|
+
}
|
|
423
|
+
var anchor = [(Math.min.apply(Math, _toConsumableArray(points.map(function (_ref13) {
|
|
424
|
+
var _ref14 = _slicedToArray(_ref13, 1),
|
|
425
|
+
x = _ref14[0];
|
|
426
|
+
return x;
|
|
427
|
+
}))) + Math.max.apply(Math, _toConsumableArray(points.map(function (_ref15) {
|
|
428
|
+
var _ref16 = _slicedToArray(_ref15, 1),
|
|
429
|
+
x = _ref16[0];
|
|
430
|
+
return x;
|
|
431
|
+
})))) / 2, (Math.min.apply(Math, _toConsumableArray(points.map(function (_ref17) {
|
|
432
|
+
var _ref18 = _slicedToArray(_ref17, 2),
|
|
433
|
+
y = _ref18[1];
|
|
434
|
+
return y;
|
|
435
|
+
}))) + Math.max.apply(Math, _toConsumableArray(points.map(function (_ref19) {
|
|
436
|
+
var _ref20 = _slicedToArray(_ref19, 2),
|
|
437
|
+
y = _ref20[1];
|
|
438
|
+
return y;
|
|
439
|
+
})))) / 2];
|
|
440
|
+
return [[0], [[anchor]], [[0]]];
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/** Selection uses original fields and intentionally allows a selector to match a whole series. */
|
|
448
|
+
function selectHighlights(data, annotations) {
|
|
449
|
+
var originals = new Set(data);
|
|
450
|
+
return annotations.map(function (annotation) {
|
|
451
|
+
var targets = Array.isArray(annotation.data) ? annotation.data : [annotation.data];
|
|
452
|
+
if (!targets.length) throw new Error('Invalid annotation: highlight needs target data.');
|
|
453
|
+
var selectors = [];
|
|
454
|
+
var rows = new Set();
|
|
455
|
+
var _iterator6 = _createForOfIteratorHelper(targets),
|
|
456
|
+
_step6;
|
|
457
|
+
try {
|
|
458
|
+
var _loop4 = function _loop4() {
|
|
459
|
+
var target = _step6.value;
|
|
460
|
+
if (!target || _typeof(target) !== 'object' || Array.isArray(target) || !Object.keys(target).length) throw new Error('Invalid annotation: highlight needs a nonempty original-field selector.');
|
|
461
|
+
var entries = Object.entries(target);
|
|
462
|
+
if (entries.some(function (_ref21) {
|
|
463
|
+
var _ref22 = _slicedToArray(_ref21, 1),
|
|
464
|
+
key = _ref22[0];
|
|
465
|
+
return !data.some(function (row) {
|
|
466
|
+
return Object.hasOwn(row, key);
|
|
467
|
+
});
|
|
468
|
+
})) throw new Error('Invalid annotation: highlight contains an unknown field.');
|
|
469
|
+
// Computed selections retain observation identity, including identical input rows.
|
|
470
|
+
var exact = computedHighlights.has(annotation);
|
|
471
|
+
var matchesRow = function matchesRow(row) {
|
|
472
|
+
return exact && originals.has(row) ? row === target : entries.every(function (_ref23) {
|
|
473
|
+
var _ref24 = _slicedToArray(_ref23, 2),
|
|
474
|
+
key = _ref24[0],
|
|
475
|
+
value = _ref24[1];
|
|
476
|
+
return row[key] === value;
|
|
477
|
+
});
|
|
478
|
+
};
|
|
479
|
+
selectors.push(matchesRow);
|
|
480
|
+
var matches = data.filter(matchesRow);
|
|
481
|
+
if (!matches.length) throw new Error('Invalid annotation: highlight matches no data.');
|
|
482
|
+
matches.forEach(function (row) {
|
|
483
|
+
return rows.add(row);
|
|
484
|
+
});
|
|
485
|
+
};
|
|
486
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
487
|
+
_loop4();
|
|
488
|
+
}
|
|
489
|
+
} catch (err) {
|
|
490
|
+
_iterator6.e(err);
|
|
491
|
+
} finally {
|
|
492
|
+
_iterator6.f();
|
|
493
|
+
}
|
|
494
|
+
return {
|
|
495
|
+
annotation: annotation,
|
|
496
|
+
rows: _toConsumableArray(rows),
|
|
497
|
+
matches: function matches(row) {
|
|
498
|
+
return selectors.some(function (matches) {
|
|
499
|
+
return matches(row);
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/** Each data target selects rows, a column or their intersection; targets select their union. */
|
|
507
|
+
function bindTableHighlights(container, content, data, annotations, defaults) {
|
|
508
|
+
var _data$;
|
|
509
|
+
if (!(annotations !== null && annotations !== void 0 && annotations.length)) return function () {};
|
|
510
|
+
var dim = getDimOpacity(annotations, defaults.highlight.dimOpacity);
|
|
511
|
+
var fields = Object.keys((_data$ = data[0]) !== null && _data$ !== void 0 ? _data$ : {});
|
|
512
|
+
var rows = _toConsumableArray(content.querySelectorAll('tbody tr'));
|
|
513
|
+
var headers = _toConsumableArray(content.querySelectorAll('th'));
|
|
514
|
+
var selections = annotations.map(function (annotation) {
|
|
515
|
+
var targets = Array.isArray(annotation.data) ? annotation.data : [annotation.data];
|
|
516
|
+
if (!targets.length) throw new Error('Invalid annotation: table highlight needs target data.');
|
|
517
|
+
var selected = new Set();
|
|
518
|
+
var _iterator7 = _createForOfIteratorHelper(targets),
|
|
519
|
+
_step7;
|
|
520
|
+
try {
|
|
521
|
+
var _loop5 = function _loop5() {
|
|
522
|
+
var target = _step7.value;
|
|
523
|
+
if (!target || _typeof(target) !== 'object' || Array.isArray(target)) throw new Error('Invalid annotation: table target must contain row or column.');
|
|
524
|
+
var selector = target.row,
|
|
525
|
+
field = target.column;
|
|
526
|
+
if (Object.keys(target).some(function (key) {
|
|
527
|
+
return key !== 'row' && key !== 'column';
|
|
528
|
+
})) throw new Error('Invalid annotation: table target only accepts row and column.');
|
|
529
|
+
if (selector === undefined && field === undefined) throw new Error('Invalid annotation: table target must contain row or column.');
|
|
530
|
+
var column = field === undefined ? undefined : fields.indexOf(field);
|
|
531
|
+
if (column === -1) throw new Error("Invalid annotation: unknown table column ".concat(field, "."));
|
|
532
|
+
var indices;
|
|
533
|
+
if (selector === undefined) {
|
|
534
|
+
indices = data.map(function (_, index) {
|
|
535
|
+
return index;
|
|
536
|
+
});
|
|
537
|
+
selected.add(headers[column]);
|
|
538
|
+
} else {
|
|
539
|
+
if (!selector || _typeof(selector) !== 'object' || Array.isArray(selector)) throw new Error('Invalid annotation: table row must be an original-field selector.');
|
|
540
|
+
var entries = Object.entries(selector);
|
|
541
|
+
if (!entries.length) throw new Error('Invalid annotation: table row must not be empty.');
|
|
542
|
+
if (entries.some(function (_ref25) {
|
|
543
|
+
var _ref26 = _slicedToArray(_ref25, 1),
|
|
544
|
+
key = _ref26[0];
|
|
545
|
+
return !fields.includes(key);
|
|
546
|
+
})) throw new Error('Invalid annotation: table row contains an unknown field.');
|
|
547
|
+
var exact = computedHighlights.has(annotation) ? data.indexOf(selector) : -1;
|
|
548
|
+
indices = exact === -1 ? data.flatMap(function (row, index) {
|
|
549
|
+
return entries.every(function (_ref27) {
|
|
550
|
+
var _ref28 = _slicedToArray(_ref27, 2),
|
|
551
|
+
key = _ref28[0],
|
|
552
|
+
value = _ref28[1];
|
|
553
|
+
return row[key] === value;
|
|
554
|
+
}) ? [index] : [];
|
|
555
|
+
}) : [exact];
|
|
556
|
+
if (!indices.length) throw new Error('Invalid annotation: table highlight matches no rows.');
|
|
557
|
+
}
|
|
558
|
+
var _iterator8 = _createForOfIteratorHelper(indices),
|
|
559
|
+
_step8;
|
|
560
|
+
try {
|
|
561
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
562
|
+
var index = _step8.value;
|
|
563
|
+
var _cells = column === undefined ? _toConsumableArray(rows[index].children) : [rows[index].children[column]];
|
|
564
|
+
var _iterator9 = _createForOfIteratorHelper(_cells),
|
|
565
|
+
_step9;
|
|
566
|
+
try {
|
|
567
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
568
|
+
var cell = _step9.value;
|
|
569
|
+
selected.add(cell);
|
|
570
|
+
}
|
|
571
|
+
} catch (err) {
|
|
572
|
+
_iterator9.e(err);
|
|
573
|
+
} finally {
|
|
574
|
+
_iterator9.f();
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
} catch (err) {
|
|
578
|
+
_iterator8.e(err);
|
|
579
|
+
} finally {
|
|
580
|
+
_iterator8.f();
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
584
|
+
_loop5();
|
|
585
|
+
}
|
|
586
|
+
} catch (err) {
|
|
587
|
+
_iterator7.e(err);
|
|
588
|
+
} finally {
|
|
589
|
+
_iterator7.f();
|
|
590
|
+
}
|
|
591
|
+
var cells = _toConsumableArray(selected);
|
|
592
|
+
return {
|
|
593
|
+
annotation: annotation,
|
|
594
|
+
cells: cells
|
|
595
|
+
};
|
|
596
|
+
});
|
|
597
|
+
var selected = new Set(selections.flatMap(function (_ref29) {
|
|
598
|
+
var cells = _ref29.cells;
|
|
599
|
+
return cells;
|
|
600
|
+
}));
|
|
601
|
+
var all = _toConsumableArray(content.querySelectorAll('th, td'));
|
|
602
|
+
var previous = all.map(function (cell) {
|
|
603
|
+
return cell.getAttribute('style');
|
|
604
|
+
});
|
|
605
|
+
var _iterator10 = _createForOfIteratorHelper(all),
|
|
606
|
+
_step10;
|
|
607
|
+
try {
|
|
608
|
+
var _loop6 = function _loop6() {
|
|
609
|
+
var cell = _step10.value;
|
|
610
|
+
if (selected.has(cell)) {
|
|
611
|
+
var _style$fill, _style$fillOpacity, _style$lineWidth, _style$stroke;
|
|
612
|
+
var style = Object.assign.apply(Object, [{}].concat(_toConsumableArray(selections.filter(function (_ref31) {
|
|
613
|
+
var cells = _ref31.cells;
|
|
614
|
+
return cells.includes(cell);
|
|
615
|
+
}).map(function (_ref32) {
|
|
616
|
+
var annotation = _ref32.annotation;
|
|
617
|
+
return annotation.style;
|
|
618
|
+
}))));
|
|
619
|
+
var color = (_style$fill = style.fill) !== null && _style$fill !== void 0 ? _style$fill : defaults.stroke;
|
|
620
|
+
var opacity = (_style$fillOpacity = style.fillOpacity) !== null && _style$fillOpacity !== void 0 ? _style$fillOpacity : defaults.highlight.fillOpacity;
|
|
621
|
+
// Older browsers retain this translucent background when color-mix is unsupported.
|
|
622
|
+
cell.style.background = "rgba(127, 127, 127, ".concat(opacity, ")");
|
|
623
|
+
cell.style.background = "color-mix(in srgb, ".concat(color, " ").concat(opacity * 100, "%, ").concat(defaults.highlight.background, ")");
|
|
624
|
+
cell.style.boxShadow = "inset 0 -".concat((_style$lineWidth = style.lineWidth) !== null && _style$lineWidth !== void 0 ? _style$lineWidth : defaults.highlight.lineWidth, "px ").concat((_style$stroke = style.stroke) !== null && _style$stroke !== void 0 ? _style$stroke : defaults.stroke);
|
|
625
|
+
} else cell.style.opacity = String(dim);
|
|
626
|
+
};
|
|
627
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
628
|
+
_loop6();
|
|
629
|
+
}
|
|
630
|
+
} catch (err) {
|
|
631
|
+
_iterator10.e(err);
|
|
632
|
+
} finally {
|
|
633
|
+
_iterator10.f();
|
|
634
|
+
}
|
|
635
|
+
var cleanupLabels = bindLabels(container, content, selections.map(function (_ref30) {
|
|
636
|
+
var annotation = _ref30.annotation,
|
|
637
|
+
cells = _ref30.cells;
|
|
638
|
+
return {
|
|
639
|
+
annotation: annotation,
|
|
640
|
+
bounds: function bounds() {
|
|
641
|
+
var clip = content.getBoundingClientRect();
|
|
642
|
+
var visible = cells.map(function (cell) {
|
|
643
|
+
return cell.getBoundingClientRect();
|
|
644
|
+
}).filter(function (box) {
|
|
645
|
+
return box.right > clip.left && box.left < clip.right && box.bottom > clip.top && box.top < clip.bottom;
|
|
646
|
+
});
|
|
647
|
+
if (!visible.length) return undefined;
|
|
648
|
+
var groups = labelConnectors.has(annotation) ? _toConsumableArray(new Set(cells.map(function (cell) {
|
|
649
|
+
return cell.parentElement;
|
|
650
|
+
}))).map(function (row) {
|
|
651
|
+
return cells.filter(function (cell) {
|
|
652
|
+
return cell.parentElement === row;
|
|
653
|
+
}).map(function (cell) {
|
|
654
|
+
return cell.getBoundingClientRect();
|
|
655
|
+
}).filter(function (box) {
|
|
656
|
+
return box.right > clip.left && box.left < clip.right && box.bottom > clip.top && box.top < clip.bottom;
|
|
657
|
+
});
|
|
658
|
+
}) : [visible];
|
|
659
|
+
return groups.filter(function (boxes) {
|
|
660
|
+
return boxes.length;
|
|
661
|
+
}).map(function (boxes) {
|
|
662
|
+
var left = Math.max(clip.left, Math.min.apply(Math, _toConsumableArray(boxes.map(function (box) {
|
|
663
|
+
return box.left;
|
|
664
|
+
}))));
|
|
665
|
+
var top = Math.max(clip.top, Math.min.apply(Math, _toConsumableArray(boxes.map(function (box) {
|
|
666
|
+
return box.top;
|
|
667
|
+
}))));
|
|
668
|
+
var right = Math.min(clip.right, Math.max.apply(Math, _toConsumableArray(boxes.map(function (box) {
|
|
669
|
+
return box.right;
|
|
670
|
+
}))));
|
|
671
|
+
var bottom = Math.min(clip.bottom, Math.max.apply(Math, _toConsumableArray(boxes.map(function (box) {
|
|
672
|
+
return box.bottom;
|
|
673
|
+
}))));
|
|
674
|
+
return DOMRect.fromRect({
|
|
675
|
+
x: left,
|
|
676
|
+
y: top,
|
|
677
|
+
width: right - left,
|
|
678
|
+
height: bottom - top
|
|
679
|
+
});
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
};
|
|
683
|
+
}), defaults);
|
|
684
|
+
return function () {
|
|
685
|
+
cleanupLabels();
|
|
686
|
+
all.forEach(function (cell, index) {
|
|
687
|
+
if (previous[index] === null) cell.removeAttribute('style');else cell.setAttribute('style', previous[index]);
|
|
688
|
+
});
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
/** Match visible text across T8 inline phrases without replacing their styles or events. */
|
|
693
|
+
function bindSummaryHighlights(container, content, annotations, defaults) {
|
|
694
|
+
if (!(annotations !== null && annotations !== void 0 && annotations.length)) return function () {};
|
|
695
|
+
var dim = getDimOpacity(annotations, defaults.highlight.dimOpacity);
|
|
696
|
+
var walker = document.createTreeWalker(content, NodeFilter.SHOW_TEXT);
|
|
697
|
+
var nodes = [];
|
|
698
|
+
var text = '';
|
|
699
|
+
var lastBlock = null;
|
|
700
|
+
while (walker.nextNode()) {
|
|
701
|
+
var _node$parentElement$c, _node$parentElement;
|
|
702
|
+
var node = walker.currentNode;
|
|
703
|
+
var block = (_node$parentElement$c = (_node$parentElement = node.parentElement) === null || _node$parentElement === void 0 ? void 0 : _node$parentElement.closest('p, h1, h2, h3, h4, h5, h6, li')) !== null && _node$parentElement$c !== void 0 ? _node$parentElement$c : null;
|
|
704
|
+
if (lastBlock && block !== lastBlock) text += '\n';
|
|
705
|
+
nodes.push({
|
|
706
|
+
node: node,
|
|
707
|
+
start: text.length
|
|
708
|
+
});
|
|
709
|
+
text += node.data;
|
|
710
|
+
lastBlock = block;
|
|
711
|
+
}
|
|
712
|
+
var selections = annotations.map(function (annotation) {
|
|
713
|
+
var data = Array.isArray(annotation.data) ? annotation.data : [annotation.data];
|
|
714
|
+
if (!data.length) throw new Error('Invalid annotation: summary highlight needs text.');
|
|
715
|
+
var intervals = data.map(function (selector) {
|
|
716
|
+
if (!selector.text) throw new Error('Invalid annotation: summary highlight needs a nonempty text string.');
|
|
717
|
+
var start = text.indexOf(selector.text);
|
|
718
|
+
if (start < 0) throw new Error("Invalid annotation: text not found: ".concat(selector.text, "."));
|
|
719
|
+
if (text.indexOf(selector.text, start + 1) !== -1) throw new Error("Invalid annotation: text is ambiguous: ".concat(selector.text, "."));
|
|
720
|
+
return {
|
|
721
|
+
start: start,
|
|
722
|
+
end: start + selector.text.length
|
|
723
|
+
};
|
|
724
|
+
});
|
|
725
|
+
return {
|
|
726
|
+
annotation: annotation,
|
|
727
|
+
intervals: intervals,
|
|
728
|
+
marks: []
|
|
729
|
+
};
|
|
730
|
+
});
|
|
731
|
+
var spans = [];
|
|
732
|
+
for (var _i = 0, _nodes = nodes; _i < _nodes.length; _i++) {
|
|
733
|
+
var _nodes$_i = _nodes[_i],
|
|
734
|
+
_node = _nodes$_i.node,
|
|
735
|
+
start = _nodes$_i.start;
|
|
736
|
+
var end = start + _node.length;
|
|
737
|
+
var boundaries = new Set([start, end]);
|
|
738
|
+
var _iterator11 = _createForOfIteratorHelper(selections),
|
|
739
|
+
_step11;
|
|
740
|
+
try {
|
|
741
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
742
|
+
var intervals = _step11.value.intervals;
|
|
743
|
+
var _iterator12 = _createForOfIteratorHelper(intervals),
|
|
744
|
+
_step12;
|
|
745
|
+
try {
|
|
746
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
747
|
+
var interval = _step12.value;
|
|
748
|
+
if (interval.start > start && interval.start < end) boundaries.add(interval.start);
|
|
749
|
+
if (interval.end > start && interval.end < end) boundaries.add(interval.end);
|
|
750
|
+
}
|
|
751
|
+
} catch (err) {
|
|
752
|
+
_iterator12.e(err);
|
|
753
|
+
} finally {
|
|
754
|
+
_iterator12.f();
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
} catch (err) {
|
|
758
|
+
_iterator11.e(err);
|
|
759
|
+
} finally {
|
|
760
|
+
_iterator11.f();
|
|
761
|
+
}
|
|
762
|
+
var offsets = _toConsumableArray(boundaries).sort(function (a, b) {
|
|
763
|
+
return a - b;
|
|
764
|
+
});
|
|
765
|
+
var fragment = document.createDocumentFragment();
|
|
766
|
+
var _loop7 = function _loop7() {
|
|
767
|
+
var a = offsets[i - 1],
|
|
768
|
+
b = offsets[i];
|
|
769
|
+
var matches = selections.filter(function (_ref33) {
|
|
770
|
+
var intervals = _ref33.intervals;
|
|
771
|
+
return intervals.some(function (r) {
|
|
772
|
+
return r.start <= a && r.end >= b;
|
|
773
|
+
});
|
|
774
|
+
});
|
|
775
|
+
if (!matches.length && dim === 1) {
|
|
776
|
+
fragment.appendChild(document.createTextNode(_node.data.slice(a - start, b - start)));
|
|
777
|
+
return 1; // continue
|
|
778
|
+
}
|
|
779
|
+
var span = document.createElement(matches.length ? 'mark' : 'span');
|
|
780
|
+
span.textContent = _node.data.slice(a - start, b - start);
|
|
781
|
+
if (matches.length) {
|
|
782
|
+
var _style$fill2, _style$fillOpacity2, _style$lineWidth2, _style$stroke2;
|
|
783
|
+
var style = Object.assign.apply(Object, [{}].concat(_toConsumableArray(matches.map(function (_ref34) {
|
|
784
|
+
var annotation = _ref34.annotation;
|
|
785
|
+
return annotation.style;
|
|
786
|
+
}))));
|
|
787
|
+
var color = (_style$fill2 = style.fill) !== null && _style$fill2 !== void 0 ? _style$fill2 : defaults.stroke;
|
|
788
|
+
var opacity = (_style$fillOpacity2 = style.fillOpacity) !== null && _style$fillOpacity2 !== void 0 ? _style$fillOpacity2 : defaults.highlight.fillOpacity;
|
|
789
|
+
span.className = 'annotation-highlight';
|
|
790
|
+
Object.assign(span.style, {
|
|
791
|
+
background: "rgba(127, 127, 127, ".concat(opacity, ")"),
|
|
792
|
+
borderBottom: "".concat((_style$lineWidth2 = style.lineWidth) !== null && _style$lineWidth2 !== void 0 ? _style$lineWidth2 : defaults.highlight.lineWidth, "px solid ").concat((_style$stroke2 = style.stroke) !== null && _style$stroke2 !== void 0 ? _style$stroke2 : defaults.stroke),
|
|
793
|
+
color: 'inherit',
|
|
794
|
+
padding: '2px 0'
|
|
795
|
+
});
|
|
796
|
+
span.style.background = "color-mix(in srgb, ".concat(color, " ").concat(opacity * 100, "%, transparent)");
|
|
797
|
+
var _iterator13 = _createForOfIteratorHelper(matches),
|
|
798
|
+
_step13;
|
|
799
|
+
try {
|
|
800
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
801
|
+
var match = _step13.value;
|
|
802
|
+
match.marks.push(span);
|
|
803
|
+
}
|
|
804
|
+
} catch (err) {
|
|
805
|
+
_iterator13.e(err);
|
|
806
|
+
} finally {
|
|
807
|
+
_iterator13.f();
|
|
808
|
+
}
|
|
809
|
+
} else span.style.opacity = String(dim);
|
|
810
|
+
spans.push(span);
|
|
811
|
+
fragment.appendChild(span);
|
|
812
|
+
};
|
|
813
|
+
for (var i = 1; i < offsets.length; i++) {
|
|
814
|
+
if (_loop7()) continue;
|
|
815
|
+
}
|
|
816
|
+
_node.replaceWith(fragment);
|
|
817
|
+
}
|
|
818
|
+
var cleanupLabels = bindLabels(container, content, selections.map(function (_ref35) {
|
|
819
|
+
var annotation = _ref35.annotation,
|
|
820
|
+
marks = _ref35.marks;
|
|
821
|
+
return {
|
|
822
|
+
annotation: annotation,
|
|
823
|
+
bounds: function bounds() {
|
|
824
|
+
var _marks;
|
|
825
|
+
var rects = (_marks = marks[marks.length - 1]) === null || _marks === void 0 ? void 0 : _marks.getClientRects();
|
|
826
|
+
return rects === null || rects === void 0 ? void 0 : rects[rects.length - 1];
|
|
827
|
+
}
|
|
828
|
+
};
|
|
829
|
+
}), defaults);
|
|
830
|
+
return function () {
|
|
831
|
+
cleanupLabels();
|
|
832
|
+
for (var _i2 = 0, _spans = spans; _i2 < _spans.length; _i2++) {
|
|
833
|
+
var span = _spans[_i2];
|
|
834
|
+
span.replaceWith.apply(span, _toConsumableArray(span.childNodes));
|
|
835
|
+
}
|
|
836
|
+
content.normalize();
|
|
837
|
+
};
|
|
838
|
+
}
|