@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,92 @@
|
|
|
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 _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); }
|
|
5
|
+
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; }
|
|
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 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; }
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
12
|
+
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); }
|
|
13
|
+
/** Axis bounds, including the full band at either end; omitted axes span the plot. */
|
|
14
|
+
export var range = {
|
|
15
|
+
create: createRange,
|
|
16
|
+
g2: function g2() {
|
|
17
|
+
return drawG2;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var positions = new WeakMap();
|
|
21
|
+
function createRange(options, bounds) {
|
|
22
|
+
var annotation = _objectSpread(_objectSpread({}, options), {}, {
|
|
23
|
+
type: 'range'
|
|
24
|
+
});
|
|
25
|
+
if (bounds) positions.set(annotation, bounds);
|
|
26
|
+
return [annotation];
|
|
27
|
+
}
|
|
28
|
+
var drawG2 = function drawG2(annotations, context) {
|
|
29
|
+
var mapping = context.mapping,
|
|
30
|
+
defaults = context.defaults;
|
|
31
|
+
return {
|
|
32
|
+
marks: annotations.map(function (annotation) {
|
|
33
|
+
var _annotation$style$str, _annotation$style, _annotation$style$lin, _annotation$style2, _annotation$style3, _ref, _annotation$style$fil, _annotation$style4, _annotation$style5, _annotation$style$fil2, _annotation$style6;
|
|
34
|
+
var x = annotation.data[mapping.x];
|
|
35
|
+
var y = annotation.data[mapping.y];
|
|
36
|
+
return context.createMark(annotation, {
|
|
37
|
+
nativeType: x && y ? 'range' : x !== undefined ? 'rangeX' : 'rangeY',
|
|
38
|
+
zIndex: -1,
|
|
39
|
+
clip: true,
|
|
40
|
+
decorate: function decorate(element) {
|
|
41
|
+
return element.setAttribute('annotationIgnoreObstacle', true);
|
|
42
|
+
},
|
|
43
|
+
style: {
|
|
44
|
+
stroke: (_annotation$style$str = (_annotation$style = annotation.style) === null || _annotation$style === void 0 ? void 0 : _annotation$style.stroke) !== null && _annotation$style$str !== void 0 ? _annotation$style$str : 'none',
|
|
45
|
+
lineWidth: (_annotation$style$lin = (_annotation$style2 = annotation.style) === null || _annotation$style2 === void 0 ? void 0 : _annotation$style2.lineWidth) !== null && _annotation$style$lin !== void 0 ? _annotation$style$lin : defaults.lineWidth.range,
|
|
46
|
+
lineDash: (_annotation$style3 = annotation.style) === null || _annotation$style3 === void 0 ? void 0 : _annotation$style3.lineDash,
|
|
47
|
+
fill: (_ref = (_annotation$style$fil = (_annotation$style4 = annotation.style) === null || _annotation$style4 === void 0 ? void 0 : _annotation$style4.fill) !== null && _annotation$style$fil !== void 0 ? _annotation$style$fil : (_annotation$style5 = annotation.style) === null || _annotation$style5 === void 0 ? void 0 : _annotation$style5.stroke) !== null && _ref !== void 0 ? _ref : defaults.stroke,
|
|
48
|
+
fillOpacity: (_annotation$style$fil2 = (_annotation$style6 = annotation.style) === null || _annotation$style6 === void 0 ? void 0 : _annotation$style6.fillOpacity) !== null && _annotation$style$fil2 !== void 0 ? _annotation$style$fil2 : defaults.fillOpacity
|
|
49
|
+
},
|
|
50
|
+
geometry: function geometry(native) {
|
|
51
|
+
return function (_index, scale, value, coordinate) {
|
|
52
|
+
var position = positions.get(annotation);
|
|
53
|
+
if (position) {
|
|
54
|
+
var _position = position(context),
|
|
55
|
+
_position2 = _slicedToArray(_position, 2),
|
|
56
|
+
from = _position2[0],
|
|
57
|
+
to = _position2[1];
|
|
58
|
+
return native([0], scale, _objectSpread(_objectSpread({}, value), {}, {
|
|
59
|
+
x: [from[0]],
|
|
60
|
+
x1: [to[0]],
|
|
61
|
+
y: [from[1]],
|
|
62
|
+
y1: [to[1]]
|
|
63
|
+
}), coordinate);
|
|
64
|
+
}
|
|
65
|
+
if (!context.onlyAxisFields(annotation.data)) throw new Error('Invalid annotation: range only accepts axis fields.');
|
|
66
|
+
var bounds = function bounds(values, axis) {
|
|
67
|
+
if (!values) return [0, 1];
|
|
68
|
+
var a = context.axisValue(axis, values[0], false);
|
|
69
|
+
var b = context.axisValue(axis, values[1], false);
|
|
70
|
+
var end = context.bandWidth(axis, values[a < b ? 1 : 0]);
|
|
71
|
+
return [Math.min(a, b), Math.max(a, b) + end];
|
|
72
|
+
};
|
|
73
|
+
var _bounds = bounds(x, 'x'),
|
|
74
|
+
_bounds2 = _slicedToArray(_bounds, 2),
|
|
75
|
+
x0 = _bounds2[0],
|
|
76
|
+
x1 = _bounds2[1];
|
|
77
|
+
var _bounds3 = bounds(y, 'y'),
|
|
78
|
+
_bounds4 = _slicedToArray(_bounds3, 2),
|
|
79
|
+
y0 = _bounds4[0],
|
|
80
|
+
y1 = _bounds4[1];
|
|
81
|
+
return native([0], scale, _objectSpread(_objectSpread({}, value), {}, {
|
|
82
|
+
x: [x0],
|
|
83
|
+
x1: [x1],
|
|
84
|
+
y: [y0],
|
|
85
|
+
y1: [y1]
|
|
86
|
+
}), coordinate);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
})
|
|
91
|
+
};
|
|
92
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
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; } } }; }
|
|
8
|
+
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); }
|
|
9
|
+
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; }
|
|
10
|
+
import { annotationField, axisPosition, finiteValue, formatNumber } from "../utils";
|
|
11
|
+
import { path } from "./path";
|
|
12
|
+
export var target = {
|
|
13
|
+
g2: function g2(annotations, _ref) {
|
|
14
|
+
var mapping = _ref.mapping;
|
|
15
|
+
return annotations.flatMap(function (annotation) {
|
|
16
|
+
var _annotation$label;
|
|
17
|
+
var field = annotationField(mapping, annotation.axis);
|
|
18
|
+
if (annotation.target !== undefined && annotation.data !== undefined) throw new Error('Invalid annotation: target needs either a fixed target or a path.');
|
|
19
|
+
if (annotation.target === undefined) {
|
|
20
|
+
if (!Array.isArray(annotation.data) || annotation.data.length < 2) throw new Error('Invalid annotation: target path needs at least two positions.');
|
|
21
|
+
var _iterator = _createForOfIteratorHelper(annotation.data),
|
|
22
|
+
_step;
|
|
23
|
+
try {
|
|
24
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
25
|
+
var position = _step.value;
|
|
26
|
+
axisPosition(mapping.x, position[mapping.x]);
|
|
27
|
+
finiteValue(position[mapping.y], mapping.y);
|
|
28
|
+
}
|
|
29
|
+
} catch (err) {
|
|
30
|
+
_iterator.e(err);
|
|
31
|
+
} finally {
|
|
32
|
+
_iterator.f();
|
|
33
|
+
}
|
|
34
|
+
} else finiteValue(annotation.target, 'target');
|
|
35
|
+
return path.create({
|
|
36
|
+
data: annotation.target === undefined ? annotation.data : axisPosition(field, annotation.target),
|
|
37
|
+
label: (_annotation$label = annotation.label) !== null && _annotation$label !== void 0 ? _annotation$label : annotation.target === undefined ? 'Target' : "Target: ".concat(formatNumber(annotation.target)),
|
|
38
|
+
style: _objectSpread({
|
|
39
|
+
lineDash: [4, 4]
|
|
40
|
+
}, annotation.style)
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
};
|
|
@@ -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
|
+
/** Standalone text stays at the supplied anchor and participates as a fixed layout obstacle. */
|
|
6
|
+
export declare const text: AnnotationComponent<'text', 'g2' | 'g6'> & {
|
|
7
|
+
create: typeof createText;
|
|
8
|
+
};
|
|
9
|
+
type Position = (context: Pick<G2AnnotationContext<object>, 'axisValue'>, coordinate: Parameters<G2AnnotationContext<object>['position']>[1]) => Point | undefined;
|
|
10
|
+
declare function createText<T extends object>(options: Omit<Extract<Annotation<T>, {
|
|
11
|
+
type: 'text';
|
|
12
|
+
}>, 'type'>, position?: Position): Extract<Annotation<T>, {
|
|
13
|
+
type: 'text';
|
|
14
|
+
}>[];
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
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 _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; } } }; }
|
|
3
|
+
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); }
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
|
+
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; }
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
|
+
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); }
|
|
10
|
+
/** Standalone text stays at the supplied anchor and participates as a fixed layout obstacle. */
|
|
11
|
+
export var text = {
|
|
12
|
+
create: createText,
|
|
13
|
+
g2: function g2() {
|
|
14
|
+
return drawG2;
|
|
15
|
+
},
|
|
16
|
+
g6: function g6() {
|
|
17
|
+
return drawG6;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var positions = new WeakMap();
|
|
21
|
+
function createText(options, position) {
|
|
22
|
+
var annotation = _objectSpread(_objectSpread({}, options), {}, {
|
|
23
|
+
type: 'text'
|
|
24
|
+
});
|
|
25
|
+
if (position) positions.set(annotation, position);
|
|
26
|
+
return [annotation];
|
|
27
|
+
}
|
|
28
|
+
var drawG2 = function drawG2(annotations, context) {
|
|
29
|
+
return {
|
|
30
|
+
marks: annotations.map(function (annotation) {
|
|
31
|
+
return context.createMark(annotation, {
|
|
32
|
+
nativeType: 'text',
|
|
33
|
+
zIndex: 1,
|
|
34
|
+
encode: {
|
|
35
|
+
text: function text() {
|
|
36
|
+
return annotation.label;
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
label: false,
|
|
40
|
+
style: _objectSpread(_objectSpread({}, context.getTextStyle(annotation)), {}, {
|
|
41
|
+
textAlign: 'center',
|
|
42
|
+
textBaseline: 'middle',
|
|
43
|
+
stroke: 'none',
|
|
44
|
+
lineWidth: 0
|
|
45
|
+
}),
|
|
46
|
+
geometry: function geometry(native) {
|
|
47
|
+
return function (_index, scale, value, coordinate) {
|
|
48
|
+
var position = positions.get(annotation);
|
|
49
|
+
var point = position ? position(context, coordinate) : context.position(annotation.data, coordinate);
|
|
50
|
+
if (!point) return [[], []];
|
|
51
|
+
return native([0], scale, _objectSpread(_objectSpread({}, value), {}, {
|
|
52
|
+
x: [point[0]],
|
|
53
|
+
y: [point[1]]
|
|
54
|
+
}), coordinate);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
})
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
var drawG6 = function drawG6(annotations, context) {
|
|
62
|
+
var _iterator = _createForOfIteratorHelper(annotations),
|
|
63
|
+
_step;
|
|
64
|
+
try {
|
|
65
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
66
|
+
var annotation = _step.value;
|
|
67
|
+
var point = context.position(annotation.data);
|
|
68
|
+
if (point) context.label(annotation, point, {
|
|
69
|
+
standalone: true
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
} catch (err) {
|
|
73
|
+
_iterator.e(err);
|
|
74
|
+
} finally {
|
|
75
|
+
_iterator.f();
|
|
76
|
+
}
|
|
77
|
+
return {};
|
|
78
|
+
};
|
|
@@ -0,0 +1,297 @@
|
|
|
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 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; }
|
|
8
|
+
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; }
|
|
9
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
10
|
+
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."); }
|
|
11
|
+
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); }
|
|
12
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
13
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
14
|
+
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; }
|
|
15
|
+
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; }
|
|
16
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
17
|
+
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); }
|
|
18
|
+
import { numericRows, selectRows } from "../utils";
|
|
19
|
+
import { highlight } from "./highlight";
|
|
20
|
+
import { path } from "./path";
|
|
21
|
+
|
|
22
|
+
/** Emphasize the native portion above or below a threshold, with a shared reference line. */
|
|
23
|
+
export var thresholdHighlight = {
|
|
24
|
+
g2: function g2(annotations, context) {
|
|
25
|
+
var mapping = context.mapping,
|
|
26
|
+
chartType = context.chartType;
|
|
27
|
+
var selections = annotations.map(function (annotation) {
|
|
28
|
+
return {
|
|
29
|
+
annotation: annotation,
|
|
30
|
+
rows: selectThreshold(selectRows(mapping.data, annotation.data), mapping.y, annotation),
|
|
31
|
+
color: getColor(annotation, context)
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
var references = selections.flatMap(function (_ref) {
|
|
35
|
+
var _annotation$label, _annotation$style, _annotation$style2, _annotation$style3, _annotation$style4;
|
|
36
|
+
var annotation = _ref.annotation;
|
|
37
|
+
return path.create({
|
|
38
|
+
data: _defineProperty({}, mapping.y, annotation.threshold),
|
|
39
|
+
label: (_annotation$label = annotation.label) !== null && _annotation$label !== void 0 ? _annotation$label : "".concat(annotation.direction === 'below' ? 'Below' : 'Above', " threshold: ").concat(annotation.threshold),
|
|
40
|
+
style: {
|
|
41
|
+
stroke: (_annotation$style = annotation.style) === null || _annotation$style === void 0 ? void 0 : _annotation$style.stroke,
|
|
42
|
+
lineDash: [4, 4],
|
|
43
|
+
lineWidth: (_annotation$style2 = annotation.style) === null || _annotation$style2 === void 0 ? void 0 : _annotation$style2.lineWidth,
|
|
44
|
+
labelFill: (_annotation$style3 = annotation.style) === null || _annotation$style3 === void 0 ? void 0 : _annotation$style3.labelFill,
|
|
45
|
+
labelFontSize: (_annotation$style4 = annotation.style) === null || _annotation$style4 === void 0 ? void 0 : _annotation$style4.labelFontSize
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
switch (chartType) {
|
|
50
|
+
case 'scatter':
|
|
51
|
+
return [].concat(_toConsumableArray(references), _toConsumableArray(selections.flatMap(function (_ref2) {
|
|
52
|
+
var annotation = _ref2.annotation,
|
|
53
|
+
rows = _ref2.rows,
|
|
54
|
+
color = _ref2.color;
|
|
55
|
+
return highlight.create({
|
|
56
|
+
data: rows,
|
|
57
|
+
style: _objectSpread(_objectSpread({}, annotation.style), {}, {
|
|
58
|
+
fill: color,
|
|
59
|
+
stroke: color
|
|
60
|
+
})
|
|
61
|
+
});
|
|
62
|
+
})));
|
|
63
|
+
default:
|
|
64
|
+
return [drawG2].concat(_toConsumableArray(references));
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
table: function table(annotations, _ref3) {
|
|
68
|
+
var data = _ref3.data,
|
|
69
|
+
defaults = _ref3.defaults;
|
|
70
|
+
return annotations.flatMap(function (annotation) {
|
|
71
|
+
var _ref4, _annotation$style$fil, _annotation$style5, _annotation$style6, _annotation$label2;
|
|
72
|
+
var rows = selectThreshold(selectRows(data, annotation.data.row), annotation.data.field, annotation);
|
|
73
|
+
var color = (_ref4 = (_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 : (_annotation$style6 = annotation.style) === null || _annotation$style6 === void 0 ? void 0 : _annotation$style6.stroke) !== null && _ref4 !== void 0 ? _ref4 : defaults.highlight.color;
|
|
74
|
+
return highlight.create({
|
|
75
|
+
data: rows.map(function (row) {
|
|
76
|
+
return {
|
|
77
|
+
row: row,
|
|
78
|
+
column: annotation.data.column
|
|
79
|
+
};
|
|
80
|
+
}),
|
|
81
|
+
label: (_annotation$label2 = annotation.label) !== null && _annotation$label2 !== void 0 ? _annotation$label2 : "".concat(annotation.direction === 'below' ? 'Below' : 'Above', " threshold: ").concat(annotation.threshold),
|
|
82
|
+
style: _objectSpread({
|
|
83
|
+
fill: color,
|
|
84
|
+
stroke: color
|
|
85
|
+
}, annotation.style)
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/** Paint original native elements after G2 resolves scales, stacking and coordinate transforms. */
|
|
92
|
+
var drawG2 = function drawG2(annotations, context) {
|
|
93
|
+
var selections = annotations.map(function (annotation) {
|
|
94
|
+
return {
|
|
95
|
+
annotation: annotation,
|
|
96
|
+
rows: selectRows(context.mapping.data, annotation.data),
|
|
97
|
+
color: getColor(annotation, context)
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
if (!annotations.length) return {};
|
|
101
|
+
if (context.chartType === 'line' || context.chartType === 'area') {
|
|
102
|
+
var _iterator = _createForOfIteratorHelper(selections),
|
|
103
|
+
_step;
|
|
104
|
+
try {
|
|
105
|
+
var _loop = function _loop() {
|
|
106
|
+
var rows = _step.value.rows;
|
|
107
|
+
var selected = new Set(rows);
|
|
108
|
+
var groups = new Set(_toConsumableArray(selected).map(function (row) {
|
|
109
|
+
return context.mapping.series ? row[context.mapping.series] : undefined;
|
|
110
|
+
}));
|
|
111
|
+
if (context.mapping.data.some(function (row) {
|
|
112
|
+
return groups.has(context.mapping.series ? row[context.mapping.series] : undefined) && !selected.has(row);
|
|
113
|
+
})) throw new Error('Invalid annotation: line thresholds must select complete series.');
|
|
114
|
+
};
|
|
115
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
116
|
+
_loop();
|
|
117
|
+
}
|
|
118
|
+
} catch (err) {
|
|
119
|
+
_iterator.e(err);
|
|
120
|
+
} finally {
|
|
121
|
+
_iterator.f();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
var original = new Map();
|
|
125
|
+
var reset = function reset() {
|
|
126
|
+
var _iterator2 = _createForOfIteratorHelper(original),
|
|
127
|
+
_step2;
|
|
128
|
+
try {
|
|
129
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
130
|
+
var _step2$value = _slicedToArray(_step2.value, 2),
|
|
131
|
+
element = _step2$value[0],
|
|
132
|
+
_step2$value$ = _step2$value[1],
|
|
133
|
+
key = _step2$value$.key,
|
|
134
|
+
paint = _step2$value$.paint;
|
|
135
|
+
element.setAttribute(key, paint);
|
|
136
|
+
}
|
|
137
|
+
} catch (err) {
|
|
138
|
+
_iterator2.e(err);
|
|
139
|
+
} finally {
|
|
140
|
+
_iterator2.f();
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
return {
|
|
144
|
+
update: function update() {
|
|
145
|
+
var elements = context.getScene().querySelectorAll('.element').filter(function (element) {
|
|
146
|
+
return !element.__removed__ && !element.getAttribute('annotationKind');
|
|
147
|
+
});
|
|
148
|
+
var live = new Set(elements);
|
|
149
|
+
var _iterator3 = _createForOfIteratorHelper(original.keys()),
|
|
150
|
+
_step3;
|
|
151
|
+
try {
|
|
152
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
153
|
+
var element = _step3.value;
|
|
154
|
+
if (!live.has(element)) original.delete(element);
|
|
155
|
+
}
|
|
156
|
+
} catch (err) {
|
|
157
|
+
_iterator3.e(err);
|
|
158
|
+
} finally {
|
|
159
|
+
_iterator3.f();
|
|
160
|
+
}
|
|
161
|
+
reset();
|
|
162
|
+
var coordinate = context.getCoordinate();
|
|
163
|
+
var pointAt = function pointAt(value) {
|
|
164
|
+
return coordinate.map([0.5, context.axisValue('y', value)]);
|
|
165
|
+
};
|
|
166
|
+
var _iterator4 = _createForOfIteratorHelper(elements),
|
|
167
|
+
_step4;
|
|
168
|
+
try {
|
|
169
|
+
var _loop2 = function _loop2() {
|
|
170
|
+
var element = _step4.value;
|
|
171
|
+
if (element.markType !== 'area' && element.markType !== 'line' && element.markType !== 'interval' && element.markType !== 'point') return 0; // continue
|
|
172
|
+
var rows = context.getSourceData(element);
|
|
173
|
+
var active = selections.filter(function (selection) {
|
|
174
|
+
return rows.every(function (row) {
|
|
175
|
+
return selection.rows.includes(row);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
if (!active.length) return 0; // continue
|
|
179
|
+
var first = active[0].annotation;
|
|
180
|
+
var a = pointAt(first.threshold);
|
|
181
|
+
var b = pointAt(first.threshold + Math.max(1, Math.abs(first.threshold)) * 1e-6);
|
|
182
|
+
var horizontal = Math.abs(b[0] - a[0]) > Math.abs(b[1] - a[1]);
|
|
183
|
+
var dimension = horizontal ? 0 : 1;
|
|
184
|
+
var increasing = b[dimension] > a[dimension];
|
|
185
|
+
// Coordinate direction may reverse after transposition or scale inversion.
|
|
186
|
+
var regions = active.map(function (_ref5) {
|
|
187
|
+
var _annotation$direction;
|
|
188
|
+
var annotation = _ref5.annotation,
|
|
189
|
+
color = _ref5.color;
|
|
190
|
+
return {
|
|
191
|
+
position: pointAt(annotation.threshold)[dimension],
|
|
192
|
+
inclusive: annotation.inclusive,
|
|
193
|
+
greater: ((_annotation$direction = annotation.direction) !== null && _annotation$direction !== void 0 ? _annotation$direction : 'above') === 'above' ? increasing : !increasing,
|
|
194
|
+
color: color
|
|
195
|
+
};
|
|
196
|
+
});
|
|
197
|
+
var key = element.markType === 'line' ? 'stroke' : 'fill';
|
|
198
|
+
if (!original.has(element)) original.set(element, {
|
|
199
|
+
key: key,
|
|
200
|
+
paint: element.getAttribute(key)
|
|
201
|
+
});
|
|
202
|
+
var base = original.get(element).paint;
|
|
203
|
+
var _element$getLocalBoun = element.getLocalBounds(),
|
|
204
|
+
min = _element$getLocalBoun.min,
|
|
205
|
+
max = _element$getLocalBoun.max;
|
|
206
|
+
var center = (min[dimension] + max[dimension]) / 2;
|
|
207
|
+
var paint = thresholdPaint(element.markType === 'area' ? 'transparent' : base, element.markType === 'point' ? center : min[dimension], element.markType === 'point' ? center : max[dimension], regions, horizontal);
|
|
208
|
+
if (element.markType === 'area') {
|
|
209
|
+
if (paint === 'transparent') return 0; // continue
|
|
210
|
+
var background = base.includes('gradient(') ? base : "linear-gradient(0deg, ".concat(base, " 0%, ").concat(base, " 100%)");
|
|
211
|
+
var region = paint.includes('gradient(') ? paint : "linear-gradient(0deg, ".concat(paint, " 0%, ").concat(paint, " 100%)");
|
|
212
|
+
// Native layered fills retain the theme gradient beneath a transparent region mask.
|
|
213
|
+
paint = "".concat(background, ", ").concat(region);
|
|
214
|
+
}
|
|
215
|
+
element.setAttribute(key, paint);
|
|
216
|
+
},
|
|
217
|
+
_ret;
|
|
218
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
219
|
+
_ret = _loop2();
|
|
220
|
+
if (_ret === 0) continue;
|
|
221
|
+
}
|
|
222
|
+
} catch (err) {
|
|
223
|
+
_iterator4.e(err);
|
|
224
|
+
} finally {
|
|
225
|
+
_iterator4.f();
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
cleanup: function cleanup() {
|
|
229
|
+
reset();
|
|
230
|
+
original.clear();
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
function getColor(annotation, _ref6) {
|
|
235
|
+
var _defaults$palette$fin, _ref7, _annotation$style$fil2, _annotation$style7, _annotation$style8;
|
|
236
|
+
var mapping = _ref6.mapping,
|
|
237
|
+
defaults = _ref6.defaults;
|
|
238
|
+
var seriesCount = mapping.series ? new Set(mapping.data.map(function (row) {
|
|
239
|
+
return row[mapping.series];
|
|
240
|
+
})).size : 1;
|
|
241
|
+
var used = new Set(defaults.palette.slice(0, seriesCount));
|
|
242
|
+
var accent = (_defaults$palette$fin = defaults.palette.find(function (color) {
|
|
243
|
+
return !used.has(color);
|
|
244
|
+
})) !== null && _defaults$palette$fin !== void 0 ? _defaults$palette$fin : defaults.labels.highlight.fill;
|
|
245
|
+
return (_ref7 = (_annotation$style$fil2 = (_annotation$style7 = annotation.style) === null || _annotation$style7 === void 0 ? void 0 : _annotation$style7.fill) !== null && _annotation$style$fil2 !== void 0 ? _annotation$style$fil2 : (_annotation$style8 = annotation.style) === null || _annotation$style8 === void 0 ? void 0 : _annotation$style8.stroke) !== null && _ref7 !== void 0 ? _ref7 : accent;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** Hard stops preserve the native path, including curves, gaps and stacked interval geometry. */
|
|
249
|
+
function thresholdPaint(base, min, max, regions, horizontal) {
|
|
250
|
+
var colorAt = function colorAt(position) {
|
|
251
|
+
var _regions$findLast$col, _regions$findLast;
|
|
252
|
+
return (_regions$findLast$col = (_regions$findLast = regions.findLast(function (region) {
|
|
253
|
+
var delta = position - region.position;
|
|
254
|
+
if (Math.abs(delta) < 1e-7) return region.inclusive;
|
|
255
|
+
return region.greater ? delta > 0 : delta < 0;
|
|
256
|
+
})) === null || _regions$findLast === void 0 ? void 0 : _regions$findLast.color) !== null && _regions$findLast$col !== void 0 ? _regions$findLast$col : base;
|
|
257
|
+
};
|
|
258
|
+
if (max <= min) return colorAt(min);
|
|
259
|
+
var stops = _toConsumableArray(new Set([min].concat(_toConsumableArray(regions.map(function (_ref8) {
|
|
260
|
+
var position = _ref8.position;
|
|
261
|
+
return position;
|
|
262
|
+
}).filter(function (p) {
|
|
263
|
+
return p > min + 1e-7 && p < max - 1e-7;
|
|
264
|
+
})), [max]))).sort(function (a, b) {
|
|
265
|
+
return a - b;
|
|
266
|
+
});
|
|
267
|
+
var colors = stops.slice(1).map(function (end, i) {
|
|
268
|
+
return colorAt((stops[i] + end) / 2);
|
|
269
|
+
});
|
|
270
|
+
if (colors.every(function (color) {
|
|
271
|
+
return color === colors[0];
|
|
272
|
+
})) return colors[0];
|
|
273
|
+
// AntV's gradient parser does not accept scientific notation at near-zero stops.
|
|
274
|
+
var percent = function percent(position) {
|
|
275
|
+
return ((position - min) / (max - min) * 100).toFixed(6);
|
|
276
|
+
};
|
|
277
|
+
var gradient = colors.flatMap(function (color, i) {
|
|
278
|
+
return ["".concat(color, " ").concat(percent(stops[i]), "%"), "".concat(color, " ").concat(percent(stops[i + 1]), "%")];
|
|
279
|
+
});
|
|
280
|
+
return "linear-gradient(".concat(horizontal ? 0 : 90, "deg, ").concat(gradient.join(', '), ")");
|
|
281
|
+
}
|
|
282
|
+
function selectThreshold(data, field, _ref9) {
|
|
283
|
+
var threshold = _ref9.threshold,
|
|
284
|
+
_ref9$direction = _ref9.direction,
|
|
285
|
+
direction = _ref9$direction === void 0 ? 'above' : _ref9$direction,
|
|
286
|
+
_ref9$inclusive = _ref9.inclusive,
|
|
287
|
+
inclusive = _ref9$inclusive === void 0 ? false : _ref9$inclusive;
|
|
288
|
+
if (!Number.isFinite(threshold)) throw new Error('Invalid annotation: threshold must be finite.');
|
|
289
|
+
if (direction !== 'above' && direction !== 'below') throw new Error('Invalid annotation: threshold direction must be above or below.');
|
|
290
|
+
return numericRows(data, field).filter(function (_ref10) {
|
|
291
|
+
var value = _ref10.value;
|
|
292
|
+
return inclusive && value === threshold || (direction === 'above' ? value > threshold : value < threshold);
|
|
293
|
+
}).map(function (_ref11) {
|
|
294
|
+
var row = _ref11.row;
|
|
295
|
+
return row;
|
|
296
|
+
});
|
|
297
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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 { axisPosition } from "../utils";
|
|
8
|
+
import { path } from "./path";
|
|
9
|
+
export var thresholdX = {
|
|
10
|
+
g2: function g2(annotations, _ref) {
|
|
11
|
+
var mapping = _ref.mapping;
|
|
12
|
+
return annotations.flatMap(function (annotation) {
|
|
13
|
+
var _annotation$label;
|
|
14
|
+
return path.create({
|
|
15
|
+
data: axisPosition(mapping.x, annotation.threshold),
|
|
16
|
+
label: (_annotation$label = annotation.label) !== null && _annotation$label !== void 0 ? _annotation$label : "Threshold: ".concat(annotation.threshold),
|
|
17
|
+
style: _objectSpread({
|
|
18
|
+
lineDash: [4, 4]
|
|
19
|
+
}, annotation.style)
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
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 { axisPosition, finiteValue } from "../utils";
|
|
8
|
+
import { path } from "./path";
|
|
9
|
+
export var thresholdY = {
|
|
10
|
+
g2: function g2(annotations, _ref) {
|
|
11
|
+
var mapping = _ref.mapping;
|
|
12
|
+
return annotations.flatMap(function (annotation) {
|
|
13
|
+
var _annotation$label;
|
|
14
|
+
finiteValue(annotation.threshold, 'threshold');
|
|
15
|
+
return path.create({
|
|
16
|
+
data: axisPosition(mapping.y, annotation.threshold),
|
|
17
|
+
label: (_annotation$label = annotation.label) !== null && _annotation$label !== void 0 ? _annotation$label : "Threshold: ".concat(annotation.threshold),
|
|
18
|
+
style: _objectSpread({
|
|
19
|
+
lineDash: [4, 4]
|
|
20
|
+
}, annotation.style)
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
};
|