@pie-lib/graphing 2.4.8 → 2.4.11
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/CHANGELOG.md +30 -0
- package/lib/axis/arrow.js +17 -13
- package/lib/axis/arrow.js.map +1 -1
- package/lib/axis/axes.js +57 -51
- package/lib/axis/axes.js.map +1 -1
- package/lib/axis/index.js +5 -1
- package/lib/axis/index.js.map +1 -1
- package/lib/bg.js +16 -14
- package/lib/bg.js.map +1 -1
- package/lib/container/index.js +21 -15
- package/lib/container/index.js.map +1 -1
- package/lib/coordinates-label.js +4 -4
- package/lib/coordinates-label.js.map +1 -1
- package/lib/graph-with-controls.js +29 -25
- package/lib/graph-with-controls.js.map +1 -1
- package/lib/graph.js +56 -42
- package/lib/graph.js.map +1 -1
- package/lib/grid.js +20 -14
- package/lib/grid.js.map +1 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/labels.js +28 -24
- package/lib/labels.js.map +1 -1
- package/lib/mark-label.js +16 -8
- package/lib/mark-label.js.map +1 -1
- package/lib/toggle-bar.js +18 -16
- package/lib/toggle-bar.js.map +1 -1
- package/lib/tool-menu.js +22 -16
- package/lib/tool-menu.js.map +1 -1
- package/lib/tools/circle/bg-circle.js +26 -18
- package/lib/tools/circle/bg-circle.js.map +1 -1
- package/lib/tools/circle/component.js +30 -28
- package/lib/tools/circle/component.js.map +1 -1
- package/lib/tools/circle/index.js +4 -4
- package/lib/tools/circle/index.js.map +1 -1
- package/lib/tools/index.js +16 -15
- package/lib/tools/index.js.map +1 -1
- package/lib/tools/line/component.js +12 -6
- package/lib/tools/line/component.js.map +1 -1
- package/lib/tools/parabola/component.js.map +1 -1
- package/lib/tools/parabola/index.js +4 -4
- package/lib/tools/parabola/index.js.map +1 -1
- package/lib/tools/point/component.js +21 -17
- package/lib/tools/point/component.js.map +1 -1
- package/lib/tools/point/index.js +2 -2
- package/lib/tools/polygon/component.js +55 -47
- package/lib/tools/polygon/component.js.map +1 -1
- package/lib/tools/polygon/index.js +12 -8
- package/lib/tools/polygon/index.js.map +1 -1
- package/lib/tools/polygon/line.js +26 -18
- package/lib/tools/polygon/line.js.map +1 -1
- package/lib/tools/polygon/polygon.js +26 -18
- package/lib/tools/polygon/polygon.js.map +1 -1
- package/lib/tools/ray/component.js +12 -6
- package/lib/tools/ray/component.js.map +1 -1
- package/lib/tools/segment/component.js +4 -2
- package/lib/tools/segment/component.js.map +1 -1
- package/lib/tools/shared/arrow-head.js +4 -4
- package/lib/tools/shared/arrow-head.js.map +1 -1
- package/lib/tools/shared/line/index.js +46 -44
- package/lib/tools/shared/line/index.js.map +1 -1
- package/lib/tools/shared/line/line-path.js +28 -20
- package/lib/tools/shared/line/line-path.js.map +1 -1
- package/lib/tools/shared/line/with-root-edge.js +8 -6
- package/lib/tools/shared/line/with-root-edge.js.map +1 -1
- package/lib/tools/shared/point/arrow-point.js +21 -15
- package/lib/tools/shared/point/arrow-point.js.map +1 -1
- package/lib/tools/shared/point/arrow.js +21 -15
- package/lib/tools/shared/point/arrow.js.map +1 -1
- package/lib/tools/shared/point/base-point.js +22 -16
- package/lib/tools/shared/point/base-point.js.map +1 -1
- package/lib/tools/shared/point/index.js +8 -4
- package/lib/tools/shared/point/index.js.map +1 -1
- package/lib/tools/shared/styles.js +1 -1
- package/lib/tools/shared/types.js +1 -1
- package/lib/tools/sine/component.js.map +1 -1
- package/lib/tools/sine/index.js +4 -4
- package/lib/tools/sine/index.js.map +1 -1
- package/lib/tools/vector/component.js +4 -2
- package/lib/tools/vector/component.js.map +1 -1
- package/lib/undo-redo.js +20 -16
- package/lib/undo-redo.js.map +1 -1
- package/lib/use-debounce.js +7 -3
- package/lib/use-debounce.js.map +1 -1
- package/lib/utils.js +68 -5
- package/lib/utils.js.map +1 -1
- package/package.json +4 -4
- package/src/axis/axes.jsx +1 -1
- package/src/graph.jsx +13 -6
- package/src/tools/line/component.jsx +0 -1
- package/src/utils.js +62 -4
package/lib/graph.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
|
-
exports
|
|
8
|
+
exports.removeBuildingToolIfCurrentToolDiffers = exports.graphPropTypes = exports["default"] = exports.Graph = void 0;
|
|
7
9
|
|
|
8
10
|
var _react = _interopRequireDefault(require("react"));
|
|
9
11
|
|
|
@@ -25,41 +27,51 @@ var _grid = _interopRequireDefault(require("./grid"));
|
|
|
25
27
|
|
|
26
28
|
var _bg = _interopRequireDefault(require("./bg"));
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
var _utils = require("./utils");
|
|
29
31
|
|
|
30
|
-
function
|
|
32
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
33
|
+
|
|
34
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
35
|
|
|
32
|
-
function
|
|
36
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
33
37
|
|
|
34
38
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
35
39
|
|
|
36
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
40
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
41
|
+
|
|
42
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
43
|
+
|
|
44
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
37
45
|
|
|
38
|
-
function
|
|
46
|
+
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."); }
|
|
39
47
|
|
|
40
|
-
function
|
|
48
|
+
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); }
|
|
41
49
|
|
|
42
|
-
function
|
|
50
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
43
51
|
|
|
44
|
-
function
|
|
52
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
45
53
|
|
|
46
|
-
function
|
|
54
|
+
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; }
|
|
47
55
|
|
|
48
56
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
49
57
|
|
|
50
58
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
51
59
|
|
|
52
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
60
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
53
61
|
|
|
54
|
-
function
|
|
62
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
55
63
|
|
|
56
|
-
function
|
|
64
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
65
|
+
|
|
66
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
67
|
+
|
|
68
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
57
69
|
|
|
58
70
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
59
71
|
|
|
60
|
-
function
|
|
72
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
61
73
|
|
|
62
|
-
function
|
|
74
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
63
75
|
|
|
64
76
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
65
77
|
|
|
@@ -116,14 +128,12 @@ var removeBuildingToolIfCurrentToolDiffers = function removeBuildingToolIfCurren
|
|
|
116
128
|
|
|
117
129
|
exports.removeBuildingToolIfCurrentToolDiffers = removeBuildingToolIfCurrentToolDiffers;
|
|
118
130
|
|
|
119
|
-
var Graph =
|
|
120
|
-
/*#__PURE__*/
|
|
121
|
-
function (_React$Component) {
|
|
131
|
+
var Graph = /*#__PURE__*/function (_React$Component) {
|
|
122
132
|
_inherits(Graph, _React$Component);
|
|
123
133
|
|
|
124
|
-
|
|
125
|
-
var _getPrototypeOf2;
|
|
134
|
+
var _super = _createSuper(Graph);
|
|
126
135
|
|
|
136
|
+
function Graph() {
|
|
127
137
|
var _this;
|
|
128
138
|
|
|
129
139
|
_classCallCheck(this, Graph);
|
|
@@ -132,7 +142,7 @@ function (_React$Component) {
|
|
|
132
142
|
args[_key] = arguments[_key];
|
|
133
143
|
}
|
|
134
144
|
|
|
135
|
-
_this =
|
|
145
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
136
146
|
|
|
137
147
|
_defineProperty(_assertThisInitialized(_this), "state", {});
|
|
138
148
|
|
|
@@ -151,7 +161,7 @@ function (_React$Component) {
|
|
|
151
161
|
return (0, _isEqual["default"])(m, oldMark);
|
|
152
162
|
});
|
|
153
163
|
|
|
154
|
-
if (index >= 0) {
|
|
164
|
+
if (index >= 0 && !(0, _utils.isDuplicatedMark)(newMark, marks, oldMark)) {
|
|
155
165
|
newMarks.splice(index, 1, newMark);
|
|
156
166
|
onChangeMarks(newMarks);
|
|
157
167
|
}
|
|
@@ -176,6 +186,11 @@ function (_React$Component) {
|
|
|
176
186
|
onChangeMarks = _this$props3.onChangeMarks,
|
|
177
187
|
marks = _this$props3.marks;
|
|
178
188
|
var newMarks = (0, _cloneDeep["default"])(marks);
|
|
189
|
+
|
|
190
|
+
if (!update.building && (0, _utils.isDuplicatedMark)(update, marks)) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
179
194
|
var index = newMarks.findIndex(function (m) {
|
|
180
195
|
return (0, _isEqual["default"])(m, existing);
|
|
181
196
|
});
|
|
@@ -196,16 +211,16 @@ function (_React$Component) {
|
|
|
196
211
|
return tool && tool.Component || null;
|
|
197
212
|
});
|
|
198
213
|
|
|
199
|
-
_defineProperty(_assertThisInitialized(_this), "onBgClick", function (
|
|
200
|
-
var x =
|
|
201
|
-
y =
|
|
202
|
-
log('[onBgClick] x,y: ', x, y);
|
|
214
|
+
_defineProperty(_assertThisInitialized(_this), "onBgClick", function (point) {
|
|
215
|
+
var x = point.x,
|
|
216
|
+
y = point.y;
|
|
203
217
|
var _this$props4 = _this.props,
|
|
204
218
|
labelModeEnabled = _this$props4.labelModeEnabled,
|
|
205
219
|
currentTool = _this$props4.currentTool,
|
|
206
220
|
marks = _this$props4.marks;
|
|
221
|
+
log('[onBgClick] x,y: ', x, y);
|
|
207
222
|
|
|
208
|
-
if (labelModeEnabled || !currentTool
|
|
223
|
+
if (labelModeEnabled || !currentTool) {
|
|
209
224
|
return;
|
|
210
225
|
}
|
|
211
226
|
|
|
@@ -261,53 +276,52 @@ function (_React$Component) {
|
|
|
261
276
|
marks: marks || [],
|
|
262
277
|
currentTool: currentTool
|
|
263
278
|
});
|
|
264
|
-
return _react["default"].createElement(_plot.Root // left side requires an extra padding of 10, in order to fit next to tick labels like 1.5, 1.55...
|
|
279
|
+
return /*#__PURE__*/_react["default"].createElement(_plot.Root // left side requires an extra padding of 10, in order to fit next to tick labels like 1.5, 1.55...
|
|
265
280
|
, _extends({
|
|
266
281
|
paddingLeft: 60,
|
|
267
282
|
rootRef: function rootRef(r) {
|
|
268
283
|
return _this2.rootNode = r;
|
|
269
284
|
},
|
|
270
285
|
title: title
|
|
271
|
-
}, common), _react["default"].createElement(_grid["default"], common), _react["default"].createElement(_axis.Axes, _extends({}, axesSettings, common)), _react["default"].createElement(_bg["default"], _extends({}, size, {
|
|
286
|
+
}, common), /*#__PURE__*/_react["default"].createElement(_grid["default"], common), /*#__PURE__*/_react["default"].createElement(_axis.Axes, _extends({}, axesSettings, common)), /*#__PURE__*/_react["default"].createElement(_bg["default"], _extends({}, size, {
|
|
272
287
|
onClick: this.onBgClick
|
|
273
|
-
}, common)), _react["default"].createElement(_labels["default"], _extends({
|
|
288
|
+
}, common)), /*#__PURE__*/_react["default"].createElement(_labels["default"], _extends({
|
|
274
289
|
value: labels
|
|
275
|
-
}, common)), _react["default"].createElement("mask", {
|
|
290
|
+
}, common)), /*#__PURE__*/_react["default"].createElement("mask", {
|
|
276
291
|
id: "myMask"
|
|
277
|
-
}, _react["default"].createElement("rect", _extends({}, maskSize, {
|
|
292
|
+
}, /*#__PURE__*/_react["default"].createElement("rect", _extends({}, maskSize, {
|
|
278
293
|
fill: "white"
|
|
279
|
-
})), " "), _react["default"].createElement("g", {
|
|
294
|
+
})), " "), /*#__PURE__*/_react["default"].createElement("g", {
|
|
280
295
|
id: "marks",
|
|
281
296
|
mask: "url('#myMask')"
|
|
282
297
|
}, (backgroundMarks || []).map(function (m, index) {
|
|
283
298
|
var Component = _this2.getComponent(m);
|
|
284
299
|
|
|
285
300
|
var markType = m.type;
|
|
286
|
-
return _react["default"].createElement(Component, _extends({
|
|
301
|
+
return /*#__PURE__*/_react["default"].createElement(Component, _extends({
|
|
287
302
|
key: "".concat(markType, "-").concat(index, "-bg"),
|
|
288
|
-
mark: _objectSpread({}, m, {
|
|
303
|
+
mark: _objectSpread(_objectSpread({}, m), {}, {
|
|
289
304
|
disabled: true
|
|
290
|
-
})
|
|
305
|
+
}),
|
|
306
|
+
labelNode: _this2.state.labelNode
|
|
291
307
|
}, common));
|
|
292
308
|
}), marks.map(function (m, index) {
|
|
293
309
|
var Component = _this2.getComponent(m);
|
|
294
310
|
|
|
295
311
|
var markType = m.type;
|
|
296
|
-
return _react["default"].createElement(Component, _extends({
|
|
312
|
+
return /*#__PURE__*/_react["default"].createElement(Component, _extends({
|
|
297
313
|
key: "".concat(markType, "-").concat(index),
|
|
298
314
|
mark: m,
|
|
299
315
|
coordinatesOnHover: coordinatesOnHover,
|
|
300
316
|
onChange: _this2.changeMark,
|
|
301
317
|
onComplete: _this2.completeMark,
|
|
302
|
-
onClick:
|
|
303
|
-
return _this2.onBgClick(point, m);
|
|
304
|
-
},
|
|
318
|
+
onClick: _this2.onBgClick,
|
|
305
319
|
onDragStart: _this2.startDrag,
|
|
306
320
|
onDragStop: _this2.stopDrag,
|
|
307
321
|
labelNode: _this2.state.labelNode,
|
|
308
322
|
isToolActive: currentTool && markType === currentTool.type
|
|
309
323
|
}, common));
|
|
310
|
-
}), _react["default"].createElement("foreignObject", _extends({
|
|
324
|
+
}), /*#__PURE__*/_react["default"].createElement("foreignObject", _extends({
|
|
311
325
|
ref: function ref(labelNode) {
|
|
312
326
|
return _this2.labelNode = labelNode;
|
|
313
327
|
},
|
|
@@ -326,7 +340,7 @@ function (_React$Component) {
|
|
|
326
340
|
|
|
327
341
|
exports.Graph = Graph;
|
|
328
342
|
|
|
329
|
-
_defineProperty(Graph, "propTypes", _objectSpread({}, graphPropTypes, {
|
|
343
|
+
_defineProperty(Graph, "propTypes", _objectSpread(_objectSpread({}, graphPropTypes), {}, {
|
|
330
344
|
currentTool: _propTypes["default"].object
|
|
331
345
|
}));
|
|
332
346
|
|
package/lib/graph.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph.jsx"],"names":["log","graphPropTypes","axesSettings","PropTypes","shape","AxisPropTypes","backgroundMarks","array","className","string","domain","types","DomainType","labels","LabelType","labelModeEnabled","bool","coordinatesOnHover","marks","onChangeMarks","func","range","size","width","number","isRequired","height","title","tools","getMaskSize","x","y","removeBuildingToolIfCurrentToolDiffers","currentTool","buildingMark","filter","m","building","newMarks","type","index","findIndex","splice","Graph","setState","labelNode","oldMark","newMark","props","markData","updatedMark","complete","updateMarks","existing","update","addIfMissing","mark","tool","find","t","Component","addPoint","undefined","graphProps","rootNode","maskSize","common","r","onBgClick","map","getComponent","markType","disabled","changeMark","completeMark","point","startDrag","stopD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ACP,SAAL,CAAeO,KAAf,EAAsBvC,CAAtB,CAAJ;AAAA,WANhB;AAOE,UAAA,WAAW,EAAE,MAAI,CAACwC,SAPpB;AAQE,UAAA,UAAU,EAAE,MAAI,CAACC,QARnB;AASE,UAAA,SAAS,EAAE,MAAI,CAACC,KAAL,CAAWjC,SATxB;AAUE,UAAA,YAAY,EAAEZ,WAAW,IAAIsC,QAAQ,KAAKtC,WAAW,CAACM;AAVxD,WAWM2B,MAXN,EADF;AAeD,OAnBA,CAdH,EAmCE;AACE,QAAA,GAAG,EAAE,aAAArB,SAAS;AAAA,iBAAK,MAAI,CAACA,SAAL,GAAiBA,SAAtB;AAAA,SADhB;AAEE,QAAA,CAAC,EAAC,GAFJ;AAGE,QAAA,CAAC,EAAC;AAHJ,SAIMvB,IAJN;AAKE,QAAA,KAAK,EAAE;AAAEyD,UAAAA,aAAa,EAAE;AAAjB;AALT,SAnCF,CAfF,CADF;AA6DD;;;;EArKwBC,kBAAMpB,S;;;;gBAApBjB,K,iCAEN1C,c;AACHgC,EAAAA,WAAW,EAAE9B,sBAAU8E;;;gBAHdtC,K,kBAMW;AACpBxB,EAAAA,aAAa,EAAE,yBAAM,CAAE;AADH,C;;eAkKTwB,K","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport isEqual from 'lodash/isEqual';\nimport cloneDeep from 'lodash/cloneDeep';\nimport { Root, types, createGraphProps } from '@pie-lib/plot';\nimport debug from 'debug';\n\nimport Labels from './labels';\nimport { Axes, AxisPropTypes } from './axis';\nimport Grid from './grid';\nimport { LabelType } from './labels';\nimport Bg from './bg';\n\nconst log = debug('pie-lib:graphing:graph');\n\nexport const graphPropTypes = {\n axesSettings: PropTypes.shape(AxisPropTypes),\n backgroundMarks: PropTypes.array,\n className: PropTypes.string,\n domain: types.DomainType,\n labels: PropTypes.shape(LabelType),\n labelModeEnabled: PropTypes.bool,\n coordinatesOnHover: PropTypes.bool,\n marks: PropTypes.array,\n onChangeMarks: PropTypes.func,\n range: types.DomainType,\n size: PropTypes.shape({\n width: PropTypes.number.isRequired,\n height: PropTypes.number.isRequired\n }),\n title: PropTypes.string,\n tools: PropTypes.array\n};\n\nconst getMaskSize = size => ({\n x: -23,\n y: -23,\n width: size.width + 46,\n height: size.height + 46\n});\n\nexport const removeBuildingToolIfCurrentToolDiffers = ({ marks, currentTool }) => {\n const buildingMark = marks.filter(m => m.building)[0];\n let newMarks = cloneDeep(marks);\n\n if (buildingMark && currentTool && buildingMark.type !== currentTool.type) {\n const index = newMarks.findIndex(m => isEqual(m, buildingMark));\n\n if (index >= 0) {\n newMarks.splice(index, 1);\n }\n }\n\n return newMarks;\n};\n\nexport class Graph extends React.Component {\n static propTypes = {\n ...graphPropTypes,\n currentTool: PropTypes.object\n };\n\n static defaultProps = {\n onChangeMarks: () => {}\n };\n\n state = {};\n\n componentDidMount = () => this.setState({ labelNode: this.labelNode });\n\n changeMark = (oldMark, newMark) => {\n const { onChangeMarks, marks } = this.props;\n let newMarks = cloneDeep(marks);\n\n const index = newMarks.findIndex(m => isEqual(m, oldMark));\n\n if (index >= 0) {\n newMarks.splice(index, 1, newMark);\n\n onChangeMarks(newMarks);\n }\n };\n\n completeMark = markData => {\n const { currentTool, marks } = this.props;\n const buildingMark = marks.filter(m => m.building)[0];\n\n if (!buildingMark || !currentTool) return;\n\n const updatedMark = currentTool.complete(buildingMark, markData);\n\n this.updateMarks(buildingMark, updatedMark);\n };\n\n updateMarks = (existing, update, addIfMissing = false) => {\n const { onChangeMarks, marks } = this.props;\n let newMarks = cloneDeep(marks);\n\n const index = newMarks.findIndex(m => isEqual(m, existing));\n\n if (index >= 0) {\n newMarks.splice(index, 1, update);\n\n onChangeMarks(newMarks);\n } else if (addIfMissing) {\n onChangeMarks([...newMarks, update]);\n }\n };\n\n getComponent = mark => {\n if (!mark) return null;\n\n const tool = (this.props.tools || []).find(t => t.type === mark.type);\n\n return (tool && tool.Component) || null;\n };\n\n onBgClick = ({ x, y }, mark) => {\n log('[onBgClick] x,y: ', x, y);\n\n const { labelModeEnabled, currentTool, marks } = this.props;\n\n if (labelModeEnabled || !currentTool || mark) {\n return;\n }\n\n const buildingMark = marks.filter(m => m.building)[0];\n let updatedMark;\n\n // if the building mark has a different type, we just replace it\n if (buildingMark && currentTool && buildingMark.type === currentTool.type) {\n updatedMark = currentTool.addPoint({ x, y }, { ...buildingMark });\n } else {\n updatedMark = currentTool.addPoint({ x, y }, undefined);\n }\n\n this.updateMarks(buildingMark, updatedMark, true);\n };\n\n render() {\n const {\n axesSettings,\n currentTool,\n coordinatesOnHover,\n size,\n domain,\n backgroundMarks,\n range,\n title,\n labels,\n labelModeEnabled\n } = this.props;\n let { marks } = this.props;\n\n const graphProps = createGraphProps(domain, range, size, () => this.rootNode);\n const maskSize = getMaskSize(size);\n const common = { graphProps, labelModeEnabled };\n\n marks = removeBuildingToolIfCurrentToolDiffers({ marks: marks || [], currentTool });\n\n return (\n <Root\n // left side requires an extra padding of 10, in order to fit next to tick labels like 1.5, 1.55...\n paddingLeft={60}\n rootRef={r => (this.rootNode = r)}\n title={title}\n {...common}\n >\n <Grid {...common} />\n <Axes {...axesSettings} {...common} />\n <Bg {...size} onClick={this.onBgClick} {...common} />\n <Labels value={labels} {...common} />\n <mask id=\"myMask\">\n <rect {...maskSize} fill=\"white\" /> {/* TODO hardcoded color */}\n </mask>\n\n <g id=\"marks\" mask=\"url('#myMask')\">\n {(backgroundMarks || []).map((m, index) => {\n const Component = this.getComponent(m);\n const markType = m.type;\n\n return (\n <Component\n key={`${markType}-${index}-bg`}\n mark={{ ...m, disabled: true }}\n {...common}\n />\n );\n })}\n\n {marks.map((m, index) => {\n const Component = this.getComponent(m);\n const markType = m.type;\n\n return (\n <Component\n key={`${markType}-${index}`}\n mark={m}\n coordinatesOnHover={coordinatesOnHover}\n onChange={this.changeMark}\n onComplete={this.completeMark}\n onClick={point => this.onBgClick(point, m)}\n onDragStart={this.startDrag}\n onDragStop={this.stopDrag}\n labelNode={this.state.labelNode}\n isToolActive={currentTool && markType === currentTool.type}\n {...common}\n />\n );\n })}\n\n <foreignObject\n ref={labelNode => (this.labelNode = labelNode)}\n x=\"0\"\n y=\"0\"\n {...size}\n style={{ pointerEvents: 'none' }}\n />\n </g>\n </Root>\n );\n }\n}\n\nexport default Graph;\n"],"file":"graph.js"}
|
|
1
|
+
{"version":3,"sources":["../src/graph.jsx"],"names":["log","graphPropTypes","axesSettings","PropTypes","shape","AxisPropTypes","backgroundMarks","array","className","string","domain","types","DomainType","labels","LabelType","labelModeEnabled","bool","coordinatesOnHover","marks","onChangeMarks","func","range","size","width","number","isRequired","height","title","tools","getMaskSize","x","y","removeBuildingToolIfCurrentToolDiffers","currentTool","buildingMark","filter","m","building","newMarks","type","index","findIndex","splice","Graph","setState","labelNode","oldMark","newMark","props","markData","updatedMark","complete","updateMarks","existing","update","addIfMissing","mark","tool","find","t","Component","point","addPoint","undefined","graphProps","rootNode","maskSize","common","r","onBgClick","map","getComponent","markType","disabled","state","changeMark","completeMark","startDrag","stopDrag","pointerEvents","React","object"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,wBAAN,CAAZ;AAEO,IAAMC,cAAc,GAAG;AAC5BC,EAAAA,YAAY,EAAEC,sBAAUC,KAAV,CAAgBC,mBAAhB,CADc;AAE5BC,EAAAA,eAAe,EAAEH,sBAAUI,KAFC;AAG5BC,EAAAA,SAAS,EAAEL,sBAAUM,MAHO;AAI5BC,EAAAA,MAAM,EAAEC,YAAMC,UAJc;AAK5BC,EAAAA,MAAM,EAAEV,sBAAUC,KAAV,CAAgBU,iBAAhB,CALoB;AAM5BC,EAAAA,gBAAgB,EAAEZ,sBAAUa,IANA;AAO5BC,EAAAA,kBAAkB,EAAEd,sBAAUa,IAPF;AAQ5BE,EAAAA,KAAK,E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AI,CAACA,SAAL,GAAiBA,SAAtB;AAAA,SADhB;AAEE,QAAA,CAAC,EAAC,GAFJ;AAGE,QAAA,CAAC,EAAC;AAHJ,SAIMvB,IAJN;AAKE,QAAA,KAAK,EAAE;AAAEyD,UAAAA,aAAa,EAAE;AAAjB;AALT,SApCF,CAfF,CADF;AA8DD;;;;EA3KwBC,kBAAMpB,S;;;;gBAApBjB,K,+CAEN1C,c;AACHgC,EAAAA,WAAW,EAAE9B,sBAAU8E;;;gBAHdtC,K,kBAMW;AACpBxB,EAAAA,aAAa,EAAE,yBAAM,CAAE;AADH,C;;eAwKTwB,K","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport isEqual from 'lodash/isEqual';\nimport cloneDeep from 'lodash/cloneDeep';\nimport { Root, types, createGraphProps } from '@pie-lib/plot';\nimport debug from 'debug';\n\nimport Labels from './labels';\nimport { Axes, AxisPropTypes } from './axis';\nimport Grid from './grid';\nimport { LabelType } from './labels';\nimport Bg from './bg';\nimport { isDuplicatedMark } from './utils';\n\nconst log = debug('pie-lib:graphing:graph');\n\nexport const graphPropTypes = {\n axesSettings: PropTypes.shape(AxisPropTypes),\n backgroundMarks: PropTypes.array,\n className: PropTypes.string,\n domain: types.DomainType,\n labels: PropTypes.shape(LabelType),\n labelModeEnabled: PropTypes.bool,\n coordinatesOnHover: PropTypes.bool,\n marks: PropTypes.array,\n onChangeMarks: PropTypes.func,\n range: types.DomainType,\n size: PropTypes.shape({\n width: PropTypes.number.isRequired,\n height: PropTypes.number.isRequired\n }),\n title: PropTypes.string,\n tools: PropTypes.array\n};\n\nconst getMaskSize = size => ({\n x: -23,\n y: -23,\n width: size.width + 46,\n height: size.height + 46\n});\n\nexport const removeBuildingToolIfCurrentToolDiffers = ({ marks, currentTool }) => {\n const buildingMark = marks.filter(m => m.building)[0];\n let newMarks = cloneDeep(marks);\n\n if (buildingMark && currentTool && buildingMark.type !== currentTool.type) {\n const index = newMarks.findIndex(m => isEqual(m, buildingMark));\n\n if (index >= 0) {\n newMarks.splice(index, 1);\n }\n }\n\n return newMarks;\n};\n\nexport class Graph extends React.Component {\n static propTypes = {\n ...graphPropTypes,\n currentTool: PropTypes.object\n };\n\n static defaultProps = {\n onChangeMarks: () => {}\n };\n\n state = {};\n\n componentDidMount = () => this.setState({ labelNode: this.labelNode });\n\n changeMark = (oldMark, newMark) => {\n const { onChangeMarks, marks } = this.props;\n let newMarks = cloneDeep(marks);\n\n const index = newMarks.findIndex(m => isEqual(m, oldMark));\n\n if (index >= 0 && !isDuplicatedMark(newMark, marks, oldMark)) {\n newMarks.splice(index, 1, newMark);\n\n onChangeMarks(newMarks);\n }\n };\n\n completeMark = markData => {\n const { currentTool, marks } = this.props;\n const buildingMark = marks.filter(m => m.building)[0];\n\n if (!buildingMark || !currentTool) return;\n\n const updatedMark = currentTool.complete(buildingMark, markData);\n\n this.updateMarks(buildingMark, updatedMark);\n };\n\n updateMarks = (existing, update, addIfMissing = false) => {\n const { onChangeMarks, marks } = this.props;\n let newMarks = cloneDeep(marks);\n\n if (!update.building && isDuplicatedMark(update, marks)) {\n return;\n }\n\n const index = newMarks.findIndex(m => isEqual(m, existing));\n\n if (index >= 0) {\n newMarks.splice(index, 1, update);\n\n onChangeMarks(newMarks);\n } else if (addIfMissing) {\n onChangeMarks([...newMarks, update]);\n }\n };\n\n getComponent = mark => {\n if (!mark) return null;\n\n const tool = (this.props.tools || []).find(t => t.type === mark.type);\n\n return (tool && tool.Component) || null;\n };\n\n onBgClick = point => {\n const { x, y } = point;\n const { labelModeEnabled, currentTool, marks } = this.props;\n\n log('[onBgClick] x,y: ', x, y);\n\n if (labelModeEnabled || !currentTool) {\n return;\n }\n\n const buildingMark = marks.filter(m => m.building)[0];\n let updatedMark;\n\n // if the building mark has a different type, we just replace it\n if (buildingMark && currentTool && buildingMark.type === currentTool.type) {\n updatedMark = currentTool.addPoint({ x, y }, { ...buildingMark });\n } else {\n updatedMark = currentTool.addPoint({ x, y }, undefined);\n }\n\n this.updateMarks(buildingMark, updatedMark, true);\n };\n\n render() {\n const {\n axesSettings,\n currentTool,\n coordinatesOnHover,\n size,\n domain,\n backgroundMarks,\n range,\n title,\n labels,\n labelModeEnabled\n } = this.props;\n let { marks } = this.props;\n\n const graphProps = createGraphProps(domain, range, size, () => this.rootNode);\n const maskSize = getMaskSize(size);\n const common = { graphProps, labelModeEnabled };\n\n marks = removeBuildingToolIfCurrentToolDiffers({ marks: marks || [], currentTool });\n\n return (\n <Root\n // left side requires an extra padding of 10, in order to fit next to tick labels like 1.5, 1.55...\n paddingLeft={60}\n rootRef={r => (this.rootNode = r)}\n title={title}\n {...common}\n >\n <Grid {...common} />\n <Axes {...axesSettings} {...common} />\n <Bg {...size} onClick={this.onBgClick} {...common} />\n <Labels value={labels} {...common} />\n <mask id=\"myMask\">\n <rect {...maskSize} fill=\"white\" /> {/* TODO hardcoded color */}\n </mask>\n\n <g id=\"marks\" mask=\"url('#myMask')\">\n {(backgroundMarks || []).map((m, index) => {\n const Component = this.getComponent(m);\n const markType = m.type;\n\n return (\n <Component\n key={`${markType}-${index}-bg`}\n mark={{ ...m, disabled: true }}\n labelNode={this.state.labelNode}\n {...common}\n />\n );\n })}\n\n {marks.map((m, index) => {\n const Component = this.getComponent(m);\n const markType = m.type;\n\n return (\n <Component\n key={`${markType}-${index}`}\n mark={m}\n coordinatesOnHover={coordinatesOnHover}\n onChange={this.changeMark}\n onComplete={this.completeMark}\n onClick={this.onBgClick}\n onDragStart={this.startDrag}\n onDragStop={this.stopDrag}\n labelNode={this.state.labelNode}\n isToolActive={currentTool && markType === currentTool.type}\n {...common}\n />\n );\n })}\n\n <foreignObject\n ref={labelNode => (this.labelNode = labelNode)}\n x=\"0\"\n y=\"0\"\n {...size}\n style={{ pointerEvents: 'none' }}\n />\n </g>\n </Root>\n );\n }\n}\n\nexport default Graph;\n"],"file":"graph.js"}
|
package/lib/grid.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -17,39 +19,43 @@ var _styles = require("@material-ui/core/styles");
|
|
|
17
19
|
|
|
18
20
|
var _utils = require("./utils");
|
|
19
21
|
|
|
20
|
-
function
|
|
22
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
23
|
|
|
22
|
-
function
|
|
24
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
25
|
|
|
24
|
-
function
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
27
|
|
|
26
28
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
27
29
|
|
|
28
30
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
29
31
|
|
|
30
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
32
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
31
33
|
|
|
32
|
-
function
|
|
34
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
33
35
|
|
|
34
|
-
function
|
|
36
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
35
37
|
|
|
36
|
-
function
|
|
38
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
37
39
|
|
|
38
|
-
function
|
|
40
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
39
41
|
|
|
40
|
-
function
|
|
42
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
43
|
+
|
|
44
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
45
|
+
|
|
46
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
41
47
|
|
|
42
48
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
43
49
|
|
|
44
|
-
var Grid =
|
|
45
|
-
/*#__PURE__*/
|
|
46
|
-
function (_React$Component) {
|
|
50
|
+
var Grid = /*#__PURE__*/function (_React$Component) {
|
|
47
51
|
_inherits(Grid, _React$Component);
|
|
48
52
|
|
|
53
|
+
var _super = _createSuper(Grid);
|
|
54
|
+
|
|
49
55
|
function Grid() {
|
|
50
56
|
_classCallCheck(this, Grid);
|
|
51
57
|
|
|
52
|
-
return
|
|
58
|
+
return _super.apply(this, arguments);
|
|
53
59
|
}
|
|
54
60
|
|
|
55
61
|
_createClass(Grid, [{
|
|
@@ -73,7 +79,7 @@ function (_React$Component) {
|
|
|
73
79
|
range = graphProps.range;
|
|
74
80
|
var rowTickValues = (0, _utils.getTickValues)(range);
|
|
75
81
|
var columnTicksValues = (0, _utils.getTickValues)(domain);
|
|
76
|
-
return _react["default"].createElement(vx.Grid, {
|
|
82
|
+
return /*#__PURE__*/_react["default"].createElement(vx.Grid, {
|
|
77
83
|
innerRef: function innerRef(r) {
|
|
78
84
|
return _this.grid = r;
|
|
79
85
|
},
|
package/lib/grid.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/grid.jsx"],"names":["Grid","nextProps","graphProps","props","nextGraphProps","utils","isDomainRangeEqual","classes","scale","size","domain","range","rowTickValues","columnTicksValues","r","grid","x","y","width","height","React","Component","disabled","PropTypes","bool","object","isRequired","types","GraphPropsType","stroke"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/grid.jsx"],"names":["Grid","nextProps","graphProps","props","nextGraphProps","utils","isDomainRangeEqual","classes","scale","size","domain","range","rowTickValues","columnTicksValues","r","grid","x","y","width","height","React","Component","disabled","PropTypes","bool","object","isRequired","types","GraphPropsType","stroke"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEaA,I;;;;;;;;;;;;;WAOX,+BAAsBC,SAAtB,EAAiC;AAC/B,UAAQC,UAAR,GAAuB,KAAKC,KAA5B,CAAQD,UAAR;AACA,UAAoBE,cAApB,GAAuCH,SAAvC,CAAQC,UAAR;AACA,aAAO,CAACG,YAAMC,kBAAN,CAAyBJ,UAAzB,EAAqCE,cAArC,CAAR;AACD;;;WAED,kBAAS;AAAA;;AACP,wBAAgC,KAAKD,KAArC;AAAA,UAAQI,OAAR,eAAQA,OAAR;AAAA,UAAiBL,UAAjB,eAAiBA,UAAjB;AACA,UAAQM,KAAR,GAAuCN,UAAvC,CAAQM,KAAR;AAAA,UAAeC,IAAf,GAAuCP,UAAvC,CAAeO,IAAf;AAAA,UAAqBC,MAArB,GAAuCR,UAAvC,CAAqBQ,MAArB;AAAA,UAA6BC,KAA7B,GAAuCT,UAAvC,CAA6BS,KAA7B;AACA,UAAMC,aAAa,GAAG,0BAAcD,KAAd,CAAtB;AACA,UAAME,iBAAiB,GAAG,0BAAcH,MAAd,CAA1B;AAEA,0BACE,gCAAC,EAAD,CAAI,IAAJ;AACE,QAAA,QAAQ,EAAE,kBAAAI,CAAC;AAAA,iBAAK,KAAI,CAACC,IAAL,GAAYD,CAAjB;AAAA,SADb;AAEE,QAAA,MAAM,EAAEN,KAAK,CAACQ,CAFhB;AAGE,QAAA,MAAM,EAAER,KAAK,CAACS,CAHhB;AAIE,QAAA,KAAK,EAAER,IAAI,CAACS,KAJd;AAKE,QAAA,MAAM,EAAET,IAAI,CAACU,MALf;AAME,QAAA,SAAS,EAAEZ,OAAO,CAACQ,IANrB;AAOE,QAAA,aAAa,EAAEH,aAPjB;AAQE,QAAA,gBAAgB,EAAEC;AARpB,QADF;AAYD;;;;EA/BuBO,kBAAMC,S;;;;gBAAnBrB,I,eACQ;AACjBsB,EAAAA,QAAQ,EAAEC,sBAAUC,IADH;AAEjBjB,EAAAA,OAAO,EAAEgB,sBAAUE,MAAV,CAAiBC,UAFT;AAGjBxB,EAAAA,UAAU,EAAEyB,YAAMC,cAAN,CAAqBF;AAHhB,C;;eAiCN,wBAAW;AAAA,SAAO;AAC/BX,IAAAA,IAAI,EAAE;AACJc,MAAAA,MAAM,EAAE,QADJ,CACa;;AADb;AADyB,GAAP;AAAA,CAAX,EAIX7B,IAJW,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport * as vx from '@vx/grid';\nimport { types, utils } from '@pie-lib/plot';\nimport { withStyles } from '@material-ui/core/styles';\nimport { getTickValues } from './utils';\n\nexport class Grid extends React.Component {\n static propTypes = {\n disabled: PropTypes.bool,\n classes: PropTypes.object.isRequired,\n graphProps: types.GraphPropsType.isRequired\n };\n\n shouldComponentUpdate(nextProps) {\n const { graphProps } = this.props;\n const { graphProps: nextGraphProps } = nextProps;\n return !utils.isDomainRangeEqual(graphProps, nextGraphProps);\n }\n\n render() {\n const { classes, graphProps } = this.props;\n const { scale, size, domain, range } = graphProps;\n const rowTickValues = getTickValues(range);\n const columnTicksValues = getTickValues(domain);\n\n return (\n <vx.Grid\n innerRef={r => (this.grid = r)}\n xScale={scale.x}\n yScale={scale.y}\n width={size.width}\n height={size.height}\n className={classes.grid}\n rowTickValues={rowTickValues}\n columnTickValues={columnTicksValues}\n />\n );\n }\n}\n\nexport default withStyles(() => ({\n grid: {\n stroke: 'purple' // TODO hardcoded color\n }\n}))(Grid);\n"],"file":"grid.js"}
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -33,7 +35,9 @@ exports.tools = tools;
|
|
|
33
35
|
|
|
34
36
|
var _toolMenu = _interopRequireDefault(require("./tool-menu"));
|
|
35
37
|
|
|
36
|
-
function
|
|
38
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
39
|
+
|
|
40
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
37
41
|
|
|
38
42
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
39
43
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;;;AACA","sourcesContent":["import Graph from './graph';\nimport GraphContainer from './container';\nimport * as tools from './tools';\nimport ToolMenu from './tool-menu';\n\nexport { Graph, GraphContainer, ToolMenu, tools };\n"],"file":"index.js"}
|
package/lib/labels.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
|
-
exports["default"] = exports.Labels = exports.LabelType =
|
|
8
|
+
exports.getTransform = exports["default"] = exports.Labels = exports.LabelType = void 0;
|
|
7
9
|
|
|
8
10
|
var _react = _interopRequireDefault(require("react"));
|
|
9
11
|
|
|
@@ -17,23 +19,25 @@ var _renderUi = require("@pie-lib/render-ui");
|
|
|
17
19
|
|
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
21
|
|
|
20
|
-
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
21
|
-
|
|
22
22
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
23
23
|
|
|
24
24
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
25
25
|
|
|
26
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
26
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
27
27
|
|
|
28
|
-
function
|
|
28
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
29
29
|
|
|
30
|
-
function
|
|
30
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
31
31
|
|
|
32
|
-
function
|
|
32
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
33
33
|
|
|
34
|
-
function
|
|
34
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
35
35
|
|
|
36
|
-
function
|
|
36
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
37
|
+
|
|
38
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
39
|
+
|
|
40
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
37
41
|
|
|
38
42
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
39
43
|
|
|
@@ -84,15 +88,15 @@ var getY = function getY(side, height) {
|
|
|
84
88
|
}
|
|
85
89
|
};
|
|
86
90
|
|
|
87
|
-
var RawLabel =
|
|
88
|
-
/*#__PURE__*/
|
|
89
|
-
function (_React$Component) {
|
|
91
|
+
var RawLabel = /*#__PURE__*/function (_React$Component) {
|
|
90
92
|
_inherits(RawLabel, _React$Component);
|
|
91
93
|
|
|
94
|
+
var _super = _createSuper(RawLabel);
|
|
95
|
+
|
|
92
96
|
function RawLabel() {
|
|
93
97
|
_classCallCheck(this, RawLabel);
|
|
94
98
|
|
|
95
|
-
return
|
|
99
|
+
return _super.apply(this, arguments);
|
|
96
100
|
}
|
|
97
101
|
|
|
98
102
|
_createClass(RawLabel, [{
|
|
@@ -108,16 +112,16 @@ function (_React$Component) {
|
|
|
108
112
|
var width = side === 'left' || side === 'right' ? size.height : size.width;
|
|
109
113
|
var height = 36;
|
|
110
114
|
var y = getY(side, height);
|
|
111
|
-
return _react["default"].createElement("foreignObject", {
|
|
115
|
+
return /*#__PURE__*/_react["default"].createElement("foreignObject", {
|
|
112
116
|
x: -(width / 2),
|
|
113
117
|
y: y,
|
|
114
118
|
width: width,
|
|
115
119
|
height: height,
|
|
116
120
|
transform: transform,
|
|
117
121
|
textAnchor: "middle"
|
|
118
|
-
}, _react["default"].createElement(_renderUi.Readable, {
|
|
122
|
+
}, /*#__PURE__*/_react["default"].createElement(_renderUi.Readable, {
|
|
119
123
|
"false": true
|
|
120
|
-
}, _react["default"].createElement("div", {
|
|
124
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
121
125
|
dangerouslySetInnerHTML: {
|
|
122
126
|
__html: text
|
|
123
127
|
},
|
|
@@ -155,15 +159,15 @@ var LabelType = {
|
|
|
155
159
|
};
|
|
156
160
|
exports.LabelType = LabelType;
|
|
157
161
|
|
|
158
|
-
var Labels =
|
|
159
|
-
/*#__PURE__*/
|
|
160
|
-
function (_React$Component2) {
|
|
162
|
+
var Labels = /*#__PURE__*/function (_React$Component2) {
|
|
161
163
|
_inherits(Labels, _React$Component2);
|
|
162
164
|
|
|
165
|
+
var _super2 = _createSuper(Labels);
|
|
166
|
+
|
|
163
167
|
function Labels() {
|
|
164
168
|
_classCallCheck(this, Labels);
|
|
165
169
|
|
|
166
|
-
return
|
|
170
|
+
return _super2.apply(this, arguments);
|
|
167
171
|
}
|
|
168
172
|
|
|
169
173
|
_createClass(Labels, [{
|
|
@@ -172,22 +176,22 @@ function (_React$Component2) {
|
|
|
172
176
|
var _this$props2 = this.props,
|
|
173
177
|
value = _this$props2.value,
|
|
174
178
|
graphProps = _this$props2.graphProps;
|
|
175
|
-
return _react["default"].createElement(_react["default"].Fragment, null, value && value.left && _react["default"].createElement(Label, {
|
|
179
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, value && value.left && /*#__PURE__*/_react["default"].createElement(Label, {
|
|
176
180
|
key: "left",
|
|
177
181
|
side: "left",
|
|
178
182
|
text: value.left,
|
|
179
183
|
graphProps: graphProps
|
|
180
|
-
}), value && value.top && _react["default"].createElement(Label, {
|
|
184
|
+
}), value && value.top && /*#__PURE__*/_react["default"].createElement(Label, {
|
|
181
185
|
key: "top",
|
|
182
186
|
side: "top",
|
|
183
187
|
text: value.top,
|
|
184
188
|
graphProps: graphProps
|
|
185
|
-
}), value && value.bottom && _react["default"].createElement(Label, {
|
|
189
|
+
}), value && value.bottom && /*#__PURE__*/_react["default"].createElement(Label, {
|
|
186
190
|
key: "bottom",
|
|
187
191
|
side: "bottom",
|
|
188
192
|
text: value.bottom,
|
|
189
193
|
graphProps: graphProps
|
|
190
|
-
}), value && value.right && _react["default"].createElement(Label, {
|
|
194
|
+
}), value && value.right && /*#__PURE__*/_react["default"].createElement(Label, {
|
|
191
195
|
key: "right",
|
|
192
196
|
side: "right",
|
|
193
197
|
text: value.right,
|