@antv/gpt-vis 1.3.2 → 1.4.1
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 +12 -3
- package/dist/cjs/vis/summary/index.js +29 -11
- 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/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 +12 -3
- package/dist/esm/vis/summary/index.js +35 -16
- 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/umd/index.min.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,277 @@
|
|
|
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 _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; } } }; }
|
|
7
|
+
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); }
|
|
8
|
+
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; }
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
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; }
|
|
12
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
13
|
+
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); }
|
|
14
|
+
import { createPointPulse } from "../utils";
|
|
15
|
+
|
|
16
|
+
/** Mark geometry and point halos belong to the same capability on both rendering stacks. */
|
|
17
|
+
export var point = {
|
|
18
|
+
create: createPoint,
|
|
19
|
+
g2: function g2() {
|
|
20
|
+
return drawG2;
|
|
21
|
+
},
|
|
22
|
+
g6: function g6() {
|
|
23
|
+
return drawG6;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var presets = new WeakMap();
|
|
27
|
+
|
|
28
|
+
/** Internal presets preserve native observations or specialize semantic markers without public options. */
|
|
29
|
+
function createPoint(options, preset) {
|
|
30
|
+
if (Array.isArray(options.data) && !options.data.length) return [];
|
|
31
|
+
var annotation = _objectSpread(_objectSpread({}, options), {}, {
|
|
32
|
+
type: 'point'
|
|
33
|
+
});
|
|
34
|
+
if (preset) presets.set(annotation, preset);
|
|
35
|
+
return [annotation];
|
|
36
|
+
}
|
|
37
|
+
var drawG2 = function drawG2(annotations, context) {
|
|
38
|
+
var defaults = context.defaults;
|
|
39
|
+
// G2 copies attributes onto retained shapes when updating native marks.
|
|
40
|
+
var owner = Symbol('point');
|
|
41
|
+
var disposed = false;
|
|
42
|
+
var pulse;
|
|
43
|
+
var update = function update() {
|
|
44
|
+
var _pulse;
|
|
45
|
+
if (disposed) return;
|
|
46
|
+
var scene = context.getScene();
|
|
47
|
+
// Native exit elements remain mounted until their transition cleanup finishes.
|
|
48
|
+
var elements = scene.querySelectorAll('.element').filter(function (element) {
|
|
49
|
+
return !element.__removed__;
|
|
50
|
+
});
|
|
51
|
+
var points = elements.filter(function (element) {
|
|
52
|
+
var _element$getAttribute;
|
|
53
|
+
return ((_element$getAttribute = element.getAttribute('annotationPoint')) === null || _element$getAttribute === void 0 ? void 0 : _element$getAttribute.owner) === owner;
|
|
54
|
+
});
|
|
55
|
+
(_pulse = pulse) === null || _pulse === void 0 || _pulse.clear();
|
|
56
|
+
if (!points.length) return;
|
|
57
|
+
var centers = elements.flatMap(function (element) {
|
|
58
|
+
if (element.markType !== 'point' || !element.isVisible()) return [];
|
|
59
|
+
var _element$getLocalBoun = element.getLocalBounds(),
|
|
60
|
+
halfExtents = _element$getLocalBoun.halfExtents;
|
|
61
|
+
if (!halfExtents[0] && !halfExtents[1]) return [];
|
|
62
|
+
var points = element.__data__.points;
|
|
63
|
+
var a = points[0],
|
|
64
|
+
b = points[points.length - 1];
|
|
65
|
+
return [[(a[0] + b[0]) / 2, (a[1] + b[1]) / 2]];
|
|
66
|
+
});
|
|
67
|
+
var _iterator = _createForOfIteratorHelper(points),
|
|
68
|
+
_step;
|
|
69
|
+
try {
|
|
70
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
71
|
+
var element = _step.value;
|
|
72
|
+
var _element$getAttribute2 = element.getAttribute('annotationPoint'),
|
|
73
|
+
anchor = _element$getAttribute2.anchor,
|
|
74
|
+
size = _element$getAttribute2.size,
|
|
75
|
+
color = _element$getAttribute2.color,
|
|
76
|
+
fill = _element$getAttribute2.fill,
|
|
77
|
+
stroke = _element$getAttribute2.stroke,
|
|
78
|
+
animated = _element$getAttribute2.pulse,
|
|
79
|
+
halo = _element$getAttribute2.halo;
|
|
80
|
+
var covered = fill === undefined && hasPointAt(centers, anchor);
|
|
81
|
+
element.setAttribute('fill', fill !== null && fill !== void 0 ? fill : covered ? 'transparent' : color);
|
|
82
|
+
element.setAttribute('stroke', covered ? 'transparent' : stroke);
|
|
83
|
+
if (halo) {
|
|
84
|
+
var _pulse2;
|
|
85
|
+
(_pulse2 = pulse) !== null && _pulse2 !== void 0 ? _pulse2 : pulse = createPointPulse(scene, defaults.pulse, update);
|
|
86
|
+
pulse.add(element.parentNode, anchor, size, color, animated);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
} catch (err) {
|
|
90
|
+
_iterator.e(err);
|
|
91
|
+
} finally {
|
|
92
|
+
_iterator.f();
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
return {
|
|
96
|
+
update: update,
|
|
97
|
+
cleanup: function cleanup() {
|
|
98
|
+
var _pulse3;
|
|
99
|
+
disposed = true;
|
|
100
|
+
(_pulse3 = pulse) === null || _pulse3 === void 0 || _pulse3.destroy();
|
|
101
|
+
},
|
|
102
|
+
marks: annotations.map(function (annotation) {
|
|
103
|
+
var _annotation$style$siz, _annotation$style, _annotation$style$str, _annotation$style2, _ref, _preset$outline, _annotation$style3, _preset$shape, _annotation$style$lin, _annotation$style4, _annotation$style$fil, _annotation$style5;
|
|
104
|
+
var preset = presets.get(annotation);
|
|
105
|
+
var useSourceGeometry = preset === null || preset === void 0 ? void 0 : preset.useSourceGeometry;
|
|
106
|
+
var size = (_annotation$style$siz = (_annotation$style = annotation.style) === null || _annotation$style === void 0 ? void 0 : _annotation$style.size) !== null && _annotation$style$siz !== void 0 ? _annotation$style$siz : defaults.size;
|
|
107
|
+
var stroke = (_annotation$style$str = (_annotation$style2 = annotation.style) === null || _annotation$style2 === void 0 ? void 0 : _annotation$style2.stroke) !== null && _annotation$style$str !== void 0 ? _annotation$style$str : defaults.stroke;
|
|
108
|
+
var outline = (_ref = (_preset$outline = preset === null || preset === void 0 ? void 0 : preset.outline) !== null && _preset$outline !== void 0 ? _preset$outline : (_annotation$style3 = annotation.style) === null || _annotation$style3 === void 0 ? void 0 : _annotation$style3.stroke) !== null && _ref !== void 0 ? _ref : defaults.pointStroke;
|
|
109
|
+
var shape = (_preset$shape = preset === null || preset === void 0 ? void 0 : preset.shape) !== null && _preset$shape !== void 0 ? _preset$shape : defaults.shape;
|
|
110
|
+
var radius = size * ((preset === null || preset === void 0 ? void 0 : preset.halo) === false ? 1 : defaults.pulse.endScale);
|
|
111
|
+
var resolved = [];
|
|
112
|
+
return context.createMark(annotation, {
|
|
113
|
+
nativeType: 'point',
|
|
114
|
+
shape: shape,
|
|
115
|
+
zIndex: preset === null || preset === void 0 ? void 0 : preset.zIndex,
|
|
116
|
+
encode: {
|
|
117
|
+
size: size
|
|
118
|
+
},
|
|
119
|
+
data: preset !== null && preset !== void 0 && preset.positions ? function (coordinate) {
|
|
120
|
+
var _preset$visible;
|
|
121
|
+
resolved = ((_preset$visible = preset.visible) === null || _preset$visible === void 0 ? void 0 : _preset$visible.call(preset)) === false ? [] : preset.positions(context, coordinate);
|
|
122
|
+
return resolved.map(function (position) {
|
|
123
|
+
return {
|
|
124
|
+
position: position
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
} : undefined,
|
|
128
|
+
labelGap: radius,
|
|
129
|
+
label: {
|
|
130
|
+
annotationPreferSide: true,
|
|
131
|
+
connectorStroke: stroke
|
|
132
|
+
},
|
|
133
|
+
style: {
|
|
134
|
+
shape: shape,
|
|
135
|
+
stroke: outline,
|
|
136
|
+
lineWidth: (_annotation$style$lin = (_annotation$style4 = annotation.style) === null || _annotation$style4 === void 0 ? void 0 : _annotation$style4.lineWidth) !== null && _annotation$style$lin !== void 0 ? _annotation$style$lin : defaults.lineWidth.point,
|
|
137
|
+
fill: (_annotation$style$fil = (_annotation$style5 = annotation.style) === null || _annotation$style5 === void 0 ? void 0 : _annotation$style5.fill) !== null && _annotation$style$fil !== void 0 ? _annotation$style$fil : 'transparent',
|
|
138
|
+
fillOpacity: preset === null || preset === void 0 ? void 0 : preset.fillOpacity
|
|
139
|
+
},
|
|
140
|
+
decorate: function decorate(element, points) {
|
|
141
|
+
var _annotation$style6;
|
|
142
|
+
var _points = _slicedToArray(points, 2),
|
|
143
|
+
a = _points[0],
|
|
144
|
+
_points$ = _points[1],
|
|
145
|
+
b = _points$ === void 0 ? a : _points$;
|
|
146
|
+
var fill = (_annotation$style6 = annotation.style) === null || _annotation$style6 === void 0 ? void 0 : _annotation$style6.fill;
|
|
147
|
+
var anchor = [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2];
|
|
148
|
+
element.setAttribute('annotationBounds', {
|
|
149
|
+
x: anchor[0] - radius,
|
|
150
|
+
y: anchor[1] - radius,
|
|
151
|
+
width: radius * 2,
|
|
152
|
+
height: radius * 2
|
|
153
|
+
});
|
|
154
|
+
element.setAttribute('annotationPoint', {
|
|
155
|
+
owner: owner,
|
|
156
|
+
anchor: anchor,
|
|
157
|
+
size: size,
|
|
158
|
+
color: useSourceGeometry ? fill !== null && fill !== void 0 ? fill : context.color(Array.isArray(annotation.data) ? annotation.data[0] : annotation.data) : fill && fill !== 'none' && fill !== 'transparent' ? fill : stroke,
|
|
159
|
+
fill: fill,
|
|
160
|
+
stroke: outline,
|
|
161
|
+
pulse: annotation.pulse,
|
|
162
|
+
halo: (preset === null || preset === void 0 ? void 0 : preset.halo) !== false
|
|
163
|
+
});
|
|
164
|
+
},
|
|
165
|
+
geometry: function geometry(native) {
|
|
166
|
+
return function (_index, scale, value, coordinate) {
|
|
167
|
+
var _preset$visible2;
|
|
168
|
+
if ((preset === null || preset === void 0 || (_preset$visible2 = preset.visible) === null || _preset$visible2 === void 0 ? void 0 : _preset$visible2.call(preset)) === false) return [[], []];
|
|
169
|
+
var data = Array.isArray(annotation.data) ? annotation.data : [annotation.data];
|
|
170
|
+
var positions = preset !== null && preset !== void 0 && preset.positions ? resolved : data.map(function (datum) {
|
|
171
|
+
return context.position(datum, coordinate, !!useSourceGeometry);
|
|
172
|
+
});
|
|
173
|
+
// Resolved anchors are positions, even when the source view exposes interval ends.
|
|
174
|
+
var channels = _objectSpread({}, value);
|
|
175
|
+
for (var _i = 0, _arr = ['x1', 'y1', 'dx', 'dy']; _i < _arr.length; _i++) {
|
|
176
|
+
var key = _arr[_i];
|
|
177
|
+
delete channels[key];
|
|
178
|
+
}
|
|
179
|
+
return native(positions.flatMap(function (p, i) {
|
|
180
|
+
return p ? [i] : [];
|
|
181
|
+
}), scale, _objectSpread(_objectSpread({}, channels), {}, {
|
|
182
|
+
x: positions.map(function (p) {
|
|
183
|
+
var _p$;
|
|
184
|
+
return (_p$ = p === null || p === void 0 ? void 0 : p[0]) !== null && _p$ !== void 0 ? _p$ : 0;
|
|
185
|
+
}),
|
|
186
|
+
y: positions.map(function (p) {
|
|
187
|
+
var _p$2;
|
|
188
|
+
return (_p$2 = p === null || p === void 0 ? void 0 : p[1]) !== null && _p$2 !== void 0 ? _p$2 : 0;
|
|
189
|
+
})
|
|
190
|
+
}), coordinate);
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
})
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
var drawG6 = function drawG6(annotations, context) {
|
|
198
|
+
var defaults = context.defaults;
|
|
199
|
+
var _iterator2 = _createForOfIteratorHelper(annotations),
|
|
200
|
+
_step2;
|
|
201
|
+
try {
|
|
202
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
203
|
+
var annotation = _step2.value;
|
|
204
|
+
var _iterator3 = _createForOfIteratorHelper(Array.isArray(annotation.data) ? annotation.data : [annotation.data]),
|
|
205
|
+
_step3;
|
|
206
|
+
try {
|
|
207
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
208
|
+
var _annotation$style$siz2, _annotation$style7, _annotation$style$str2, _annotation$style8, _annotation$style9, _annotation$style$lin2, _annotation$style10, _annotation$style$str3, _annotation$style11, _annotation$style$fil2, _annotation$style12;
|
|
209
|
+
var data = _step3.value;
|
|
210
|
+
var anchor = context.position(data);
|
|
211
|
+
if (!anchor) continue;
|
|
212
|
+
var _anchor = _slicedToArray(anchor, 2),
|
|
213
|
+
x = _anchor[0],
|
|
214
|
+
y = _anchor[1];
|
|
215
|
+
var r = (_annotation$style$siz2 = (_annotation$style7 = annotation.style) === null || _annotation$style7 === void 0 ? void 0 : _annotation$style7.size) !== null && _annotation$style$siz2 !== void 0 ? _annotation$style$siz2 : defaults.size;
|
|
216
|
+
var halo = r * defaults.pulse.endScale;
|
|
217
|
+
context.boxes.push({
|
|
218
|
+
x: x - halo,
|
|
219
|
+
y: y - halo,
|
|
220
|
+
width: halo * 2,
|
|
221
|
+
height: halo * 2
|
|
222
|
+
});
|
|
223
|
+
var stroke = (_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.stroke;
|
|
224
|
+
var covered = ((_annotation$style9 = annotation.style) === null || _annotation$style9 === void 0 ? void 0 : _annotation$style9.fill) === undefined && hasPointAt(context.centers, anchor);
|
|
225
|
+
var paint = {
|
|
226
|
+
lineWidth: (_annotation$style$lin2 = (_annotation$style10 = annotation.style) === null || _annotation$style10 === void 0 ? void 0 : _annotation$style10.lineWidth) !== null && _annotation$style$lin2 !== void 0 ? _annotation$style$lin2 : defaults.lineWidth.point,
|
|
227
|
+
stroke: covered ? 'transparent' : (_annotation$style$str3 = (_annotation$style11 = annotation.style) === null || _annotation$style11 === void 0 ? void 0 : _annotation$style11.stroke) !== null && _annotation$style$str3 !== void 0 ? _annotation$style$str3 : defaults.pointStroke,
|
|
228
|
+
fill: (_annotation$style$fil2 = (_annotation$style12 = annotation.style) === null || _annotation$style12 === void 0 ? void 0 : _annotation$style12.fill) !== null && _annotation$style$fil2 !== void 0 ? _annotation$style$fil2 : covered ? 'transparent' : stroke
|
|
229
|
+
};
|
|
230
|
+
context.pulse().add(context.root, anchor, r, paint.fill !== 'none' && paint.fill !== 'transparent' ? paint.fill : stroke, annotation.pulse);
|
|
231
|
+
var shape = defaults.shape;
|
|
232
|
+
if (shape === 'square' || shape === 'hollowSquare') context.add('rect', _objectSpread(_objectSpread({}, paint), {}, {
|
|
233
|
+
x: x - r,
|
|
234
|
+
y: y - r,
|
|
235
|
+
width: 2 * r,
|
|
236
|
+
height: 2 * r
|
|
237
|
+
}));else if (shape === 'diamond' || shape === 'hollowDiamond') context.add('path', _objectSpread(_objectSpread({}, paint), {}, {
|
|
238
|
+
d: [['M', x, y - r * 1.5], ['L', x + r, y], ['L', x, y + r * 1.5], ['L', x - r, y], ['Z']]
|
|
239
|
+
}));else if (shape === 'triangle' || shape === 'hollowTriangle') context.add('path', _objectSpread(_objectSpread({}, paint), {}, {
|
|
240
|
+
d: [['M', x, y - r], ['L', x + r, y + r], ['L', x - r, y + r], ['Z']]
|
|
241
|
+
}));else if (shape === 'triangleDown') context.add('path', _objectSpread(_objectSpread({}, paint), {}, {
|
|
242
|
+
d: [['M', x, y + r], ['L', x + r, y - r], ['L', x - r, y - r], ['Z']]
|
|
243
|
+
}));else if (['point', 'circle', 'hollow', 'hollowCircle'].includes(shape)) context.add('circle', _objectSpread(_objectSpread({}, paint), {}, {
|
|
244
|
+
cx: x,
|
|
245
|
+
cy: y,
|
|
246
|
+
r: r
|
|
247
|
+
}));else throw new Error("Unsupported annotation point shape: ".concat(shape, "."));
|
|
248
|
+
context.label(annotation, anchor, {
|
|
249
|
+
gap: halo
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
} catch (err) {
|
|
253
|
+
_iterator3.e(err);
|
|
254
|
+
} finally {
|
|
255
|
+
_iterator3.f();
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
} catch (err) {
|
|
259
|
+
_iterator2.e(err);
|
|
260
|
+
} finally {
|
|
261
|
+
_iterator2.f();
|
|
262
|
+
}
|
|
263
|
+
return {};
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
/** Allow only floating-point differences between mapped renderer coordinates. */
|
|
267
|
+
function hasPointAt(points, _ref2) {
|
|
268
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
269
|
+
x = _ref3[0],
|
|
270
|
+
y = _ref3[1];
|
|
271
|
+
return points.some(function (_ref4) {
|
|
272
|
+
var _ref5 = _slicedToArray(_ref4, 2),
|
|
273
|
+
px = _ref5[0],
|
|
274
|
+
py = _ref5[1];
|
|
275
|
+
return Math.hypot(px - x, py - y) < 1e-6;
|
|
276
|
+
});
|
|
277
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
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 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; }
|
|
3
|
+
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; }
|
|
4
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
5
|
+
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."); }
|
|
6
|
+
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; } }
|
|
7
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
12
|
+
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."); }
|
|
13
|
+
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); }
|
|
14
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
15
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
16
|
+
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; }
|
|
17
|
+
import { axisPosition, finiteValue } from "../utils";
|
|
18
|
+
import { path } from "./path";
|
|
19
|
+
import { range } from "./range";
|
|
20
|
+
import { text } from "./text";
|
|
21
|
+
|
|
22
|
+
/** Four named decision regions share the chart's numeric dividers and theme. */
|
|
23
|
+
export var quadrant = {
|
|
24
|
+
g2: function g2(annotations, _ref) {
|
|
25
|
+
var mapping = _ref.mapping,
|
|
26
|
+
defaults = _ref.defaults;
|
|
27
|
+
return annotations.flatMap(function (annotation) {
|
|
28
|
+
if (!annotation.data || Object.keys(annotation.data).some(function (key) {
|
|
29
|
+
return key !== mapping.x && key !== mapping.y;
|
|
30
|
+
})) throw new Error('Invalid annotation: quadrant needs both axis coordinates.');
|
|
31
|
+
var x = finiteValue(annotation.data[mapping.x], mapping.x);
|
|
32
|
+
var y = finiteValue(annotation.data[mapping.y], mapping.y);
|
|
33
|
+
var hidden = annotation.label === '';
|
|
34
|
+
var regions = ['topRight', 'topLeft', 'bottomLeft', 'bottomRight'].flatMap(function (name, i) {
|
|
35
|
+
var _annotation$labels$na, _annotation$labels, _annotation$style$fil, _annotation$style, _annotation$style$fil2, _annotation$style2, _annotation$style3, _annotation$style4;
|
|
36
|
+
var right = name.endsWith('Right');
|
|
37
|
+
var top = name.startsWith('top');
|
|
38
|
+
var bounds = function bounds(context) {
|
|
39
|
+
var splitX = Math.max(0, Math.min(1, context.axisValue('x', x)));
|
|
40
|
+
var splitY = Math.max(0, Math.min(1, context.axisValue('y', y)));
|
|
41
|
+
return [[right ? splitX : 0, top ? 0 : splitY], [right ? 1 : splitX, top ? splitY : 1]];
|
|
42
|
+
};
|
|
43
|
+
var label = hidden ? '' : (_annotation$labels$na = (_annotation$labels = annotation.labels) === null || _annotation$labels === void 0 ? void 0 : _annotation$labels[name]) !== null && _annotation$labels$na !== void 0 ? _annotation$labels$na : "".concat(right ? 'High' : 'Low', " ").concat(mapping.x, " \xB7 ").concat(top ? 'High' : 'Low', " ").concat(mapping.y);
|
|
44
|
+
return [].concat(_toConsumableArray(range.create({
|
|
45
|
+
data: _defineProperty(_defineProperty({}, mapping.x, [x, x]), mapping.y, [y, y]),
|
|
46
|
+
label: '',
|
|
47
|
+
style: {
|
|
48
|
+
fill: (_annotation$style$fil = (_annotation$style = annotation.style) === null || _annotation$style === void 0 ? void 0 : _annotation$style.fill) !== null && _annotation$style$fil !== void 0 ? _annotation$style$fil : defaults.palette[i % defaults.palette.length],
|
|
49
|
+
fillOpacity: (_annotation$style$fil2 = (_annotation$style2 = annotation.style) === null || _annotation$style2 === void 0 ? void 0 : _annotation$style2.fillOpacity) !== null && _annotation$style$fil2 !== void 0 ? _annotation$style$fil2 : 0.06
|
|
50
|
+
}
|
|
51
|
+
}, bounds)), _toConsumableArray(label ? text.create({
|
|
52
|
+
data: annotation.data,
|
|
53
|
+
label: label,
|
|
54
|
+
style: {
|
|
55
|
+
labelFill: (_annotation$style3 = annotation.style) === null || _annotation$style3 === void 0 ? void 0 : _annotation$style3.labelFill,
|
|
56
|
+
labelFontSize: (_annotation$style4 = annotation.style) === null || _annotation$style4 === void 0 ? void 0 : _annotation$style4.labelFontSize
|
|
57
|
+
}
|
|
58
|
+
}, function (context, coordinate) {
|
|
59
|
+
var _bounds = bounds(context),
|
|
60
|
+
_bounds2 = _slicedToArray(_bounds, 2),
|
|
61
|
+
from = _bounds2[0],
|
|
62
|
+
to = _bounds2[1];
|
|
63
|
+
if (to[0] <= from[0] || to[1] <= from[1]) return undefined;
|
|
64
|
+
var inset = Math.min((to[1] - from[1]) / 2, 18 / coordinate.getSize()[1]);
|
|
65
|
+
return [(from[0] + to[0]) / 2, from[1] + inset];
|
|
66
|
+
}) : []));
|
|
67
|
+
});
|
|
68
|
+
var dividers = ['x', 'y'].flatMap(function (axis) {
|
|
69
|
+
var _annotation$label;
|
|
70
|
+
var field = mapping[axis];
|
|
71
|
+
var value = axis === 'x' ? x : y;
|
|
72
|
+
return path.create({
|
|
73
|
+
data: axisPosition(field, value),
|
|
74
|
+
label: (_annotation$label = annotation.label) !== null && _annotation$label !== void 0 ? _annotation$label : "".concat(axis.toUpperCase(), ": ").concat(value),
|
|
75
|
+
style: _objectSpread({
|
|
76
|
+
lineDash: [4, 4]
|
|
77
|
+
}, annotation.style)
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
return [].concat(_toConsumableArray(regions), _toConsumableArray(dividers));
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
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 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; }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
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); }
|
|
7
|
+
import { annotationField, axisPosition, formatNumber, numericRows, quantileValue, selectRows } from "../utils";
|
|
8
|
+
import { path } from "./path";
|
|
9
|
+
export var quantile = {
|
|
10
|
+
g2: function g2(annotations, _ref) {
|
|
11
|
+
var mapping = _ref.mapping;
|
|
12
|
+
return annotations.flatMap(function (annotation) {
|
|
13
|
+
var _annotation$label;
|
|
14
|
+
var field = annotationField(mapping, annotation.axis);
|
|
15
|
+
var values = numericRows(selectRows(mapping.data, annotation.data), field).map(function (_ref2) {
|
|
16
|
+
var value = _ref2.value;
|
|
17
|
+
return value;
|
|
18
|
+
});
|
|
19
|
+
var value = quantileValue(values.sort(function (a, b) {
|
|
20
|
+
return a - b;
|
|
21
|
+
}), annotation.p);
|
|
22
|
+
if (!values.length) return [];
|
|
23
|
+
return path.create({
|
|
24
|
+
data: axisPosition(field, value),
|
|
25
|
+
label: (_annotation$label = annotation.label) !== null && _annotation$label !== void 0 ? _annotation$label : "P".concat(formatNumber(annotation.p * 100), ": ").concat(formatNumber(value)),
|
|
26
|
+
style: _objectSpread({
|
|
27
|
+
lineDash: [4, 4]
|
|
28
|
+
}, annotation.style)
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
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 _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; }
|
|
3
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
4
|
+
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); }
|
|
5
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
|
+
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."); }
|
|
7
|
+
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); }
|
|
8
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
9
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
|
+
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; }
|
|
11
|
+
import { selectRange, selectRows } from "../utils";
|
|
12
|
+
import { highlight } from "./highlight";
|
|
13
|
+
import { range } from "./range";
|
|
14
|
+
export var rangeInside = {
|
|
15
|
+
g2: function g2(annotations, _ref) {
|
|
16
|
+
var mapping = _ref.mapping;
|
|
17
|
+
return annotations.flatMap(function (annotation) {
|
|
18
|
+
var _annotation$style$fil, _annotation$style, _annotation$style2;
|
|
19
|
+
var rows = selectRows(mapping.data, annotation.data);
|
|
20
|
+
var field = mapping.y;
|
|
21
|
+
var selected = selectRange(rows, field, annotation.range, false);
|
|
22
|
+
return [].concat(_toConsumableArray(range.create({
|
|
23
|
+
data: _defineProperty({}, field, annotation.range),
|
|
24
|
+
style: {
|
|
25
|
+
fill: (_annotation$style$fil = (_annotation$style = annotation.style) === null || _annotation$style === void 0 ? void 0 : _annotation$style.fill) !== null && _annotation$style$fil !== void 0 ? _annotation$style$fil : (_annotation$style2 = annotation.style) === null || _annotation$style2 === void 0 ? void 0 : _annotation$style2.stroke
|
|
26
|
+
}
|
|
27
|
+
})), _toConsumableArray(selected.flatMap(function (row) {
|
|
28
|
+
var _annotation$label;
|
|
29
|
+
return highlight.create({
|
|
30
|
+
data: [row],
|
|
31
|
+
label: (_annotation$label = annotation.label) !== null && _annotation$label !== void 0 ? _annotation$label : "Inside range: ".concat(row[field]),
|
|
32
|
+
style: annotation.style
|
|
33
|
+
});
|
|
34
|
+
})));
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
table: function table(annotations, _ref2) {
|
|
38
|
+
var data = _ref2.data;
|
|
39
|
+
return annotations.flatMap(function (annotation) {
|
|
40
|
+
var rows = selectRows(data, annotation.data.row);
|
|
41
|
+
var field = annotation.data.field;
|
|
42
|
+
return selectRange(rows, field, annotation.range, false).flatMap(function (row) {
|
|
43
|
+
var _annotation$label2;
|
|
44
|
+
return highlight.create({
|
|
45
|
+
data: [{
|
|
46
|
+
row: row,
|
|
47
|
+
column: annotation.data.column
|
|
48
|
+
}],
|
|
49
|
+
label: (_annotation$label2 = annotation.label) !== null && _annotation$label2 !== void 0 ? _annotation$label2 : "Inside range: ".concat(row[field]),
|
|
50
|
+
style: annotation.style
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
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 _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; }
|
|
3
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
4
|
+
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); }
|
|
5
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
|
+
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."); }
|
|
7
|
+
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); }
|
|
8
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
9
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
|
+
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; }
|
|
11
|
+
import { selectRange, selectRows } from "../utils";
|
|
12
|
+
import { highlight } from "./highlight";
|
|
13
|
+
import { range } from "./range";
|
|
14
|
+
export var rangeOutside = {
|
|
15
|
+
g2: function g2(annotations, _ref) {
|
|
16
|
+
var mapping = _ref.mapping;
|
|
17
|
+
return annotations.flatMap(function (annotation) {
|
|
18
|
+
var _annotation$style$fil, _annotation$style, _annotation$style2;
|
|
19
|
+
var rows = selectRows(mapping.data, annotation.data);
|
|
20
|
+
var field = mapping.y;
|
|
21
|
+
var selected = selectRange(rows, field, annotation.range, true);
|
|
22
|
+
return [].concat(_toConsumableArray(range.create({
|
|
23
|
+
data: _defineProperty({}, field, annotation.range),
|
|
24
|
+
style: {
|
|
25
|
+
fill: (_annotation$style$fil = (_annotation$style = annotation.style) === null || _annotation$style === void 0 ? void 0 : _annotation$style.fill) !== null && _annotation$style$fil !== void 0 ? _annotation$style$fil : (_annotation$style2 = annotation.style) === null || _annotation$style2 === void 0 ? void 0 : _annotation$style2.stroke
|
|
26
|
+
}
|
|
27
|
+
})), _toConsumableArray(selected.flatMap(function (row) {
|
|
28
|
+
var _annotation$label;
|
|
29
|
+
return highlight.create({
|
|
30
|
+
data: [row],
|
|
31
|
+
label: (_annotation$label = annotation.label) !== null && _annotation$label !== void 0 ? _annotation$label : "Outside range: ".concat(row[field]),
|
|
32
|
+
style: annotation.style
|
|
33
|
+
});
|
|
34
|
+
})));
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
table: function table(annotations, _ref2) {
|
|
38
|
+
var data = _ref2.data;
|
|
39
|
+
return annotations.flatMap(function (annotation) {
|
|
40
|
+
var rows = selectRows(data, annotation.data.row);
|
|
41
|
+
var field = annotation.data.field;
|
|
42
|
+
return selectRange(rows, field, annotation.range, true).flatMap(function (row) {
|
|
43
|
+
var _annotation$label2;
|
|
44
|
+
return highlight.create({
|
|
45
|
+
data: [{
|
|
46
|
+
row: row,
|
|
47
|
+
column: annotation.data.column
|
|
48
|
+
}],
|
|
49
|
+
label: (_annotation$label2 = annotation.label) !== null && _annotation$label2 !== void 0 ? _annotation$label2 : "Outside range: ".concat(row[field]),
|
|
50
|
+
style: annotation.style
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { axisRange } from "../utils";
|
|
2
|
+
import { range } from "./range";
|
|
3
|
+
export var rangeX = {
|
|
4
|
+
g2: function g2(annotations, _ref) {
|
|
5
|
+
var mapping = _ref.mapping;
|
|
6
|
+
return annotations.flatMap(function (annotation) {
|
|
7
|
+
var _annotation$label;
|
|
8
|
+
return range.create({
|
|
9
|
+
data: axisRange(mapping.x, annotation.range),
|
|
10
|
+
label: (_annotation$label = annotation.label) !== null && _annotation$label !== void 0 ? _annotation$label : "X range: ".concat(annotation.range.join('–')),
|
|
11
|
+
style: annotation.style
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { axisRange } from "../utils";
|
|
2
|
+
import { range } from "./range";
|
|
3
|
+
export var rangeY = {
|
|
4
|
+
g2: function g2(annotations, _ref) {
|
|
5
|
+
var mapping = _ref.mapping;
|
|
6
|
+
return annotations.flatMap(function (annotation) {
|
|
7
|
+
var _annotation$label;
|
|
8
|
+
return range.create({
|
|
9
|
+
data: axisRange(mapping.y, annotation.range),
|
|
10
|
+
label: (_annotation$label = annotation.label) !== null && _annotation$label !== void 0 ? _annotation$label : "Y range: ".concat(annotation.range.join('–')),
|
|
11
|
+
style: annotation.style
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Annotation } from '../../types/annotation';
|
|
2
|
+
import type { Point } from '../layout';
|
|
3
|
+
import type { AnnotationComponent } from '../registry';
|
|
4
|
+
import type { G2AnnotationContext } from '../runtime';
|
|
5
|
+
/** Axis bounds, including the full band at either end; omitted axes span the plot. */
|
|
6
|
+
export declare const range: AnnotationComponent<'range', 'g2'> & {
|
|
7
|
+
create: typeof createRange;
|
|
8
|
+
};
|
|
9
|
+
type Bounds = (context: Pick<G2AnnotationContext<object>, 'axisValue'>) => [Point, Point];
|
|
10
|
+
declare function createRange<T extends object>(options: Omit<Extract<Annotation<T>, {
|
|
11
|
+
type: 'range';
|
|
12
|
+
}>, 'type'>, bounds?: Bounds): Extract<Annotation<T>, {
|
|
13
|
+
type: 'range';
|
|
14
|
+
}>[];
|
|
15
|
+
export {};
|