@pie-lib/graphing 2.4.3 → 2.4.7
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 +32 -0
- package/lib/tools/line/component.js +3 -0
- package/lib/tools/line/component.js.map +1 -1
- package/lib/tools/ray/component.js +3 -0
- package/lib/tools/ray/component.js.map +1 -1
- package/lib/tools/shared/point/arrow.js +3 -1
- package/lib/tools/shared/point/arrow.js.map +1 -1
- package/lib/tools/shared/point/base-point.js +4 -1
- package/lib/tools/shared/point/base-point.js.map +1 -1
- package/lib/utils.js +21 -1
- package/lib/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/tools/line/component.jsx +3 -0
- package/src/tools/ray/component.jsx +2 -0
- package/src/tools/shared/point/arrow.jsx +2 -1
- package/src/tools/shared/point/base-point.jsx +3 -1
- package/src/utils.js +18 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,38 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.4.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@2.4.6...@pie-lib/graphing@2.4.7) (2022-01-10)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-lib/graphing
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [2.4.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@2.4.5...@pie-lib/graphing@2.4.6) (2021-12-13)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @pie-lib/graphing
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [2.4.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@2.4.4...@pie-lib/graphing@2.4.5) (2021-11-29)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @pie-lib/graphing
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## [2.4.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@2.4.3...@pie-lib/graphing@2.4.4) (2021-09-08)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @pie-lib/graphing
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
6
38
|
## [2.4.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@2.4.2...@pie-lib/graphing@2.4.3) (2021-09-08)
|
|
7
39
|
|
|
8
40
|
**Note:** Version bump only for package @pie-lib/graphing
|
|
@@ -19,6 +19,8 @@ var _styles = require("@material-ui/core/styles");
|
|
|
19
19
|
|
|
20
20
|
var _arrowHead = require("../shared/arrow-head");
|
|
21
21
|
|
|
22
|
+
var _utils = require("../../utils");
|
|
23
|
+
|
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
25
|
|
|
24
26
|
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); }
|
|
@@ -69,6 +71,7 @@ var ArrowedLine = function ArrowedLine(props) {
|
|
|
69
71
|
|
|
70
72
|
var suffix = correctness || disabled && 'disabled' || 'enabled';
|
|
71
73
|
return _react["default"].createElement("g", null, _react["default"].createElement("defs", null, _react["default"].createElement(_arrowHead.ArrowMarker, {
|
|
74
|
+
size: (0, _utils.thinnerShapesNeeded)(graphProps) ? 4 : 5,
|
|
72
75
|
id: "".concat(props.markerId || markerId, "-").concat(suffix),
|
|
73
76
|
className: (0, _classnames["default"])(classes["".concat(suffix, "Arrow")])
|
|
74
77
|
})), _react["default"].createElement("line", _extends({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/tools/line/component.jsx"],"names":["markerId","lineStyles","theme","line","styles","enabledArrow","arrow","disabledArrow","disabled","correct","correctArrow","incorrect","incorrectArrow","ArrowedLine","props","className","classes","correctness","graphProps","from","to","rest","scale","trig","edges","domain","range","eFrom","eTo","suffix","x","y","propTypes","PropTypes","string","object","bool","types","GraphPropsType","PointType","StyledArrowedLine","Line","Component"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/tools/line/component.jsx"],"names":["markerId","lineStyles","theme","line","styles","enabledArrow","arrow","disabledArrow","disabled","correct","correctArrow","incorrect","incorrectArrow","ArrowedLine","props","className","classes","correctness","graphProps","from","to","rest","scale","trig","edges","domain","range","eFrom","eTo","suffix","x","y","propTypes","PropTypes","string","object","bool","types","GraphPropsType","PointType","StyledArrowedLine","Line","Component"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;AAEA,IAAMA,QAAQ,GAAG,wBAAjB;;AAEA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAAAC,KAAK;AAAA,SAAK;AAC3BC,IAAAA,IAAI,EAAEC,aAAOD,IAAP,CAAYD,KAAZ,CADqB;AAE3BG,IAAAA,YAAY,EAAED,aAAOE,KAAP,CAAaJ,KAAb,CAFa;AAG3BK,IAAAA,aAAa,EAAEH,aAAOG,aAAP,CAAqBL,KAArB,CAHY;AAI3BM,IAAAA,QAAQ,EAAEJ,aAAOI,QAAP,CAAgBN,KAAhB,CAJiB;AAK3BO,IAAAA,OAAO,EAAEL,aAAOK,OAAP,CAAeP,KAAf,EAAsB,QAAtB,CALkB;AAM3BQ,IAAAA,YAAY,EAAEN,aAAOK,OAAP,CAAeP,KAAf,CANa;AAO3BS,IAAAA,SAAS,EAAEP,aAAOO,SAAP,CAAiBT,KAAjB,EAAwB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AAGE,IAAA,EAAE,EAAET,KAAK,CAACQ,CAAN,CAAQF,GAAG,CAACE,CAAZ,CAHN;AAIE,IAAA,EAAE,EAAER,KAAK,CAACS,CAAN,CAAQH,GAAG,CAACG,CAAZ,CAJN;AAKE,IAAA,SAAS,EAAE,4BACTf,OAAO,CAACb,IADC,EAETK,QAAQ,IAAIQ,OAAO,CAACR,QAFX,EAGTQ,OAAO,CAACC,WAAD,CAHE,EAITF,SAJS,CALb;AAWE,IAAA,SAAS,iBAAUD,KAAK,CAACd,QAAN,IAAkBA,QAA5B,cAAwC6B,MAAxC,MAXX;AAYE,IAAA,WAAW,iBAAUf,KAAK,CAACd,QAAN,IAAkBA,QAA5B,cAAwC6B,MAAxC;AAZb,KAaMR,IAbN,EARF,CADF;AA0BD,CAhCM;;;AAkCPR,WAAW,CAACmB,SAAZ,GAAwB;AACtBjB,EAAAA,SAAS,EAAEkB,sBAAUC,MADC;AAEtBlB,EAAAA,OAAO,EAAEiB,sBAAUE,MAFG;AAGtBlB,EAAAA,WAAW,EAAEgB,sBAAUC,MAHD;AAItB1B,EAAAA,QAAQ,EAAEyB,sBAAUG,IAJE;AAKtBlB,EAAAA,UAAU,EAAEmB,YAAMC,cALI;AAMtBnB,EAAAA,IAAI,EAAEkB,YAAME,SANU;AAOtBnB,EAAAA,EAAE,EAAEiB,YAAME,SAPY;AAQtBvC,EAAAA,QAAQ,EAAEiC,sBAAUC;AARE,CAAxB;AAWA,IAAMM,iBAAiB,GAAG,wBAAWvC,UAAX,EAAuBY,WAAvB,CAA1B;AAEA,IAAM4B,IAAI,GAAG,oBAASD,iBAAT,CAAb;AACA,IAAME,SAAS,GAAG,6BAAkBD,IAAlB,CAAlB;eAEeC,S","sourcesContent":["import { lineToolComponent, lineBase, styles } from '../shared/line';\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { trig, types } from '@pie-lib/plot';\nimport classNames from 'classnames';\nimport { withStyles } from '@material-ui/core/styles';\nimport { ArrowMarker, genUid } from '../shared/arrow-head';\nimport { thinnerShapesNeeded } from '../../utils';\n\nconst markerId = genUid();\n\nconst lineStyles = theme => ({\n line: styles.line(theme),\n enabledArrow: styles.arrow(theme),\n disabledArrow: styles.disabledArrow(theme),\n disabled: styles.disabled(theme),\n correct: styles.correct(theme, 'stroke'),\n correctArrow: styles.correct(theme),\n incorrect: styles.incorrect(theme, 'stroke'),\n incorrectArrow: styles.incorrect(theme)\n});\nexport const ArrowedLine = props => {\n const { className, classes, correctness, disabled, graphProps, from, to, ...rest } = props;\n const { scale } = graphProps;\n const [eFrom, eTo] = trig.edges(graphProps.domain, graphProps.range)(from, to);\n const suffix = correctness || (disabled && 'disabled') || 'enabled';\n\n return (\n <g>\n <defs>\n <ArrowMarker\n size={thinnerShapesNeeded(graphProps) ? 4 : 5}\n id={`${props.markerId || markerId}-${suffix}`}\n className={classNames(classes[`${suffix}Arrow`])}\n />\n </defs>\n <line\n x1={scale.x(eFrom.x)}\n y1={scale.y(eFrom.y)}\n x2={scale.x(eTo.x)}\n y2={scale.y(eTo.y)}\n className={classNames(\n classes.line,\n disabled && classes.disabled,\n classes[correctness],\n className\n )}\n markerEnd={`url(#${props.markerId || markerId}-${suffix})`}\n markerStart={`url(#${props.markerId || markerId}-${suffix})`}\n {...rest}\n />\n </g>\n );\n};\n\nArrowedLine.propTypes = {\n className: PropTypes.string,\n classes: PropTypes.object,\n correctness: PropTypes.string,\n disabled: PropTypes.bool,\n graphProps: types.GraphPropsType,\n from: types.PointType,\n to: types.PointType,\n markerId: PropTypes.string\n};\n\nconst StyledArrowedLine = withStyles(lineStyles)(ArrowedLine);\n\nconst Line = lineBase(StyledArrowedLine);\nconst Component = lineToolComponent(Line);\n\nexport default Component;\n"],"file":"component.js"}
|
|
@@ -19,6 +19,8 @@ var _styles = require("@material-ui/core/styles");
|
|
|
19
19
|
|
|
20
20
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
21
21
|
|
|
22
|
+
var _utils = require("../../utils");
|
|
23
|
+
|
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
25
|
|
|
24
26
|
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); }
|
|
@@ -68,6 +70,7 @@ var RayLine = function RayLine(props) {
|
|
|
68
70
|
|
|
69
71
|
var suffix = correctness || disabled && 'disabled' || 'enabled';
|
|
70
72
|
return _react["default"].createElement("g", null, _react["default"].createElement("defs", null, _react["default"].createElement(_arrowHead.ArrowMarker, {
|
|
73
|
+
size: (0, _utils.thinnerShapesNeeded)(graphProps) ? 4 : 5,
|
|
71
74
|
id: "".concat(props.markerId || markerId, "-").concat(suffix),
|
|
72
75
|
className: (0, _classnames["default"])(classes["".concat(suffix, "Arrow")])
|
|
73
76
|
})), _react["default"].createElement("line", _extends({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/tools/ray/component.jsx"],"names":["markerId","rayStyles","theme","line","styles","enabledArrow","arrow","disabledArrow","disabled","correct","correctArrow","incorrect","incorrectArrow","RayLine","props","graphProps","from","to","classes","correctness","className","rest","scale","trig","edges","domain","range","aToB","suffix","x","y","propTypes","PropTypes","object","string","bool","any","types","PointType","StyledRay","Ray","Component"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;AAEA,IAAMA,QAAQ,GAAG,wBAAjB;;AAEA,IAAMC,SAAS,GAAG,SAAZA,SAAY,CAAAC,KAAK;AAAA,SAAK;AAC1BC,IAAAA,IAAI,EAAEC,aAAOD,IAAP,CAAYD,KAAZ,CADoB;AAE1BG,IAAAA,YAAY,EAAED,aAAOE,KAAP,CAAaJ,KAAb,CAFY;AAG1BK,IAAAA,aAAa,EAAEH,aAAOG,aAAP,CAAqBL,KAArB,CAHW;AAI1BM,IAAAA,QAAQ,EAAEJ,aAAOI,QAAP,CAAgBN,KAAhB,CAJgB;AAK1BO,IAAAA,OAAO,EAAEL,aAAOK,OAAP,CAAeP,KAAf,EAAsB,QAAtB,CALiB;AAM1BQ,IAAAA,YAAY,EAAEN,aAAOK,OAAP,CAAeP,KAAf,CANY;AAO1BS,IAAAA,SAAS,EAAEP,aAAOO,SAAP,CAAiBT,KAAjB,EAAwB,QAAxB,CAPe;AAQ1BU,IAAAA,cAAc,EAAER,aAAOO,SAAP,CAAiBT,KAAjB;AARU,GAAL;AAAA,CAAvB;;AAUO,IAAMW,OAAO,GAAG,SAAVA,OAAU,CAAAC,KAAK,EAAI;AAAA,MACtBC,UADsB,GACuDD,KADvD,CACtBC,UADsB;AAAA,MACVC,IADU,GACuDF,KADvD,CACVE,IADU;AAAA,MACJC,EADI,GACuDH,KADvD,CACJG,EADI;AAAA,MACAC,OADA,GACuDJ,KADvD,CACAI,OADA;AAAA,MACSV,QADT,GACuDM,KADvD,CACSN,QADT;AAAA,MACmBW,WADnB,GACuDL,KADvD,CACmBK,WADnB;AAAA,MACgCC,SADhC,GACuDN,KADvD,CACgCM,SADhC;AAAA,MAC8CC,IAD9C,4BACuDP,KADvD;;AAAA,MAEtBQ,KAFsB,GAEZP,UAFY,CAEtBO,KAFsB;;AAAA,oBAGfC,WAAKC,KAAL,CAAWT,UAAU,CAACU,MAAtB,EAA8BV,UAAU,CAACW,KAAzC,EAAgDV,IAAhD,EAAsDC,EAAtD,CAHe;AAAA;AAAA,MAGvBU,IAHuB;;AAI9B,MAAMC,MAAM,GAAGT,WAAW,IAAKX,QAAQ,IAAI,UAA5B,IAA2C,SAA1D;AAEA,SACE,2CACE,8CACE,gCAAC,sBAAD;AACE,IAAA,EAAE,
|
|
1
|
+
{"version":3,"sources":["../../../src/tools/ray/component.jsx"],"names":["markerId","rayStyles","theme","line","styles","enabledArrow","arrow","disabledArrow","disabled","correct","correctArrow","incorrect","incorrectArrow","RayLine","props","graphProps","from","to","classes","correctness","className","rest","scale","trig","edges","domain","range","aToB","suffix","x","y","propTypes","PropTypes","object","string","bool","any","types","PointType","StyledRay","Ray","Component"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;AAEA,IAAMA,QAAQ,GAAG,wBAAjB;;AAEA,IAAMC,SAAS,GAAG,SAAZA,SAAY,CAAAC,KAAK;AAAA,SAAK;AAC1BC,IAAAA,IAAI,EAAEC,aAAOD,IAAP,CAAYD,KAAZ,CADoB;AAE1BG,IAAAA,YAAY,EAAED,aAAOE,KAAP,CAAaJ,KAAb,CAFY;AAG1BK,IAAAA,aAAa,EAAEH,aAAOG,aAAP,CAAqBL,KAArB,CAHW;AAI1BM,IAAAA,QAAQ,EAAEJ,aAAOI,QAAP,CAAgBN,KAAhB,CAJgB;AAK1BO,IAAAA,OAAO,EAAEL,aAAOK,OAAP,CAAeP,KAAf,EAAsB,QAAtB,CALiB;AAM1BQ,IAAAA,YAAY,EAAEN,aAAOK,OAAP,CAAeP,KAAf,CANY;AAO1BS,IAAAA,SAAS,EAAEP,aAAOO,SAAP,CAAiBT,KAAjB,EAAwB,QAAxB,CAPe;AAQ1BU,IAAAA,cAAc,EAAER,aAAOO,SAAP,CAAiBT,KAAjB;AARU,GAAL;AAAA,CAAvB;;AAUO,IAAMW,OAAO,GAAG,SAAVA,OAAU,CAAAC,KAAK,EAAI;AAAA,MACtBC,UADsB,GACuDD,KADvD,CACtBC,UADsB;AAAA,MACVC,IADU,GACuDF,KADvD,CACVE,IADU;AAAA,MACJC,EADI,GACuDH,KADvD,CACJG,EADI;AAAA,MACAC,OADA,GACuDJ,KADvD,CACAI,OADA;AAAA,MACSV,QADT,GACuDM,KADvD,CACSN,QADT;AAAA,MACmBW,WADnB,GACuDL,KADvD,CACmBK,WADnB;AAAA,MACgCC,SADhC,GACuDN,KADvD,CACgCM,SADhC;AAAA,MAC8CC,IAD9C,4BACuDP,KADvD;;AAAA,MAEtB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EwB,sBAAUG,IAHF;AAIlBhB,EAAAA,WAAW,EAAEa,sBAAUE,MAJL;AAKlBnB,EAAAA,UAAU,EAAEiB,sBAAUI,GALJ;AAMlBpB,EAAAA,IAAI,EAAEqB,YAAMC,SANM;AAOlBrB,EAAAA,EAAE,EAAEoB,YAAMC,SAPQ;AAQlBtC,EAAAA,QAAQ,EAAEgC,sBAAUE;AARF,CAApB;AAWA,IAAMK,SAAS,GAAG,wBAAWtC,SAAX,EAAsBY,OAAtB,CAAlB;AAEA,IAAM2B,GAAG,GAAG,oBAASD,SAAT,CAAZ;AACA,IAAME,SAAS,GAAG,6BAAkBD,GAAlB,CAAlB;eAEeC,S","sourcesContent":["import { lineToolComponent, lineBase, styles } from '../shared/line';\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { ArrowMarker, genUid } from '../shared/arrow-head';\nimport { trig, types } from '@pie-lib/plot';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport { thinnerShapesNeeded } from '../../utils';\n\nconst markerId = genUid();\n\nconst rayStyles = theme => ({\n line: styles.line(theme),\n enabledArrow: styles.arrow(theme),\n disabledArrow: styles.disabledArrow(theme),\n disabled: styles.disabled(theme),\n correct: styles.correct(theme, 'stroke'),\n correctArrow: styles.correct(theme),\n incorrect: styles.incorrect(theme, 'stroke'),\n incorrectArrow: styles.incorrect(theme)\n});\nexport const RayLine = props => {\n const { graphProps, from, to, classes, disabled, correctness, className, ...rest } = props;\n const { scale } = graphProps;\n const [aToB] = trig.edges(graphProps.domain, graphProps.range)(from, to);\n const suffix = correctness || (disabled && 'disabled') || 'enabled';\n\n return (\n <g>\n <defs>\n <ArrowMarker\n size={thinnerShapesNeeded(graphProps) ? 4 : 5}\n id={`${props.markerId || markerId}-${suffix}`}\n className={classNames(classes[`${suffix}Arrow`])}\n />\n </defs>\n <line\n x1={scale.x(from.x)}\n y1={scale.y(from.y)}\n x2={scale.x(aToB.x)}\n y2={scale.y(aToB.y)}\n {...rest}\n className={classNames(\n classes.line,\n disabled && classes.disabled,\n classes[correctness],\n className\n )}\n markerEnd={`url(#${props.markerId || markerId}-${suffix})`}\n />\n </g>\n );\n};\n\nRayLine.propTypes = {\n classes: PropTypes.object,\n className: PropTypes.string,\n disabled: PropTypes.bool,\n correctness: PropTypes.string,\n graphProps: PropTypes.any,\n from: types.PointType,\n to: types.PointType,\n markerId: PropTypes.string\n};\n\nconst StyledRay = withStyles(rayStyles)(RayLine);\n\nconst Ray = lineBase(StyledRay);\nconst Component = lineToolComponent(Ray);\n\nexport default Component;\n"],"file":"component.js"}
|
|
@@ -15,6 +15,8 @@ var _plot = require("@pie-lib/plot");
|
|
|
15
15
|
|
|
16
16
|
var _arrowHead = require("../arrow-head");
|
|
17
17
|
|
|
18
|
+
var _utils = require("../../../utils");
|
|
19
|
+
|
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
21
|
|
|
20
22
|
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); }
|
|
@@ -91,7 +93,7 @@ function (_React$Component) {
|
|
|
91
93
|
graphProps = _this$props.graphProps,
|
|
92
94
|
rest = _objectWithoutProperties(_this$props, ["classes", "angle", "className", "x", "y", "disabled", "correctness", "graphProps"]);
|
|
93
95
|
|
|
94
|
-
var size = 14;
|
|
96
|
+
var size = (0, _utils.thinnerShapesNeeded)(graphProps) ? 12 : 14;
|
|
95
97
|
var scale = graphProps.scale;
|
|
96
98
|
var scaledX = scale.x(x);
|
|
97
99
|
var scaledY = scale.y(y);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/tools/shared/point/arrow.jsx"],"names":["Arrow","currentAngle","referenceAngle","x","y","breakpoint","firstBreakpoint","secondBreakpoint","t","props","classes","angle","className","disabled","correctness","graphProps","rest","size","scale","scaledX","scaledY","transform","points","getRotation","getRotationWithBreakpoint","point","React","Component","PropTypes","object","string","bool","number","isRequired","types","GraphPropsType"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEqBA,K;;;;;;;;;;;;;gCAYPC,Y,EAAcC,c,EAAgBC,C,EAAGC,C,EAAG;AAC9C,UAAMC,UAAU,GAAGH,cAAc,GAAG,EAApC;AACA,8BAAiB,CAACD,YAAD,IAAiBA,YAAY,GAAGI,UAAf,GAA4B,EAA5B,GAAiC,CAAlD,CAAjB,eAA0EF,CAA1E,cAA+EC,CAA/E;AACD;;;8CAEyBH,Y,EAAcC,c,EAAgBC,C,EAAGC,C,EAAG;AAC5D,UAAME,eAAe,GAAGJ,cAAc,GAAG,EAAzC;AACA,UAAMK,gBAAgB,GAAGL,cAAc,GAAG,EAA1C;AACA,UAAIM,CAAJ;;AACA,UAAIP,YAAY,IAAIK,eAAhB,IAAmCL,YAAY,GAAGM,gBAAtD,EAAwE;AACtEC,QAAAA,CAAC,GAAG,EAAJ;AACD,OAFD,MAEO,IAAIP,YAAY,GAAGM,gBAAnB,EAAqC;AAC1CC,QAAAA,CAAC,GAAG,CAAJ;AACD,OAFM,MAEA;AACLA,QAAAA,CAAC,GAAG,CAAJ;AACD;;AACD,8BAAiB,CAACP,YAAD,GAAgBO,CAAjC,eAAuCL,CAAvC,cAA4CC,CAA5C;AACD;;;6BAEQ;AAAA,wBAWH,KAAKK,KAXF;AAAA,UAELC,OAFK,eAELA,OAFK;AAAA,UAGLC,KAHK,eAGLA,KAHK;AAAA,UAILC,SAJK,eAILA,SAJK;AAAA,UAKLT,CALK,eAKLA,CALK;AAAA,UAMLC,CANK,eAMLA,CANK;AAAA,UAOLS,QAPK,eAOLA,QAPK;AAAA,UAQLC,WARK,eAQLA,WARK;AAAA,UASLC,UATK,eASLA,UATK;AAAA,UAUFC,IAVE;;AAaP,UAAMC,IAAI,GAAG,
|
|
1
|
+
{"version":3,"sources":["../../../../src/tools/shared/point/arrow.jsx"],"names":["Arrow","currentAngle","referenceAngle","x","y","breakpoint","firstBreakpoint","secondBreakpoint","t","props","classes","angle","className","disabled","correctness","graphProps","rest","size","scale","scaledX","scaledY","transform","points","getRotation","getRotationWithBreakpoint","point","React","Component","PropTypes","object","string","bool","number","isRequired","types","GraphPropsType"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEqBA,K;;;;;;;;;;;;;gCAYPC,Y,EAAcC,c,EAAgBC,C,EAAGC,C,EAAG;AAC9C,UAAMC,UAAU,GAAGH,cAAc,GAAG,EAApC;AACA,8BAAiB,CAACD,YAAD,IAAiBA,YAAY,GAAGI,UAAf,GAA4B,EAA5B,GAAiC,CAAlD,CAAjB,eAA0EF,CAA1E,cAA+EC,CAA/E;AACD;;;8CAEyBH,Y,EAAcC,c,EAAgBC,C,EAAGC,C,EAAG;AAC5D,UAAME,eAAe,GAAGJ,cAAc,GAAG,EAAzC;AACA,UAAMK,gBAAgB,GAAGL,cAAc,GAAG,EAA1C;AACA,UAAIM,CAAJ;;AACA,UAAIP,YAAY,IAAIK,eAAhB,IAAmCL,YAAY,GAAGM,gBAAtD,EAAwE;AACtEC,QAAAA,CAAC,GAAG,EAAJ;AACD,OAFD,MAEO,IAAIP,YAAY,GAAGM,gBAAnB,EAAqC;AAC1CC,QAAAA,CAAC,GAAG,CAAJ;AACD,OAFM,MAEA;AACLA,QAAAA,CAAC,GAAG,CAAJ;AACD;;AACD,8BAAiB,CAACP,YAAD,GAAgBO,CAAjC,eAAuCL,CAAvC,cAA4CC,CAA5C;AACD;;;6BAEQ;AAAA,wBAWH,KAAKK,KAXF;AAAA,UAELC,OAFK,eAELA,OAFK;AAAA,UAGLC,KAHK,eAGLA,KAHK;AAAA,UAILC,SAJK,eAILA,SAJK;AAAA,UAK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KAA/B,EAAsC,GAAtC,EAA2CQ,OAA3C,EAAoDC,OAApD,CAAZ;AACD;;AAED,aACE;AACE,QAAA,SAAS,EAAE,4BACTV,OAAO,CAACe,KADC,EAETZ,QAAQ,IAAIH,OAAO,CAACG,QAFX,EAGTH,OAAO,CAACI,WAAD,CAHE,EAITF,SAJS;AADb,SAOMI,IAPN,GASE,gCAAC,oBAAD;AAAW,QAAA,IAAI,EAAEC,IAAjB;AAAuB,QAAA,SAAS,EAAEI,SAAlC;AAA6C,QAAA,MAAM,EAAEC;AAArD,QATF,CADF;AAaD;;;;EA9EgCI,kBAAMC,S;;;;gBAApB3B,K,eACA;AACjBU,EAAAA,OAAO,EAAEkB,sBAAUC,MADF;AAEjBjB,EAAAA,SAAS,EAAEgB,sBAAUE,MAFJ;AAGjBhB,EAAAA,WAAW,EAAEc,sBAAUE,MAHN;AAIjBjB,EAAAA,QAAQ,EAAEe,sBAAUG,IAJH;AAKjB5B,EAAAA,CAAC,EAAEyB,sBAAUI,MAAV,CAAiBC,UALH;AAMjB7B,EAAAA,CAAC,EAAEwB,sBAAUI,MAAV,CAAiBC,UANH;AAOjBtB,EAAAA,KAAK,EAAEiB,sBAAUI,MAAV,CAAiBC,UAPP;AAQjBlB,EAAAA,UAAU,EAAEmB,YAAMC,cAAN,CAAqBF;AARhB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { types } from '@pie-lib/plot';\nimport { ArrowHead } from '../arrow-head';\nimport { thinnerShapesNeeded } from '../../../utils';\n\nexport default class Arrow extends React.Component {\n static propTypes = {\n classes: PropTypes.object,\n className: PropTypes.string,\n correctness: PropTypes.string,\n disabled: PropTypes.bool,\n x: PropTypes.number.isRequired,\n y: PropTypes.number.isRequired,\n angle: PropTypes.number.isRequired,\n graphProps: types.GraphPropsType.isRequired\n };\n\n getRotation(currentAngle, referenceAngle, x, y) {\n const breakpoint = referenceAngle + 10;\n return `rotate(${-currentAngle - (currentAngle > breakpoint ? 15 : 0)}, ${x},${y})`;\n }\n\n getRotationWithBreakpoint(currentAngle, referenceAngle, x, y) {\n const firstBreakpoint = referenceAngle + 10;\n const secondBreakpoint = referenceAngle + 65;\n let t;\n if (currentAngle >= firstBreakpoint && currentAngle < secondBreakpoint) {\n t = 15;\n } else if (currentAngle > secondBreakpoint) {\n t = 7;\n } else {\n t = 0;\n }\n return `rotate(${-currentAngle + t}, ${x},${y})`;\n }\n\n render() {\n const {\n classes,\n angle,\n className,\n x,\n y,\n disabled,\n correctness,\n graphProps,\n ...rest\n } = this.props;\n\n const size = thinnerShapesNeeded(graphProps) ? 12 : 14;\n const { scale } = graphProps;\n\n const scaledX = scale.x(x);\n const scaledY = scale.y(y);\n\n let transform;\n const points = `${scaledX},${scaledY}\n ${scaledX - size},${scaledY - size / 2}\n ${scaledX - size}, ${scaledY + size / 2}`;\n\n if (angle >= 0 && angle < 90) {\n transform = this.getRotation(angle, 0, scaledX, scaledY);\n } else if (angle >= 90 && angle < 180) {\n transform = this.getRotationWithBreakpoint(angle, 90, scaledX, scaledY);\n } else if (angle >= 180 && angle < 270) {\n transform = this.getRotation(angle, 180, scaledX, scaledY);\n } else {\n transform = this.getRotationWithBreakpoint(angle, 280, scaledX, scaledY);\n }\n\n return (\n <g\n className={classNames(\n classes.point,\n disabled && classes.disabled,\n classes[correctness],\n className\n )}\n {...rest}\n >\n <ArrowHead size={size} transform={transform} points={points} />\n </g>\n );\n }\n}\n"],"file":"arrow.js"}
|
|
@@ -17,6 +17,8 @@ var _coordinatesLabel = _interopRequireDefault(require("../../../coordinates-lab
|
|
|
17
17
|
|
|
18
18
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
19
19
|
|
|
20
|
+
var _utils = require("../../../utils");
|
|
21
|
+
|
|
20
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
23
|
|
|
22
24
|
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); }
|
|
@@ -81,6 +83,7 @@ function (_React$Component) {
|
|
|
81
83
|
|
|
82
84
|
var showCoordinates = this.state.showCoordinates;
|
|
83
85
|
var scale = graphProps.scale;
|
|
86
|
+
var r = (0, _utils.thinnerShapesNeeded)(graphProps) ? 5 : 7;
|
|
84
87
|
return _react["default"].createElement("g", _extends({
|
|
85
88
|
className: (0, _classnames["default"])(classes.point, disabled && classes.disabled, classes[correctness], className),
|
|
86
89
|
onMouseEnter: function onMouseEnter() {
|
|
@@ -94,7 +97,7 @@ function (_React$Component) {
|
|
|
94
97
|
});
|
|
95
98
|
}
|
|
96
99
|
}, rest), _react["default"].createElement("circle", {
|
|
97
|
-
r:
|
|
100
|
+
r: r,
|
|
98
101
|
cx: scale.x(x),
|
|
99
102
|
cy: scale.y(y)
|
|
100
103
|
}), labelNode && coordinatesOnHover && showCoordinates && _reactDom["default"].createPortal(_react["default"].createElement(_coordinatesLabel["default"], {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/tools/shared/point/base-point.jsx"],"names":["RawBp","props","state","showCoordinates","classes","className","coordinatesOnHover","x","y","disabled","correctness","graphProps","labelNode","rest","scale","point","setState","ReactDOM","createPortal","React","Component","PropTypes","object","string","bool","number","types","GraphPropsType","isRequired"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEaA,K;;;;;AAaX,iBAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AACjB,+EAAMA,KAAN;AACA,UAAKC,KAAL,GAAa;AAAEC,MAAAA,eAAe,EAAE;AAAnB,KAAb;AAFiB;AAGlB;;;;6BAEQ;AAAA;;AAAA,wBAYH,KAAKF,KAZF;AAAA,UAELG,OAFK,eAELA,OAFK;AAAA,UAGLC,SAHK,eAGLA,SAHK;AAAA,UAILC,kBAJK,eAILA,kBAJK;AAAA,UAKLC,CALK,eAKLA,CALK;AAAA,UAMLC,CANK,eAMLA,CANK;AAAA,UAOLC,QAPK,eAOLA,QAPK;AAAA,UAQLC,WARK,eAQLA,WARK;AAAA,UASLC,UATK,eASLA,UATK;AAAA,UAULC,SAVK,eAULA,SAVK;AAAA,UAWFC,IAXE;;AAAA,UAaCV,eAbD,GAaqB,KAAKD,KAb1B,CAaCC,eAbD;AAAA,UAcCW,KAdD,GAcWH,UAdX,CAcCG,KAdD;
|
|
1
|
+
{"version":3,"sources":["../../../../src/tools/shared/point/base-point.jsx"],"names":["RawBp","props","state","showCoordinates","classes","className","coordinatesOnHover","x","y","disabled","correctness","graphProps","labelNode","rest","scale","r","point","setState","ReactDOM","createPortal","React","Component","PropTypes","object","string","bool","number","types","GraphPropsType","isRequired"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEaA,K;;;;;AAaX,iBAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AACjB,+EAAMA,KAAN;AACA,UAAKC,KAAL,GAAa;AAAEC,MAAAA,eAAe,EAAE;AAAnB,KAAb;AAFiB;AAGlB;;;;6BAEQ;AAAA;;AAAA,wBAYH,KAAKF,KAZF;AAAA,UAELG,OAFK,eAELA,OAFK;AAAA,UAGLC,SAHK,eAGLA,SAHK;AAAA,UAILC,kBAJK,eAILA,kBAJK;AAAA,UAKLC,CALK,eAKLA,CALK;AAAA,UAMLC,CANK,eAMLA,CANK;AAAA,UAOLC,QAPK,eAOLA,QAPK;AAAA,UAQLC,WARK,eAQLA,WARK;AAAA,UASLC,UATK,eASLA,UATK;AAAA,UAULC,SAVK,eAULA,SAVK;AAAA,UAWFC,IAXE;;AAAA,UAaCV,eAbD,GAaqB,KAAKD,KAb1B,CAaCC,eAbD;AAAA,UAcCW,KAdD,GAc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I;AAQjBlB,EAAAA,CAAC,EAAEc,sBAAUI,MARI;AASjBf,EAAAA,UAAU,EAAEgB,YAAMC,cAAN,CAAqBC;AAThB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { types } from '@pie-lib/plot';\nimport CoordinatesLabel from '../../../coordinates-label';\nimport ReactDOM from 'react-dom';\nimport { thinnerShapesNeeded } from '../../../utils';\n\nexport class RawBp extends React.Component {\n static propTypes = {\n classes: PropTypes.object,\n className: PropTypes.string,\n coordinatesOnHover: PropTypes.bool,\n correctness: PropTypes.string,\n disabled: PropTypes.bool,\n labelNode: PropTypes.object,\n x: PropTypes.number,\n y: PropTypes.number,\n graphProps: types.GraphPropsType.isRequired\n };\n\n constructor(props) {\n super(props);\n this.state = { showCoordinates: false };\n }\n\n render() {\n const {\n classes,\n className,\n coordinatesOnHover,\n x,\n y,\n disabled,\n correctness,\n graphProps,\n labelNode,\n ...rest\n } = this.props;\n const { showCoordinates } = this.state;\n const { scale } = graphProps;\n const r = thinnerShapesNeeded(graphProps) ? 5 : 7;\n\n return (\n <g\n className={classNames(\n classes.point,\n disabled && classes.disabled,\n classes[correctness],\n className\n )}\n onMouseEnter={() => this.setState({ showCoordinates: true })}\n onMouseLeave={() => this.setState({ showCoordinates: false })}\n {...rest}\n >\n <circle r={r} cx={scale.x(x)} cy={scale.y(y)} />\n {labelNode &&\n coordinatesOnHover &&\n showCoordinates &&\n ReactDOM.createPortal(\n <CoordinatesLabel graphProps={graphProps} x={x} y={y} />,\n labelNode\n )}\n </g>\n );\n }\n}\n"],"file":"base-point.js"}
|
package/lib/utils.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.equalPoints = exports.sameAxes = exports.roundNumber = exports.getMiddleOfTwoPoints = exports.getRightestPoints = exports.isDomainRangeEqual = exports.pointsToArea = exports.lineToArea = exports.polygonToArea = exports.amountToIncreaseWidth = exports.findLongestWord = exports.countWords = exports.getTickValues = exports.arrowDimensions = exports.getAngleDeg = exports.point = exports.bounds = exports.tickCount = void 0;
|
|
6
|
+
exports.thinnerShapesNeeded = exports.equalPoints = exports.sameAxes = exports.roundNumber = exports.getMiddleOfTwoPoints = exports.getRightestPoints = exports.isDomainRangeEqual = exports.pointsToArea = exports.lineToArea = exports.polygonToArea = exports.amountToIncreaseWidth = exports.findLongestWord = exports.countWords = exports.getTickValues = exports.arrowDimensions = exports.getAngleDeg = exports.point = exports.bounds = exports.tickCount = void 0;
|
|
7
7
|
|
|
8
8
|
var _head = _interopRequireDefault(require("lodash/head"));
|
|
9
9
|
|
|
@@ -194,4 +194,24 @@ var equalPoints = function equalPoints(p1, p2) {
|
|
|
194
194
|
};
|
|
195
195
|
|
|
196
196
|
exports.equalPoints = equalPoints;
|
|
197
|
+
|
|
198
|
+
var getDistanceBetweenTicks = function getDistanceBetweenTicks(axis, size) {
|
|
199
|
+
var min = axis.min,
|
|
200
|
+
max = axis.max,
|
|
201
|
+
step = axis.step;
|
|
202
|
+
var nbOfTicks = (max - min) / step;
|
|
203
|
+
return size / nbOfTicks;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
var thinnerShapesNeeded = function thinnerShapesNeeded(graphProps) {
|
|
207
|
+
var domain = graphProps.domain,
|
|
208
|
+
range = graphProps.range,
|
|
209
|
+
_graphProps$size = graphProps.size,
|
|
210
|
+
width = _graphProps$size.width,
|
|
211
|
+
height = _graphProps$size.height; // 14 is the default width of a point
|
|
212
|
+
|
|
213
|
+
return getDistanceBetweenTicks(domain, width) < 14 || getDistanceBetweenTicks(range, height) < 14;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
exports.thinnerShapesNeeded = thinnerShapesNeeded;
|
|
197
217
|
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils.js"],"names":["tickCount","utils","bounds","point","getAngleDeg","arrowDimensions","getTickValues","prop","tickValues","tickVal","min","indexOf","push","Math","round","step","max","filter","tV","countWords","label","words","split","length","findLongestWord","longestWord","replace","sort","a","b","amountToIncreaseWidth","polygonToArea","points","h","area","left","x","top","y","bottom","right","reduce","p","lineToArea","from","to","pointsToArea","isDomainRangeEqual","graphProps","nextGraphProps","domain","range","getRightestPoints","sortedPoints","getMiddleOfTwoPoints","roundNumber","number","parseFloat","toFixed","sameAxes","p1","p2","equalPoints"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAEO,IAAMA,SAAS,GAAGC,YAAMD,SAAxB;;AACA,IAAME,MAAM,GAAGD,YAAMC,MAArB;;AACA,IAAMC,KAAK,GAAGF,YAAME,KAApB,C,CAEP;;;;AACO,IAAMC,WAAW,GAAG,SAAdA,WAAc;AAAA,SAAM,CAAN;AAAA,CAApB,C,CACP;;;;;AACO,IAAMC,eAAe,GAAG,SAAlBA,eAAkB;AAAA,SAAM,CAAN;AAAA,CAAxB;;;;AAEA,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAAAC,IAAI,EAAI;AACnC,MAAMC,UAAU,GAAG,EAAnB;AACA,MAAIC,OAAO,GAAG,CAAd;;AAEA,SAAOA,OAAO,IAAIF,IAAI,CAACG,GAAhB,IAAuBF,UAAU,CAACG,OAAX,CAAmBF,OAAnB,IAA8B,CAA5D,EAA+D;AAC7DD,IAAAA,UAAU,CAACI,IAAX,CAAgBH,OAAhB;AACAA,IAAAA,OAAO,GAAGI,IAAI,CAACC,KAAL,CAAW,CAACL,OAAO,GAAGF,IAAI,CAACQ,IAAhB,IAAwB,IAAnC,IAA2C,IAArD;AACD;;AAEDN,EAAAA,OAAO,GAAGI,IAAI,CAACC,KAAL,CAAWP,IAAI,CAACQ,IAAL,GAAY,IAAvB,IAA+B,IAAzC;;AAEA,SAAON,OAAO,IAAIF,IAAI,CAACS,GAAhB,IAAuBR,UA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AAIC,CAAJ;AAAA,SAAW;AAC7CO,IAAAA,CAAC,EAAE,CAACR,CAAC,CAACQ,CAAF,GAAMP,CAAC,CAACO,CAAT,IAAc,CAD4B;AAE7CE,IAAAA,CAAC,EAAE,CAACV,CAAC,CAACU,CAAF,GAAMT,CAAC,CAACS,CAAT,IAAc;AAF4B,GAAX;AAAA,CAA7B;;;;AAKA,IAAMiB,WAAW,GAAG,SAAdA,WAAc,CAAAC,MAAM;AAAA,SAAIC,UAAU,CAACD,MAAM,CAACE,OAAP,CAAe,CAAf,CAAD,CAAd;AAAA,CAA1B;;;;AAEA,IAAMC,QAAQ,GAAG,SAAXA,QAAW,CAACC,EAAD,EAAKC,EAAL;AAAA,SACtBD,EAAE,IAAIC,EAAN,KAAaN,WAAW,CAACK,EAAE,CAACxB,CAAJ,CAAX,KAAsBmB,WAAW,CAACM,EAAE,CAACzB,CAAJ,CAAjC,IAA2CmB,WAAW,CAACK,EAAE,CAACtB,CAAJ,CAAX,KAAsBiB,WAAW,CAACM,EAAE,CAACvB,CAAJ,CAAzF,CADsB;AAAA,CAAjB;;;;AAGA,IAAMwB,WAAW,GAAG,SAAdA,WAAc,CAACF,EAAD,EAAKC,EAAL;AAAA,SACzBD,EAAE,IACFC,EADA,IAEA,yBACE;AACEzB,IAAAA,CAAC,EAAEmB,WAAW,CAACK,EAAE,CAACxB,CAAJ,CADhB;AAEEE,IAAAA,CAAC,EAAEiB,WAAW,CAACK,EAAE,CAACtB,CAAJ;AAFhB,GADF,EAKE;AACEF,IAAAA,CAAC,EAAEmB,WAAW,CAACM,EAAE,CAACzB,CAAJ,CADhB;AAEEE,IAAAA,CAAC,EAAEiB,WAAW,CAACM,EAAE,CAACvB,CAAJ;AAFhB,GALF,CAHyB;AAAA,CAApB","sourcesContent":["import head from 'lodash/head';\nimport tail from 'lodash/tail';\nimport { utils } from '@pie-lib/plot';\nimport invariant from 'invariant';\nimport isEqual from 'lodash/isEqual';\nimport isEmpty from 'lodash/isEmpty';\nimport cloneDeep from 'lodash/cloneDeep';\n\nexport const tickCount = utils.tickCount;\nexport const bounds = utils.bounds;\nexport const point = utils.point;\n\n//TODO: This can be removed?\nexport const getAngleDeg = () => 0;\n//TODO: This can be removed?\nexport const arrowDimensions = () => 0;\n\nexport const getTickValues = prop => {\n const tickValues = [];\n let tickVal = 0;\n\n while (tickVal >= prop.min && tickValues.indexOf(tickVal) < 0) {\n tickValues.push(tickVal);\n tickVal = Math.round((tickVal - prop.step) * 1000) / 1000;\n }\n\n tickVal = Math.round(prop.step * 1000) / 1000;\n\n while (tickVal <= prop.max && tickValues.indexOf(tickVal) < 0) {\n tickValues.push(tickVal);\n tickVal = Math.round((tickVal + prop.step) * 1000) / 1000;\n }\n\n // return only ticks that are inside the min-max interval\n if (tickValues) {\n return tickValues.filter(tV => tV >= prop.min && tV <= prop.max);\n }\n\n return [];\n};\n\nexport const countWords = label => {\n if (label == null || isEmpty(label)) {\n return 1;\n }\n\n const words = label.split(' ');\n return words.length;\n};\n\n// findLongestWord is also used in plot\nexport const findLongestWord = label => {\n let longestWord = (label || '')\n .replace(/<[^>]+>/g, '')\n .split(' ')\n .sort((a, b) => b.length - a.length);\n\n return longestWord[0].length;\n};\n\n// amountToIncreaseWidth is also used in plot\nexport const amountToIncreaseWidth = longestWord => {\n if (!longestWord) {\n return 0;\n }\n\n return longestWord * 10;\n};\n\nexport const polygonToArea = points => {\n const h = head(points);\n const area = {\n left: h.x,\n top: h.y,\n bottom: h.y,\n right: h.x\n };\n return tail(points).reduce((a, p) => {\n a.left = Math.min(a.left, p.x);\n a.top = Math.max(a.top, p.y);\n a.bottom = Math.min(a.bottom, p.y);\n a.right = Math.max(a.right, p.x);\n return a;\n }, area);\n};\n\nexport const lineToArea = (from, to) => pointsToArea(from, to);\n\nexport const pointsToArea = (a, b) => {\n invariant(!!a && !!b, 'a or b is undefined');\n const left = Math.min(a.x, b.x);\n const top = Math.max(a.y, b.y);\n const bottom = Math.min(a.y, b.y);\n const right = Math.max(a.x, b.x);\n return { left, top, bottom, right };\n};\n\nexport const isDomainRangeEqual = (graphProps, nextGraphProps) => {\n return (\n isEqual(graphProps.domain, nextGraphProps.domain) &&\n isEqual(graphProps.range, nextGraphProps.range)\n );\n};\n\nexport const getRightestPoints = points => {\n const sortedPoints = cloneDeep(points);\n sortedPoints.sort((a, b) => b.x - a.x);\n\n return { a: sortedPoints[0], b: sortedPoints[1] };\n};\n\nexport const getMiddleOfTwoPoints = (a, b) => ({\n x: (a.x + b.x) / 2,\n y: (a.y + b.y) / 2\n});\n\nexport const roundNumber = number => parseFloat(number.toFixed(3));\n\nexport const sameAxes = (p1, p2) =>\n p1 && p2 && (roundNumber(p1.x) === roundNumber(p2.x) || roundNumber(p1.y) === roundNumber(p2.y));\n\nexport const equalPoints = (p1, p2) =>\n p1 &&\n p2 &&\n isEqual(\n {\n x: roundNumber(p1.x),\n y: roundNumber(p1.y)\n },\n {\n x: roundNumber(p2.x),\n y: roundNumber(p2.y)\n }\n );\n"],"file":"utils.js"}
|
|
1
|
+
{"version":3,"sources":["../src/utils.js"],"names":["tickCount","utils","bounds","point","getAngleDeg","arrowDimensions","getTickValues","prop","tickValues","tickVal","min","indexOf","push","Math","round","step","max","filter","tV","countWords","label","words","split","length","findLongestWord","longestWord","replace","sort","a","b","amountToIncreaseWidth","polygonToArea","points","h","area","left","x","top","y","bottom","right","reduce","p","lineToArea","from","to","pointsToArea","isDomainRangeEqual","graphProps","nextGraphProps","domain","range","getRightestPoints","sortedPoints","getMiddleOfTwoPoints","roundNumber","number","parseFloat","toFixed","sameAxes","p1","p2","equalPoints","getDistanceBetweenTicks","axis","size","nbOfTicks","thinnerShapesNeeded","width","height"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAEO,IAAMA,SAAS,GAAGC,YAAMD,SAAxB;;AACA,IAAME,MAAM,GAAGD,YAAMC,MAArB;;AACA,IAAMC,KAAK,GAAGF,YAAME,KAApB,C,CAEP;;;;AACO,IAA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CAACb,MAAD,EAASkB,KAAT,CAAvB,GAAyC,EAAzC,IAA+CL,uBAAuB,CAACZ,KAAD,EAAQkB,MAAR,CAAvB,GAAyC,EAA/F;AACD,CATM","sourcesContent":["import head from 'lodash/head';\nimport tail from 'lodash/tail';\nimport { utils } from '@pie-lib/plot';\nimport invariant from 'invariant';\nimport isEqual from 'lodash/isEqual';\nimport isEmpty from 'lodash/isEmpty';\nimport cloneDeep from 'lodash/cloneDeep';\n\nexport const tickCount = utils.tickCount;\nexport const bounds = utils.bounds;\nexport const point = utils.point;\n\n//TODO: This can be removed?\nexport const getAngleDeg = () => 0;\n//TODO: This can be removed?\nexport const arrowDimensions = () => 0;\n\nexport const getTickValues = prop => {\n const tickValues = [];\n let tickVal = 0;\n\n while (tickVal >= prop.min && tickValues.indexOf(tickVal) < 0) {\n tickValues.push(tickVal);\n tickVal = Math.round((tickVal - prop.step) * 1000) / 1000;\n }\n\n tickVal = Math.round(prop.step * 1000) / 1000;\n\n while (tickVal <= prop.max && tickValues.indexOf(tickVal) < 0) {\n tickValues.push(tickVal);\n tickVal = Math.round((tickVal + prop.step) * 1000) / 1000;\n }\n\n // return only ticks that are inside the min-max interval\n if (tickValues) {\n return tickValues.filter(tV => tV >= prop.min && tV <= prop.max);\n }\n\n return [];\n};\n\nexport const countWords = label => {\n if (label == null || isEmpty(label)) {\n return 1;\n }\n\n const words = label.split(' ');\n return words.length;\n};\n\n// findLongestWord is also used in plot\nexport const findLongestWord = label => {\n let longestWord = (label || '')\n .replace(/<[^>]+>/g, '')\n .split(' ')\n .sort((a, b) => b.length - a.length);\n\n return longestWord[0].length;\n};\n\n// amountToIncreaseWidth is also used in plot\nexport const amountToIncreaseWidth = longestWord => {\n if (!longestWord) {\n return 0;\n }\n\n return longestWord * 10;\n};\n\nexport const polygonToArea = points => {\n const h = head(points);\n const area = {\n left: h.x,\n top: h.y,\n bottom: h.y,\n right: h.x\n };\n return tail(points).reduce((a, p) => {\n a.left = Math.min(a.left, p.x);\n a.top = Math.max(a.top, p.y);\n a.bottom = Math.min(a.bottom, p.y);\n a.right = Math.max(a.right, p.x);\n return a;\n }, area);\n};\n\nexport const lineToArea = (from, to) => pointsToArea(from, to);\n\nexport const pointsToArea = (a, b) => {\n invariant(!!a && !!b, 'a or b is undefined');\n const left = Math.min(a.x, b.x);\n const top = Math.max(a.y, b.y);\n const bottom = Math.min(a.y, b.y);\n const right = Math.max(a.x, b.x);\n return { left, top, bottom, right };\n};\n\nexport const isDomainRangeEqual = (graphProps, nextGraphProps) => {\n return (\n isEqual(graphProps.domain, nextGraphProps.domain) &&\n isEqual(graphProps.range, nextGraphProps.range)\n );\n};\n\nexport const getRightestPoints = points => {\n const sortedPoints = cloneDeep(points);\n sortedPoints.sort((a, b) => b.x - a.x);\n\n return { a: sortedPoints[0], b: sortedPoints[1] };\n};\n\nexport const getMiddleOfTwoPoints = (a, b) => ({\n x: (a.x + b.x) / 2,\n y: (a.y + b.y) / 2\n});\n\nexport const roundNumber = number => parseFloat(number.toFixed(3));\n\nexport const sameAxes = (p1, p2) =>\n p1 && p2 && (roundNumber(p1.x) === roundNumber(p2.x) || roundNumber(p1.y) === roundNumber(p2.y));\n\nexport const equalPoints = (p1, p2) =>\n p1 &&\n p2 &&\n isEqual(\n {\n x: roundNumber(p1.x),\n y: roundNumber(p1.y)\n },\n {\n x: roundNumber(p2.x),\n y: roundNumber(p2.y)\n }\n );\n\nconst getDistanceBetweenTicks = (axis, size) => {\n const { min, max, step } = axis;\n const nbOfTicks = (max - min) / step;\n\n return size / nbOfTicks;\n};\n\nexport const thinnerShapesNeeded = graphProps => {\n const {\n domain,\n range,\n size: { width, height }\n } = graphProps;\n\n // 14 is the default width of a point\n return getDistanceBetweenTicks(domain, width) < 14 || getDistanceBetweenTicks(range, height) < 14;\n};\n"],"file":"utils.js"}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "2.4.
|
|
6
|
+
"version": "2.4.7",
|
|
7
7
|
"description": "Graphing components",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"react",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@material-ui/core": "^3.8.3",
|
|
21
21
|
"@pie-lib/graphing-utils": "^1.1.20",
|
|
22
22
|
"@pie-lib/plot": "^2.1.9",
|
|
23
|
-
"@pie-lib/render-ui": "^4.12.
|
|
23
|
+
"@pie-lib/render-ui": "^4.12.4",
|
|
24
24
|
"@vx/axis": "^0.0.189",
|
|
25
25
|
"@vx/clip-path": "^0.0.189",
|
|
26
26
|
"@vx/event": "^0.0.189",
|
|
@@ -43,6 +43,6 @@
|
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react": "^16.8.1"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "777edfa035a9a3da7c25e266db5b4cc8a209c726",
|
|
47
47
|
"scripts": {}
|
|
48
48
|
}
|
|
@@ -5,6 +5,8 @@ import { trig, types } from '@pie-lib/plot';
|
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
import { withStyles } from '@material-ui/core/styles';
|
|
7
7
|
import { ArrowMarker, genUid } from '../shared/arrow-head';
|
|
8
|
+
import { thinnerShapesNeeded } from '../../utils';
|
|
9
|
+
|
|
8
10
|
const markerId = genUid();
|
|
9
11
|
|
|
10
12
|
const lineStyles = theme => ({
|
|
@@ -27,6 +29,7 @@ export const ArrowedLine = props => {
|
|
|
27
29
|
<g>
|
|
28
30
|
<defs>
|
|
29
31
|
<ArrowMarker
|
|
32
|
+
size={thinnerShapesNeeded(graphProps) ? 4 : 5}
|
|
30
33
|
id={`${props.markerId || markerId}-${suffix}`}
|
|
31
34
|
className={classNames(classes[`${suffix}Arrow`])}
|
|
32
35
|
/>
|
|
@@ -5,6 +5,7 @@ import { ArrowMarker, genUid } from '../shared/arrow-head';
|
|
|
5
5
|
import { trig, types } from '@pie-lib/plot';
|
|
6
6
|
import { withStyles } from '@material-ui/core/styles';
|
|
7
7
|
import classNames from 'classnames';
|
|
8
|
+
import { thinnerShapesNeeded } from '../../utils';
|
|
8
9
|
|
|
9
10
|
const markerId = genUid();
|
|
10
11
|
|
|
@@ -28,6 +29,7 @@ export const RayLine = props => {
|
|
|
28
29
|
<g>
|
|
29
30
|
<defs>
|
|
30
31
|
<ArrowMarker
|
|
32
|
+
size={thinnerShapesNeeded(graphProps) ? 4 : 5}
|
|
31
33
|
id={`${props.markerId || markerId}-${suffix}`}
|
|
32
34
|
className={classNames(classes[`${suffix}Arrow`])}
|
|
33
35
|
/>
|
|
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { types } from '@pie-lib/plot';
|
|
5
5
|
import { ArrowHead } from '../arrow-head';
|
|
6
|
+
import { thinnerShapesNeeded } from '../../../utils';
|
|
6
7
|
|
|
7
8
|
export default class Arrow extends React.Component {
|
|
8
9
|
static propTypes = {
|
|
@@ -48,7 +49,7 @@ export default class Arrow extends React.Component {
|
|
|
48
49
|
...rest
|
|
49
50
|
} = this.props;
|
|
50
51
|
|
|
51
|
-
const size = 14;
|
|
52
|
+
const size = thinnerShapesNeeded(graphProps) ? 12 : 14;
|
|
52
53
|
const { scale } = graphProps;
|
|
53
54
|
|
|
54
55
|
const scaledX = scale.x(x);
|
|
@@ -4,6 +4,7 @@ import classNames from 'classnames';
|
|
|
4
4
|
import { types } from '@pie-lib/plot';
|
|
5
5
|
import CoordinatesLabel from '../../../coordinates-label';
|
|
6
6
|
import ReactDOM from 'react-dom';
|
|
7
|
+
import { thinnerShapesNeeded } from '../../../utils';
|
|
7
8
|
|
|
8
9
|
export class RawBp extends React.Component {
|
|
9
10
|
static propTypes = {
|
|
@@ -38,6 +39,7 @@ export class RawBp extends React.Component {
|
|
|
38
39
|
} = this.props;
|
|
39
40
|
const { showCoordinates } = this.state;
|
|
40
41
|
const { scale } = graphProps;
|
|
42
|
+
const r = thinnerShapesNeeded(graphProps) ? 5 : 7;
|
|
41
43
|
|
|
42
44
|
return (
|
|
43
45
|
<g
|
|
@@ -51,7 +53,7 @@ export class RawBp extends React.Component {
|
|
|
51
53
|
onMouseLeave={() => this.setState({ showCoordinates: false })}
|
|
52
54
|
{...rest}
|
|
53
55
|
>
|
|
54
|
-
<circle r=
|
|
56
|
+
<circle r={r} cx={scale.x(x)} cy={scale.y(y)} />
|
|
55
57
|
{labelNode &&
|
|
56
58
|
coordinatesOnHover &&
|
|
57
59
|
showCoordinates &&
|
package/src/utils.js
CHANGED
|
@@ -132,3 +132,21 @@ export const equalPoints = (p1, p2) =>
|
|
|
132
132
|
y: roundNumber(p2.y)
|
|
133
133
|
}
|
|
134
134
|
);
|
|
135
|
+
|
|
136
|
+
const getDistanceBetweenTicks = (axis, size) => {
|
|
137
|
+
const { min, max, step } = axis;
|
|
138
|
+
const nbOfTicks = (max - min) / step;
|
|
139
|
+
|
|
140
|
+
return size / nbOfTicks;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export const thinnerShapesNeeded = graphProps => {
|
|
144
|
+
const {
|
|
145
|
+
domain,
|
|
146
|
+
range,
|
|
147
|
+
size: { width, height }
|
|
148
|
+
} = graphProps;
|
|
149
|
+
|
|
150
|
+
// 14 is the default width of a point
|
|
151
|
+
return getDistanceBetweenTicks(domain, width) < 14 || getDistanceBetweenTicks(range, height) < 14;
|
|
152
|
+
};
|