@pie-lib/charting 4.5.13 → 4.5.16
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.json +15 -15
- package/CHANGELOG.md +30 -0
- package/lib/axes.js +125 -60
- package/lib/axes.js.map +1 -1
- package/lib/bars/bar.js +17 -13
- package/lib/bars/bar.js.map +1 -1
- package/lib/bars/common/bars.js +27 -21
- package/lib/bars/common/bars.js.map +1 -1
- package/lib/bars/histogram.js +17 -13
- package/lib/bars/histogram.js.map +1 -1
- package/lib/chart.js +43 -34
- package/lib/chart.js.map +1 -1
- package/lib/common/drag-handle.js +24 -18
- package/lib/common/drag-handle.js.map +1 -1
- package/lib/common/styles.js +1 -1
- package/lib/grid.js +17 -13
- package/lib/grid.js.map +1 -1
- package/lib/line/common/drag-handle.js +20 -14
- package/lib/line/common/drag-handle.js.map +1 -1
- package/lib/line/common/line.js +37 -29
- package/lib/line/common/line.js.map +1 -1
- package/lib/line/line-cross.js +23 -17
- package/lib/line/line-cross.js.map +1 -1
- package/lib/line/line-dot.js +21 -15
- package/lib/line/line-dot.js.map +1 -1
- package/lib/mark-label.js +15 -7
- package/lib/mark-label.js.map +1 -1
- package/lib/plot/common/plot.js +27 -21
- package/lib/plot/common/plot.js.map +1 -1
- package/lib/plot/dot.js +18 -14
- package/lib/plot/dot.js.map +1 -1
- package/lib/plot/line.js +19 -15
- package/lib/plot/line.js.map +1 -1
- package/lib/tool-menu.js +19 -15
- package/lib/tool-menu.js.map +1 -1
- package/lib/utils.js +20 -9
- package/lib/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/axes.jsx +62 -1
- package/src/chart.jsx +5 -2
- package/src/utils.js +16 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/line/common/line.jsx"],"names":["getData","data","domain","max","length","map","el","i","x","y","value","RawLine","props","line","setState","index","onChange","dragging","state","existing","next","newLine","dragValue","setDragValue","undefined","graphProps","nextProps","classes","CustomDraggableComponent","lineState","scale","lineToUse","d","point","r","Component","interactive","DraggableHandle","DragHandle","v","dragStop","correctness","React","PropTypes","func","number","object","label","string","xBand","isRequired","types","GraphPropsType","arrayOf","shape","StyledLine","theme","fill","stroke","color","primaryLight","strokeWidth","transition","primaryDark","Line","category","changeLine","array"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,OAAO,GAAG,SAAVA,OAAU,CAACC,IAAD,EAAOC,MAAP,EAAkB;AAAA,aAChBA,MAAM,IAAI,EADM;AAAA,MACxBC,GADwB,QACxBA,GADwB;;AAEhC,MAAMC,MAAM,GAAGH,IAAI,CAACG,MAApB;;AAEA,MAAI,CAACD,GAAD,IAAQ,CAACC,MAAb,EAAqB;AACnB,WAAO,EAAP;AACD;;AAED,SAAOH,IAAI,CAACI,GAAL,CAAS,UAACC,EAAD,EAAKC,CAAL;AAAA,6BACXD,EADW;AAEdE,MAAAA,CAAC,EAAEJ,MAAM,GAAG,CAAT,GAAaG,CAAC,IAAIJ,GAAG,IAAIC,MAAM,GAAG,CAAb,CAAP,CAAd,GAAwC,GAF7B;AAGdK,MAAAA,CAAC,EAAEH,EAAE,CAACI;AAHQ;AAAA,GAAT,CAAP;AAKD,CAbD;;IAeaC,O;;;;;AAsBX,mBAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AACjB,iFAAMA,KAAN;;AADiB,mEAgBJ,UAAAC,IAAI;AAAA,aAAI,MAAKC,QAAL,CAAc;AAAED,QAAAA,IAAI,EAAJA;AAAF,OAAd,CAAJ;AAAA,KAhBA;;AAAA,+DAkBR,UAAAE,KAAK,EAAI;AAAA,UACVC,QADU,GACG,MAAKJ,KADR,CACVI,QADU;;AAElB,YAAKF,QAAL,CAAc;AAAEG,QAAAA,QAAQ,EAAE;AAAZ,OAAd,EAAmC,YAAM;AACvCD,QAAAA,QA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QAAAA,WAAW,EAAE,CADJ;AAETH,QAAAA,MAAM,EAAEC,gBAAMI,WAAN;AAFC;AALP;AADgC,GAAL;AAAA,CAAhB,EAWfpD,OAXe,CAAnB;;IAaaqD,I;;;;;;;;;;;;;;;;;;kEAQE,UAACjD,KAAD,EAAQkD,QAAR,EAAqB;AAAA,UACxBjD,QADwB,GACX,OAAKJ,KADM,CACxBI,QADwB;;AAEhC,UAAMK,OAAO,sBAAO,OAAKT,KAAL,CAAWX,IAAlB,CAAb;;AAFgC,UAGxBqB,SAHwB,GAGH2C,QAHG,CAGxB3C,SAHwB;AAAA,UAGbZ,KAHa,GAGHuD,QAHG,CAGbvD,KAHa;AAKhCW,MAAAA,OAAO,CAACN,KAAD,CAAP,CAAeL,KAAf,GAAuBY,SAAS,IAAI,CAAb,GAAiBA,SAAjB,GAA6BZ,KAApD;AAEAM,MAAAA,QAAQ,CAACK,OAAD,CAAR;AACD,K;;;;;;;6BAEQ;AACP,UAAMT,KAAK,GAAG,KAAKA,KAAnB;AAEA,aACE,gCAAC,YAAD,QACE,gCAAC,UAAD,eAAgBA,KAAhB;AAAuB,QAAA,QAAQ,EAAE,KAAKsD;AAAtC,SADF,CADF;AAKD;;;;EA1BuBxB,kBAAMP,S;;;;gBAAnB6B,I,eACQ;AACjB/D,EAAAA,IAAI,EAAE0C,sBAAUwB,KADC;AAEjBnD,EAAAA,QAAQ,EAAE2B,sBAAUC,IAFH;AAGjBK,EAAAA,KAAK,EAAEN,sBAAUC,IAHA;AAIjBnB,EAAAA,UAAU,EAAE0B,YAAMC,cAAN,CAAqBF;AAJhB,C;;eA4BNc,I","sourcesContent":["import React from 'react';\nimport { Group } from '@vx/group';\nimport { LinePath } from '@vx/shape';\nimport PropTypes from 'prop-types';\nimport { types } from '@pie-lib/plot';\nimport DraggableHandle, { DragHandle } from './drag-handle';\nimport { withStyles } from '@material-ui/core/styles/index';\nimport isEqual from 'lodash/isEqual';\nimport { color } from '@pie-lib/render-ui';\n\nconst getData = (data, domain) => {\n const { max } = domain || {};\n const length = data.length;\n\n if (!max || !length) {\n return [];\n }\n\n return data.map((el, i) => ({\n ...el,\n x: length > 1 ? i * (max / (length - 1)) : 0.5,\n y: el.value\n }));\n};\n\nexport class RawLine extends React.Component {\n static propTypes = {\n onChange: PropTypes.func,\n value: PropTypes.number,\n classes: PropTypes.object,\n label: PropTypes.string,\n xBand: PropTypes.func,\n index: PropTypes.number.isRequired,\n graphProps: types.GraphPropsType.isRequired,\n data: PropTypes.arrayOf(\n PropTypes.shape({\n label: PropTypes.string,\n value: PropTypes.number\n })\n ),\n CustomDraggableComponent: PropTypes.func\n };\n\n static defaultProps = {\n index: 0\n };\n\n constructor(props) {\n super(props);\n this.state = {\n dragValue: undefined,\n line: getData(props.data, props.graphProps.domain)\n };\n }\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n if (!isEqual(this.props.data, nextProps.data)) {\n this.setState({\n line: getData(nextProps.data, nextProps.graphProps.domain)\n });\n }\n }\n\n setDragValue = line => this.setState({ line });\n\n dragStop = index => {\n const { onChange } = this.props;\n this.setState({ dragging: false }, () => {\n onChange(index, this.state.line[index]);\n });\n };\n\n dragValue = (index, existing, next) => {\n const newLine = [...this.state.line];\n newLine[index].dragValue = next;\n this.setDragValue(newLine);\n };\n\n render() {\n const { graphProps, data, classes, CustomDraggableComponent } = this.props;\n const { line: lineState, dragging } = this.state;\n const { scale } = graphProps;\n const lineToUse = dragging ? lineState : getData(data, graphProps.domain);\n\n return (\n <React.Fragment>\n <LinePath\n data={lineToUse}\n x={d => scale.x(d.x)}\n y={d => scale.y(d.dragValue !== undefined ? d.dragValue : d.y)}\n className={classes.line}\n />\n {lineToUse &&\n lineToUse.map((point, i) => {\n const r = 6;\n const Component = point.interactive ? DraggableHandle : DragHandle;\n\n return (\n <Component\n key={`point-${point.x}-${i}`}\n x={point.x}\n y={point.dragValue !== undefined ? point.dragValue : point.y}\n interactive={point.interactive}\n r={r}\n onDragStart={() => this.setState({ dragging: true })}\n onDrag={v =>\n this.dragValue(i, point.dragValue !== undefined ? point.dragValue : point.y, v)\n }\n onDragStop={() => this.dragStop(i)}\n graphProps={graphProps}\n CustomDraggableComponent={CustomDraggableComponent}\n correctness={point.correctness}\n />\n );\n })}\n </React.Fragment>\n );\n }\n}\n\nconst StyledLine = withStyles(theme => ({\n line: {\n fill: 'transparent',\n stroke: color.primaryLight(),\n strokeWidth: 3,\n transition: 'stroke 200ms ease-in, stroke-width 200ms ease-in',\n '&:hover': {\n strokeWidth: 6,\n stroke: color.primaryDark()\n }\n }\n}))(RawLine);\n\nexport class Line extends React.Component {\n static propTypes = {\n data: PropTypes.array,\n onChange: PropTypes.func,\n xBand: PropTypes.func,\n graphProps: types.GraphPropsType.isRequired\n };\n\n changeLine = (index, category) => {\n const { onChange } = this.props;\n const newLine = [...this.props.data];\n const { dragValue, value } = category;\n\n newLine[index].value = dragValue >= 0 ? dragValue : value;\n\n onChange(newLine);\n };\n\n render() {\n const props = this.props;\n\n return (\n <Group>\n <StyledLine {...props} onChange={this.changeLine} />\n </Group>\n );\n }\n}\n\nexport default Line;\n"],"file":"line.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/line/common/line.jsx"],"names":["getData","data","domain","max","length","map","el","i","x","y","value","RawLine","props","line","setState","index","onChange","dragging","state","existing","next","newLine","dragValue","setDragValue","undefined","graphProps","nextProps","classes","CustomDraggableComponent","lineState","scale","lineToUse","d","point","r","Component","interactive","DraggableHandle","DragHandle","v","dragStop","correctness","React","PropTypes","func","number","object","label","string","xBand","isRequired","types","GraphPropsType","arrayOf","shape","StyledLine","theme","fill","stroke","color","primaryLight","strokeWidth","transition","primaryDark","Line","category","changeLine","array"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,OAAO,GAAG,SAAVA,OAAU,CAACC,IAAD,EAAOC,MAAP,EAAk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B2C,QAA7B,CAAQ3C,SAAR;AAAA,UAAmBZ,KAAnB,GAA6BuD,QAA7B,CAAmBvD,KAAnB;AAEAW,MAAAA,OAAO,CAACN,KAAD,CAAP,CAAeL,KAAf,GAAuBY,SAAS,IAAI,CAAb,GAAiBA,SAAjB,GAA6BZ,KAApD;AAEAM,MAAAA,QAAQ,CAACK,OAAD,CAAR;AACD,K;;;;;;;WAED,kBAAS;AACP,UAAMT,KAAK,GAAG,KAAKA,KAAnB;AAEA,0BACE,gCAAC,YAAD,qBACE,gCAAC,UAAD,eAAgBA,KAAhB;AAAuB,QAAA,QAAQ,EAAE,KAAKsD;AAAtC,SADF,CADF;AAKD;;;;EA1BuBxB,kBAAMP,S;;;;gBAAnB6B,I,eACQ;AACjB/D,EAAAA,IAAI,EAAE0C,sBAAUwB,KADC;AAEjBnD,EAAAA,QAAQ,EAAE2B,sBAAUC,IAFH;AAGjBK,EAAAA,KAAK,EAAEN,sBAAUC,IAHA;AAIjBnB,EAAAA,UAAU,EAAE0B,YAAMC,cAAN,CAAqBF;AAJhB,C;;eA4BNc,I","sourcesContent":["import React from 'react';\nimport { Group } from '@vx/group';\nimport { LinePath } from '@vx/shape';\nimport PropTypes from 'prop-types';\nimport { types } from '@pie-lib/plot';\nimport DraggableHandle, { DragHandle } from './drag-handle';\nimport { withStyles } from '@material-ui/core/styles/index';\nimport isEqual from 'lodash/isEqual';\nimport { color } from '@pie-lib/render-ui';\n\nconst getData = (data, domain) => {\n const { max } = domain || {};\n const length = data.length;\n\n if (!max || !length) {\n return [];\n }\n\n return data.map((el, i) => ({\n ...el,\n x: length > 1 ? i * (max / (length - 1)) : 0.5,\n y: el.value\n }));\n};\n\nexport class RawLine extends React.Component {\n static propTypes = {\n onChange: PropTypes.func,\n value: PropTypes.number,\n classes: PropTypes.object,\n label: PropTypes.string,\n xBand: PropTypes.func,\n index: PropTypes.number.isRequired,\n graphProps: types.GraphPropsType.isRequired,\n data: PropTypes.arrayOf(\n PropTypes.shape({\n label: PropTypes.string,\n value: PropTypes.number\n })\n ),\n CustomDraggableComponent: PropTypes.func\n };\n\n static defaultProps = {\n index: 0\n };\n\n constructor(props) {\n super(props);\n this.state = {\n dragValue: undefined,\n line: getData(props.data, props.graphProps.domain)\n };\n }\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n if (!isEqual(this.props.data, nextProps.data)) {\n this.setState({\n line: getData(nextProps.data, nextProps.graphProps.domain)\n });\n }\n }\n\n setDragValue = line => this.setState({ line });\n\n dragStop = index => {\n const { onChange } = this.props;\n this.setState({ dragging: false }, () => {\n onChange(index, this.state.line[index]);\n });\n };\n\n dragValue = (index, existing, next) => {\n const newLine = [...this.state.line];\n newLine[index].dragValue = next;\n this.setDragValue(newLine);\n };\n\n render() {\n const { graphProps, data, classes, CustomDraggableComponent } = this.props;\n const { line: lineState, dragging } = this.state;\n const { scale } = graphProps;\n const lineToUse = dragging ? lineState : getData(data, graphProps.domain);\n\n return (\n <React.Fragment>\n <LinePath\n data={lineToUse}\n x={d => scale.x(d.x)}\n y={d => scale.y(d.dragValue !== undefined ? d.dragValue : d.y)}\n className={classes.line}\n />\n {lineToUse &&\n lineToUse.map((point, i) => {\n const r = 6;\n const Component = point.interactive ? DraggableHandle : DragHandle;\n\n return (\n <Component\n key={`point-${point.x}-${i}`}\n x={point.x}\n y={point.dragValue !== undefined ? point.dragValue : point.y}\n interactive={point.interactive}\n r={r}\n onDragStart={() => this.setState({ dragging: true })}\n onDrag={v =>\n this.dragValue(i, point.dragValue !== undefined ? point.dragValue : point.y, v)\n }\n onDragStop={() => this.dragStop(i)}\n graphProps={graphProps}\n CustomDraggableComponent={CustomDraggableComponent}\n correctness={point.correctness}\n />\n );\n })}\n </React.Fragment>\n );\n }\n}\n\nconst StyledLine = withStyles(theme => ({\n line: {\n fill: 'transparent',\n stroke: color.primaryLight(),\n strokeWidth: 3,\n transition: 'stroke 200ms ease-in, stroke-width 200ms ease-in',\n '&:hover': {\n strokeWidth: 6,\n stroke: color.primaryDark()\n }\n }\n}))(RawLine);\n\nexport class Line extends React.Component {\n static propTypes = {\n data: PropTypes.array,\n onChange: PropTypes.func,\n xBand: PropTypes.func,\n graphProps: types.GraphPropsType.isRequired\n };\n\n changeLine = (index, category) => {\n const { onChange } = this.props;\n const newLine = [...this.props.data];\n const { dragValue, value } = category;\n\n newLine[index].value = dragValue >= 0 ? dragValue : value;\n\n onChange(newLine);\n };\n\n render() {\n const props = this.props;\n\n return (\n <Group>\n <StyledLine {...props} onChange={this.changeLine} />\n </Group>\n );\n }\n}\n\nexport default Line;\n"],"file":"line.js"}
|
package/lib/line/line-cross.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
|
});
|
|
@@ -21,25 +23,29 @@ var _utils = require("../utils");
|
|
|
21
23
|
|
|
22
24
|
var _line = _interopRequireDefault(require("./common/line"));
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
var _excluded = ["classes", "className", "scale", "x", "y", "r", "correctness"];
|
|
25
27
|
|
|
26
|
-
function
|
|
28
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
27
29
|
|
|
28
30
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
29
31
|
|
|
30
32
|
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); } }
|
|
31
33
|
|
|
32
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
34
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
33
35
|
|
|
34
|
-
function
|
|
36
|
+
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); }
|
|
35
37
|
|
|
36
|
-
function
|
|
38
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
37
39
|
|
|
38
|
-
function
|
|
40
|
+
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); }; }
|
|
39
41
|
|
|
40
|
-
function
|
|
42
|
+
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); }
|
|
41
43
|
|
|
42
|
-
function
|
|
44
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
45
|
+
|
|
46
|
+
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; } }
|
|
47
|
+
|
|
48
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
43
49
|
|
|
44
50
|
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; }
|
|
45
51
|
|
|
@@ -58,11 +64,11 @@ var DraggableComponent = function DraggableComponent(props) {
|
|
|
58
64
|
y = props.y,
|
|
59
65
|
r = props.r,
|
|
60
66
|
correctness = props.correctness,
|
|
61
|
-
rest = _objectWithoutProperties(props,
|
|
67
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
62
68
|
|
|
63
|
-
return _react["default"].createElement(_group.Group, _extends({}, rest, {
|
|
69
|
+
return /*#__PURE__*/_react["default"].createElement(_group.Group, _extends({}, rest, {
|
|
64
70
|
className: (0, _classnames["default"])(className, classes.line, correctness && correctness.value)
|
|
65
|
-
}), _react["default"].createElement(_shape.LinePath, {
|
|
71
|
+
}), /*#__PURE__*/_react["default"].createElement(_shape.LinePath, {
|
|
66
72
|
data: [{
|
|
67
73
|
x: scale.x(x) - r,
|
|
68
74
|
y: scale.y(y) + r
|
|
@@ -78,7 +84,7 @@ var DraggableComponent = function DraggableComponent(props) {
|
|
|
78
84
|
return d.y;
|
|
79
85
|
},
|
|
80
86
|
strokeWidth: 5
|
|
81
|
-
}), _react["default"].createElement(_shape.LinePath, {
|
|
87
|
+
}), /*#__PURE__*/_react["default"].createElement(_shape.LinePath, {
|
|
82
88
|
data: [{
|
|
83
89
|
x: scale.x(x) - r,
|
|
84
90
|
y: scale.y(y) - r
|
|
@@ -110,15 +116,15 @@ DraggableComponent.propTypes = {
|
|
|
110
116
|
})
|
|
111
117
|
};
|
|
112
118
|
|
|
113
|
-
var LineCross =
|
|
114
|
-
/*#__PURE__*/
|
|
115
|
-
function (_React$Component) {
|
|
119
|
+
var LineCross = /*#__PURE__*/function (_React$Component) {
|
|
116
120
|
_inherits(LineCross, _React$Component);
|
|
117
121
|
|
|
122
|
+
var _super = _createSuper(LineCross);
|
|
123
|
+
|
|
118
124
|
function LineCross() {
|
|
119
125
|
_classCallCheck(this, LineCross);
|
|
120
126
|
|
|
121
|
-
return
|
|
127
|
+
return _super.apply(this, arguments);
|
|
122
128
|
}
|
|
123
129
|
|
|
124
130
|
_createClass(LineCross, [{
|
|
@@ -135,7 +141,7 @@ function (_React$Component) {
|
|
|
135
141
|
size = _ref$size === void 0 ? {} : _ref$size;
|
|
136
142
|
|
|
137
143
|
var xBand = (0, _utils.dataToXBand)(scale.x, data, size.width, 'lineCross');
|
|
138
|
-
return _react["default"].createElement(_line["default"], _extends({}, props, {
|
|
144
|
+
return /*#__PURE__*/_react["default"].createElement(_line["default"], _extends({}, props, {
|
|
139
145
|
xBand: xBand,
|
|
140
146
|
CustomDraggableComponent: DraggableComponent
|
|
141
147
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/line/line-cross.js"],"names":["DraggableComponent","props","classes","className","scale","x","y","r","correctness","rest","line","value","d","propTypes","PropTypes","object","number","string","shape","label","LineCross","data","graphProps","size","xBand","width","React","Component","array","onChange","func","types","GraphPropsType","isRequired","type","name"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/line/line-cross.js"],"names":["DraggableComponent","props","classes","className","scale","x","y","r","correctness","rest","line","value","d","propTypes","PropTypes","object","number","string","shape","label","LineCross","data","graphProps","size","xBand","width","React","Component","array","onChange","func","types","GraphPropsType","isRequired","type","name"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,kB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;AAAA,UAAcC,UAAd,GAA6BrB,KAA7B,CAAcqB,UAAd;;AACA,iBAAkCA,UAAU,IAAI,EAAhD;AAAA,4BAAQlB,KAAR;AAAA,UAAQA,KAAR,2BAAgB,EAAhB;AAAA,2BAAoBmB,IAApB;AAAA,UAAoBA,IAApB,0BAA2B,EAA3B;;AACA,UAAMC,KAAK,GAAG,wBAAYpB,KAAK,CAACC,CAAlB,EAAqBgB,IAArB,EAA2BE,IAAI,CAACE,KAAhC,EAAuC,WAAvC,CAAd;AAEA,0BAAO,gCAAC,gBAAD,eAAaxB,KAAb;AAAoB,QAAA,KAAK,EAAEuB,KAA3B;AAAkC,QAAA,wBAAwB,EAAExB;AAA5D,SAAP;AACD;;;;EAd4B0B,kBAAMC,S;;;;gBAAxBP,S,eACQ;AACjBC,EAAAA,IAAI,EAAEP,sBAAUc,KADC;AAEjBC,EAAAA,QAAQ,EAAEf,sBAAUgB,IAFH;AAGjBR,EAAAA,UAAU,EAAES,YAAMC,cAAN,CAAqBC;AAHhB,C;;eAgBN;AAAA,SAAO;AACpBC,IAAAA,IAAI,EAAE,WADc;AAEpBP,IAAAA,SAAS,EAAEP,SAFS;AAGpBe,IAAAA,IAAI,EAAE;AAHc,GAAP;AAAA,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { types } from '@pie-lib/plot';\nimport { LinePath } from '@vx/shape';\nimport { Group } from '@vx/group';\nimport classNames from 'classnames';\nimport { dataToXBand } from '../utils';\nimport RawLine from './common/line';\n\nconst DraggableComponent = props => {\n const { classes = {}, className, scale, x, y, r, correctness, ...rest } = props;\n\n return (\n <Group\n {...rest}\n className={classNames(className, classes.line, correctness && correctness.value)}\n >\n <LinePath\n data={[{ x: scale.x(x) - r, y: scale.y(y) + r }, { x: scale.x(x) + r, y: scale.y(y) - r }]}\n key={`point-${x}-${y}-1`}\n x={d => d.x}\n y={d => d.y}\n strokeWidth={5}\n />\n <LinePath\n data={[{ x: scale.x(x) - r, y: scale.y(y) - r }, { x: scale.x(x) + r, y: scale.y(y) + r }]}\n key={`point-${x}-${y}-2`}\n x={d => d.x}\n y={d => d.y}\n strokeWidth={5}\n />\n </Group>\n );\n};\n\nDraggableComponent.propTypes = {\n scale: PropTypes.object,\n x: PropTypes.number,\n y: PropTypes.number,\n r: PropTypes.number,\n className: PropTypes.string,\n classes: PropTypes.object,\n correctness: PropTypes.shape({\n value: PropTypes.string,\n label: PropTypes.string\n })\n};\n\nexport class LineCross extends React.Component {\n static propTypes = {\n data: PropTypes.array,\n onChange: PropTypes.func,\n graphProps: types.GraphPropsType.isRequired\n };\n\n render() {\n const props = this.props;\n const { data, graphProps } = props;\n const { scale = {}, size = {} } = graphProps || {};\n const xBand = dataToXBand(scale.x, data, size.width, 'lineCross');\n\n return <RawLine {...props} xBand={xBand} CustomDraggableComponent={DraggableComponent} />;\n }\n}\n\nexport default () => ({\n type: 'lineCross',\n Component: LineCross,\n name: 'Line Cross'\n});\n"],"file":"line-cross.js"}
|
package/lib/line/line-dot.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,25 +19,29 @@ var _line = _interopRequireDefault(require("./common/line"));
|
|
|
17
19
|
|
|
18
20
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
var _excluded = ["scale", "x", "y", "className", "classes", "r", "correctness"];
|
|
21
23
|
|
|
22
|
-
function
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
25
|
|
|
24
26
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
25
27
|
|
|
26
28
|
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); } }
|
|
27
29
|
|
|
28
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
30
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
29
31
|
|
|
30
|
-
function
|
|
32
|
+
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); }
|
|
31
33
|
|
|
32
|
-
function
|
|
34
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
33
35
|
|
|
34
|
-
function
|
|
36
|
+
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); }; }
|
|
35
37
|
|
|
36
|
-
function
|
|
38
|
+
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); }
|
|
37
39
|
|
|
38
|
-
function
|
|
40
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
41
|
+
|
|
42
|
+
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; } }
|
|
43
|
+
|
|
44
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
39
45
|
|
|
40
46
|
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; }
|
|
41
47
|
|
|
@@ -53,9 +59,9 @@ var DraggableComponent = function DraggableComponent(_ref) {
|
|
|
53
59
|
classes = _ref.classes,
|
|
54
60
|
r = _ref.r,
|
|
55
61
|
correctness = _ref.correctness,
|
|
56
|
-
rest = _objectWithoutProperties(_ref,
|
|
62
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
57
63
|
|
|
58
|
-
return _react["default"].createElement("circle", _extends({
|
|
64
|
+
return /*#__PURE__*/_react["default"].createElement("circle", _extends({
|
|
59
65
|
cx: scale.x(x),
|
|
60
66
|
cy: scale.y(y),
|
|
61
67
|
r: r,
|
|
@@ -76,15 +82,15 @@ DraggableComponent.propTypes = {
|
|
|
76
82
|
})
|
|
77
83
|
};
|
|
78
84
|
|
|
79
|
-
var LineDot =
|
|
80
|
-
/*#__PURE__*/
|
|
81
|
-
function (_React$Component) {
|
|
85
|
+
var LineDot = /*#__PURE__*/function (_React$Component) {
|
|
82
86
|
_inherits(LineDot, _React$Component);
|
|
83
87
|
|
|
88
|
+
var _super = _createSuper(LineDot);
|
|
89
|
+
|
|
84
90
|
function LineDot() {
|
|
85
91
|
_classCallCheck(this, LineDot);
|
|
86
92
|
|
|
87
|
-
return
|
|
93
|
+
return _super.apply(this, arguments);
|
|
88
94
|
}
|
|
89
95
|
|
|
90
96
|
_createClass(LineDot, [{
|
|
@@ -101,7 +107,7 @@ function (_React$Component) {
|
|
|
101
107
|
size = _ref2$size === void 0 ? {} : _ref2$size;
|
|
102
108
|
|
|
103
109
|
var xBand = (0, _utils.dataToXBand)(scale.x, data, size.width, 'lineDot');
|
|
104
|
-
return _react["default"].createElement(_line["default"], _extends({}, props, {
|
|
110
|
+
return /*#__PURE__*/_react["default"].createElement(_line["default"], _extends({}, props, {
|
|
105
111
|
xBand: xBand,
|
|
106
112
|
CustomDraggableComponent: DraggableComponent
|
|
107
113
|
}));
|
package/lib/line/line-dot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/line/line-dot.js"],"names":["DraggableComponent","scale","x","y","className","classes","r","correctness","rest","handle","value","propTypes","PropTypes","object","number","string","shape","label","LineDot","props","data","graphProps","size","xBand","width","React","Component","array","onChange","func","types","GraphPropsType","isRequired","type","name"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/line/line-dot.js"],"names":["DraggableComponent","scale","x","y","className","classes","r","correctness","rest","handle","value","propTypes","PropTypes","object","number","string","shape","label","LineDot","props","data","graphProps","size","xBand","width","React","Component","array","onChange","func","types","GraphPropsType","isRequired","type","name"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,kBAAkB,GAAG,SAArBA,kBAAqB;AAAA,MAAGC,KAAH,QAAGA,KAAH;AAAA,MAAUC,CAAV,QAAUA,CAAV;AAAA,MAAaC,CAAb,QAAaA,CAAb;AAAA,MAAgBC,SAAhB,QAA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;;AACA,UAAMC,KAAK,GAAG,wBAAYtB,KAAK,CAACC,CAAlB,EAAqBkB,IAArB,EAA2BE,IAAI,CAACE,KAAhC,EAAuC,SAAvC,CAAd;AAEA,0BAAO,gCAAC,gBAAD,eAAaL,KAAb;AAAoB,QAAA,KAAK,EAAEI,KAA3B;AAAkC,QAAA,wBAAwB,EAAEvB;AAA5D,SAAP;AACD;;;;EAd0ByB,kBAAMC,S;;;;gBAAtBR,O,eACQ;AACjBE,EAAAA,IAAI,EAAER,sBAAUe,KADC;AAEjBC,EAAAA,QAAQ,EAAEhB,sBAAUiB,IAFH;AAGjBR,EAAAA,UAAU,EAAES,YAAMC,cAAN,CAAqBC;AAHhB,C;;eAgBN;AAAA,SAAO;AACpBC,IAAAA,IAAI,EAAE,SADc;AAEpBP,IAAAA,SAAS,EAAER,OAFS;AAGpBgB,IAAAA,IAAI,EAAE;AAHc,GAAP;AAAA,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { types } from '@pie-lib/plot';\nimport { dataToXBand } from '../utils';\nimport RawLine from './common/line';\nimport classNames from 'classnames';\n\nconst DraggableComponent = ({ scale, x, y, className, classes, r, correctness, ...rest }) => (\n <circle\n cx={scale.x(x)}\n cy={scale.y(y)}\n r={r}\n className={classNames(className, classes.handle, correctness && correctness.value)}\n {...rest}\n />\n);\n\nDraggableComponent.propTypes = {\n scale: PropTypes.object,\n x: PropTypes.number,\n y: PropTypes.number,\n r: PropTypes.number,\n className: PropTypes.string,\n classes: PropTypes.object,\n correctness: PropTypes.shape({\n value: PropTypes.string,\n label: PropTypes.string\n })\n};\n\nexport class LineDot extends React.Component {\n static propTypes = {\n data: PropTypes.array,\n onChange: PropTypes.func,\n graphProps: types.GraphPropsType.isRequired\n };\n\n render() {\n const props = this.props;\n const { data, graphProps } = props;\n const { scale = {}, size = {} } = graphProps || {};\n const xBand = dataToXBand(scale.x, data, size.width, 'lineDot');\n\n return <RawLine {...props} xBand={xBand} CustomDraggableComponent={DraggableComponent} />;\n }\n}\n\nexport default () => ({\n type: 'lineDot',\n Component: LineDot,\n name: 'Line Dot'\n});\n"],"file":"line-dot.js"}
|
package/lib/mark-label.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
|
});
|
|
@@ -23,19 +25,25 @@ var _renderUi = require("@pie-lib/render-ui");
|
|
|
23
25
|
|
|
24
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
27
|
|
|
26
|
-
function
|
|
28
|
+
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); }
|
|
29
|
+
|
|
30
|
+
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; }
|
|
27
31
|
|
|
28
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
32
|
+
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; }
|
|
29
33
|
|
|
30
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
34
|
+
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; }
|
|
31
35
|
|
|
32
36
|
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; }
|
|
33
37
|
|
|
34
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
|
38
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
39
|
+
|
|
40
|
+
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."); }
|
|
41
|
+
|
|
42
|
+
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); }
|
|
35
43
|
|
|
36
|
-
function
|
|
44
|
+
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; }
|
|
37
45
|
|
|
38
|
-
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e
|
|
46
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
39
47
|
|
|
40
48
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
41
49
|
|
|
@@ -100,7 +108,7 @@ var MarkLabel = function MarkLabel(props) {
|
|
|
100
108
|
(0, _react.useEffect)(function () {
|
|
101
109
|
setLabel(mark.label);
|
|
102
110
|
}, [mark.label]);
|
|
103
|
-
return _react["default"].createElement(_reactInputAutosize["default"], {
|
|
111
|
+
return /*#__PURE__*/_react["default"].createElement(_reactInputAutosize["default"], {
|
|
104
112
|
inputRef: function inputRef(r) {
|
|
105
113
|
_ref(r);
|
|
106
114
|
|
package/lib/mark-label.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/mark-label.jsx"],"names":["styles","theme","input","fontFamily","typography","fontSize","border","color","primaryDark","backgroundColor","MarkLabel","props","setInput","_ref","node","mark","classes","disabled","externalInputRef","inputRef","barWidth","rotate","correctness","label","setLabel","onChange","e","target","value","onChangeProp","extraStyle","width","textAlign","r","minWidth","background","boxSizing","paddingLeft","paddingRight","position","pointerEvents","top","left","transformOrigin","transform","propTypes","PropTypes","bool","func","graphProps","types","GraphPropsType","object","number","shape","string"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/mark-label.jsx"],"names":["styles","theme","input","fontFamily","typography","fontSize","border","color","primaryDark","backgroundColor","MarkLabel","props","setInput","_ref","node","mark","classes","disabled","externalInputRef","inputRef","barWidth","rotate","correctness","label","setLabel","onChange","e","target","value","onChangeProp","extraStyle","width","textAlign","r","minWidth","background","boxSizing","paddingLeft","paddingRight","position","pointerEvents","top","left","transformOrigin","transform","propTypes","PropTypes","bool","func","graphProps","types","GraphPropsType","object","number","shape","string"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBC,IAAAA,KAAK,EAAE;AACL,eAAO,OADF;AAELC,MAAAA,UAAU,EAAEF,KAAK,CAACG,UAAN,CAAiBD,UAFxB;AAGLE,MAAAA,QAAQ,EAAEJ,KAAK,CAACG,UAAN,CAAiBC,QAHtB;AAILC,MAAAA,MAAM,EAAE,MAJH;AAKLC,MAAAA,KAAK,EAAEA,gBAAMC,WAAN,EALF;AAML,mBAAa,sBAAQ,OAAR,CANR;AAOL,qBAAe,wBAAU,OAAV,CAPV;AAQL,oBAAc,uBAAS,OAAT,CART;AASLC,MAAAA,eAAe,EAAE;AATZ;AADgB,GAAL;AAAA,CAApB;;AAcO,IAAMC,SAAS,GAAG,SAAZA,SAAY,CAAAC,KAAK,EAAI;AAChC;AACA,kBAA0B,qBAAS,IAAT,CAA1B;AAAA;AAAA,MAAOT,KAAP;AAAA,MAAcU,QAAd;;AACA,MAAMC,IAAI,GAAG,wBAAY,UAAAC,IAAI;AAAA,WAAIF,QAAQ,CAACE,I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MADU;AAE3BhC,IAAAA,KAAK,EAAEuB,sBAAUS;AAFU,GAAhB;AATO,CAAtB;;eAee,wBAAWvD,MAAX,EAAmBU,SAAnB,C","sourcesContent":["import React, { useState, useCallback, useEffect } from 'react';\nimport cn from 'classnames';\nimport { withStyles } from '@material-ui/core/styles';\nimport AutosizeInput from 'react-input-autosize';\nimport PropTypes from 'prop-types';\nimport { types } from '@pie-lib/plot';\nimport { correct, incorrect, disabled } from './common/styles';\nimport { color } from '@pie-lib/render-ui';\n\nconst styles = theme => ({\n input: {\n float: 'right',\n fontFamily: theme.typography.fontFamily,\n fontSize: theme.typography.fontSize,\n border: 'none',\n color: color.primaryDark(),\n '&.correct': correct('color'),\n '&.incorrect': incorrect('color'),\n '&.disabled': disabled('color'),\n backgroundColor: 'transparent !important'\n }\n});\n\nexport const MarkLabel = props => {\n // eslint-disable-next-line no-unused-vars\n const [input, setInput] = useState(null);\n const _ref = useCallback(node => setInput(node), null);\n\n const {\n mark,\n classes,\n disabled,\n inputRef: externalInputRef,\n barWidth,\n rotate,\n correctness\n } = props;\n const [label, setLabel] = useState(mark.label);\n const onChange = e => setLabel(e.target.value);\n const onChangeProp = e => props.onChange(e.target.value);\n let extraStyle = {};\n\n if (rotate) {\n extraStyle = {\n width: 'unset',\n textAlign: 'left'\n };\n }\n\n // useState only sets the value once, to synch props to state need useEffect\n useEffect(() => {\n setLabel(mark.label);\n }, [mark.label]);\n\n return (\n <AutosizeInput\n inputRef={r => {\n _ref(r);\n externalInputRef(r);\n }}\n disabled={disabled}\n inputClassName={cn(classes.input, correctness && correctness.label, disabled && 'disabled')}\n inputStyle={{\n minWidth: barWidth,\n textAlign: 'center',\n background: 'transparent',\n boxSizing: 'border-box',\n paddingLeft: 0,\n paddingRight: 0,\n ...extraStyle\n }}\n value={label}\n style={{\n position: 'absolute',\n pointerEvents: 'auto',\n top: 0,\n left: 0,\n minWidth: barWidth,\n transformOrigin: 'left',\n transform: `rotate(${rotate}deg)`\n }}\n onChange={onChange}\n onBlur={onChangeProp}\n />\n );\n};\n\nMarkLabel.propTypes = {\n disabled: PropTypes.bool,\n onChange: PropTypes.func,\n graphProps: types.GraphPropsType,\n classes: PropTypes.object,\n inputRef: PropTypes.func,\n mark: PropTypes.object,\n barWidth: PropTypes.number,\n rotate: PropTypes.number,\n correctness: PropTypes.shape({\n value: PropTypes.string,\n label: PropTypes.string\n })\n};\n\nexport default withStyles(styles)(MarkLabel);\n"],"file":"mark-label.js"}
|
package/lib/plot/common/plot.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.
|
|
8
|
+
exports["default"] = exports.RawPlot = exports.Plot = void 0;
|
|
7
9
|
|
|
8
10
|
var _react = _interopRequireDefault(require("react"));
|
|
9
11
|
|
|
@@ -25,43 +27,47 @@ var _utils = require("../../utils");
|
|
|
25
27
|
|
|
26
28
|
var _styles = require("../../common/styles");
|
|
27
29
|
|
|
28
|
-
function
|
|
30
|
+
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); }
|
|
29
31
|
|
|
30
|
-
function
|
|
32
|
+
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
33
|
|
|
32
|
-
function
|
|
34
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
33
35
|
|
|
34
36
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
35
37
|
|
|
36
38
|
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); } }
|
|
37
39
|
|
|
38
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
40
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
39
41
|
|
|
40
|
-
function
|
|
42
|
+
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); }
|
|
41
43
|
|
|
42
|
-
function
|
|
44
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
45
|
+
|
|
46
|
+
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); }; }
|
|
47
|
+
|
|
48
|
+
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); }
|
|
43
49
|
|
|
44
50
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
45
51
|
|
|
46
|
-
function
|
|
52
|
+
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; } }
|
|
47
53
|
|
|
48
|
-
function
|
|
54
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
49
55
|
|
|
50
56
|
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; }
|
|
51
57
|
|
|
52
58
|
var log = (0, _debug["default"])('pie-lib:chart:bars');
|
|
53
59
|
|
|
54
|
-
var RawPlot =
|
|
55
|
-
/*#__PURE__*/
|
|
56
|
-
function (_React$Component) {
|
|
60
|
+
var RawPlot = /*#__PURE__*/function (_React$Component) {
|
|
57
61
|
_inherits(RawPlot, _React$Component);
|
|
58
62
|
|
|
63
|
+
var _super = _createSuper(RawPlot);
|
|
64
|
+
|
|
59
65
|
function RawPlot(props) {
|
|
60
66
|
var _this;
|
|
61
67
|
|
|
62
68
|
_classCallCheck(this, RawPlot);
|
|
63
69
|
|
|
64
|
-
_this =
|
|
70
|
+
_this = _super.call(this, props);
|
|
65
71
|
|
|
66
72
|
_defineProperty(_assertThisInitialized(_this), "setDragValue", function (dragValue) {
|
|
67
73
|
return _this.setState({
|
|
@@ -137,7 +143,7 @@ function (_React$Component) {
|
|
|
137
143
|
var pointHeight = size.height / max;
|
|
138
144
|
var pointDiameter = (pointHeight > barWidth ? barWidth : pointHeight) * 0.8;
|
|
139
145
|
var Component = interactive ? _dragHandle["default"] : _dragHandle.DragHandle;
|
|
140
|
-
return _react["default"].createElement(_react["default"].Fragment, null, values.map(function (index) {
|
|
146
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, values.map(function (index) {
|
|
141
147
|
return CustomBarElement({
|
|
142
148
|
index: index,
|
|
143
149
|
pointDiameter: pointDiameter,
|
|
@@ -149,7 +155,7 @@ function (_React$Component) {
|
|
|
149
155
|
classes: classes,
|
|
150
156
|
scale: scale
|
|
151
157
|
});
|
|
152
|
-
}), _react["default"].createElement(Component, {
|
|
158
|
+
}), /*#__PURE__*/_react["default"].createElement(Component, {
|
|
153
159
|
x: barX,
|
|
154
160
|
y: v,
|
|
155
161
|
interactive: interactive,
|
|
@@ -200,15 +206,15 @@ var Bar = (0, _index.withStyles)(function (theme) {
|
|
|
200
206
|
};
|
|
201
207
|
})(RawPlot);
|
|
202
208
|
|
|
203
|
-
var Plot =
|
|
204
|
-
/*#__PURE__*/
|
|
205
|
-
function (_React$Component2) {
|
|
209
|
+
var Plot = /*#__PURE__*/function (_React$Component2) {
|
|
206
210
|
_inherits(Plot, _React$Component2);
|
|
207
211
|
|
|
212
|
+
var _super2 = _createSuper(Plot);
|
|
213
|
+
|
|
208
214
|
function Plot() {
|
|
209
215
|
_classCallCheck(this, Plot);
|
|
210
216
|
|
|
211
|
-
return
|
|
217
|
+
return _super2.apply(this, arguments);
|
|
212
218
|
}
|
|
213
219
|
|
|
214
220
|
_createClass(Plot, [{
|
|
@@ -220,8 +226,8 @@ function (_React$Component2) {
|
|
|
220
226
|
xBand = _this$props3.xBand,
|
|
221
227
|
CustomBarElement = _this$props3.CustomBarElement,
|
|
222
228
|
_onChangeCategory = _this$props3.onChangeCategory;
|
|
223
|
-
return _react["default"].createElement(_group.Group, null, (data || []).map(function (d, index) {
|
|
224
|
-
return _react["default"].createElement(Bar, {
|
|
229
|
+
return /*#__PURE__*/_react["default"].createElement(_group.Group, null, (data || []).map(function (d, index) {
|
|
230
|
+
return /*#__PURE__*/_react["default"].createElement(Bar, {
|
|
225
231
|
value: d.value,
|
|
226
232
|
label: d.label,
|
|
227
233
|
interactive: d.interactive,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plot/common/plot.jsx"],"names":["log","RawPlot","props","dragValue","setState","label","onChangeCategory","state","undefined","value","setDragValue","existing","next","graphProps","classes","xBand","index","CustomBarElement","interactive","correctness","scale","range","size","max","v","Number","isFinite","barWidth","bandwidth","barHeight","y","barX","values","i","push","pointHeight","height","pointDiameter","Component","DraggableHandle","DragHandle","map","dragStop","React","PropTypes","func","number","object","string","isRequired","types","GraphPropsType","bool","shape","Bar","theme","dot","fill","color","primaryLight","line","stroke","Plot","data","d","category","array"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/plot/common/plot.jsx"],"names":["log","RawPlot","props","dragValue","setState","label","onChangeCategory","state","undefined","value","setDragValue","existing","next","graphProps","classes","xBand","index","CustomBarElement","interactive","correctness","scale","range","size","max","v","Number","isFinite","barWidth","bandwidth","barHeight","y","barX","values","i","push","pointHeight","height","pointDiameter","Component","DraggableHandle","DragHandle","map","dragStop","React","PropTypes","func","number","object","string","isRequired","types","GraphPropsType","bool","shape","Bar","theme","dot","fill","color","prim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,EAAE2D,CAAC,CAAC9C,WAHjB;AAIE,UAAA,KAAK,EAAEH,KAJT;AAKE,UAAA,KAAK,EAAEC,KALT;AAME,UAAA,GAAG,gBAASgD,CAAC,CAAC3D,KAAX,cAAoB2D,CAAC,CAACvD,KAAtB,cAA+BO,KAA/B,CANL;AAOE,UAAA,gBAAgB,EAAE,0BAAAiD,QAAQ;AAAA,mBAAI3D,iBAAgB,CAACU,KAAD,EAAQiD,QAAR,CAApB;AAAA,WAP5B;AAQE,UAAA,UAAU,EAAEpD,UARd;AASE,UAAA,gBAAgB,EAAEI,gBATpB;AAUE,UAAA,WAAW,EAAE+C,CAAC,CAAC7C;AAVjB,UADgB;AAAA,OAAjB,CADH,CADF;AAkBD;;;;EA9BuBwB,kBAAML,S;;;;gBAAnBwB,I,eACQ;AACjBC,EAAAA,IAAI,EAAEnB,sBAAUsB,KADC;AAEjB5D,EAAAA,gBAAgB,EAAEsC,sBAAUC,IAFX;AAGjB9B,EAAAA,KAAK,EAAE6B,sBAAUC,IAHA;AAIjBhC,EAAAA,UAAU,EAAEqC,YAAMC,cAAN,CAAqBF,UAJhB;AAKjBhC,EAAAA,gBAAgB,EAAE2B,sBAAUC;AALX,C;;eAgCNiB,I","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { types } from '@pie-lib/plot';\nimport { Group } from '@vx/group';\nimport { withStyles } from '@material-ui/core/styles/index';\nimport DraggableHandle, { DragHandle } from '../../common/drag-handle';\nimport debug from 'debug';\nimport { color } from '@pie-lib/render-ui';\nimport { bandKey } from '../../utils';\nimport { correct, incorrect } from '../../common/styles';\n\nconst log = debug('pie-lib:chart:bars');\n\nexport class RawPlot extends React.Component {\n static propTypes = {\n onChangeCategory: PropTypes.func,\n value: PropTypes.number,\n classes: PropTypes.object,\n label: PropTypes.string,\n xBand: PropTypes.func,\n index: PropTypes.number.isRequired,\n graphProps: types.GraphPropsType.isRequired,\n CustomBarElement: PropTypes.func,\n interactive: PropTypes.bool,\n correctness: PropTypes.shape({\n value: PropTypes.string,\n label: PropTypes.string\n })\n };\n\n constructor(props) {\n super(props);\n this.state = {\n dragValue: undefined\n };\n }\n\n setDragValue = dragValue => this.setState({ dragValue });\n\n dragStop = () => {\n const { label, onChangeCategory } = this.props;\n const { dragValue } = this.state;\n log('[dragStop]', dragValue);\n\n if (dragValue !== undefined) {\n onChangeCategory({ label, value: dragValue });\n }\n\n this.setDragValue(undefined);\n };\n\n dragValue = (existing, next) => {\n log('[dragValue] next:', next);\n\n this.setDragValue(next);\n };\n\n render() {\n const {\n graphProps,\n value,\n label,\n classes,\n xBand,\n index,\n CustomBarElement,\n interactive,\n correctness\n } = this.props;\n const { scale, range, size } = graphProps;\n const { max } = range || {};\n const { dragValue } = this.state;\n\n const v = Number.isFinite(dragValue) ? dragValue : value;\n const barWidth = xBand.bandwidth();\n const barHeight = scale.y(range.max - v);\n const barX = xBand(bandKey({ label }, index));\n\n log('label:', label, 'barX:', barX, 'v: ', v, 'barHeight:', barHeight, 'barWidth: ', barWidth);\n\n const values = [];\n\n for (let i = 0; i < v; i++) {\n values.push(i);\n }\n\n const pointHeight = size.height / max;\n const pointDiameter = (pointHeight > barWidth ? barWidth : pointHeight) * 0.8;\n const Component = interactive ? DraggableHandle : DragHandle;\n\n return (\n <React.Fragment>\n {values.map(index =>\n CustomBarElement({\n index,\n pointDiameter,\n barX,\n barWidth,\n pointHeight,\n label,\n value,\n classes,\n scale\n })\n )}\n <Component\n x={barX}\n y={v}\n interactive={interactive}\n width={barWidth}\n onDrag={v => this.dragValue(value, v)}\n onDragStop={this.dragStop}\n graphProps={graphProps}\n correctness={correctness}\n />\n </React.Fragment>\n );\n }\n}\n\nconst Bar = withStyles(theme => ({\n dot: {\n fill: color.primaryLight(),\n '&.correct': correct('stroke'),\n '&.incorrect': incorrect('stroke')\n },\n line: {\n stroke: color.primaryLight(),\n '&.correct': correct('stroke'),\n '&.incorrect': incorrect('stroke')\n }\n}))(RawPlot);\n\nexport class Plot extends React.Component {\n static propTypes = {\n data: PropTypes.array,\n onChangeCategory: PropTypes.func,\n xBand: PropTypes.func,\n graphProps: types.GraphPropsType.isRequired,\n CustomBarElement: PropTypes.func\n };\n\n render() {\n const { data, graphProps, xBand, CustomBarElement, onChangeCategory } = this.props;\n\n return (\n <Group>\n {(data || []).map((d, index) => (\n <Bar\n value={d.value}\n label={d.label}\n interactive={d.interactive}\n xBand={xBand}\n index={index}\n key={`bar-${d.label}-${d.value}-${index}`}\n onChangeCategory={category => onChangeCategory(index, category)}\n graphProps={graphProps}\n CustomBarElement={CustomBarElement}\n correctness={d.correctness}\n />\n ))}\n </Group>\n );\n }\n}\n\nexport default Plot;\n"],"file":"plot.js"}
|