@pie-lib/charting 4.5.6 → 4.5.11-next.256
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 +105 -0
- package/CHANGELOG.md +16 -20
- package/lib/axes.js +84 -36
- 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 +55 -37
- 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 +38 -30
- 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 +37 -11
- 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 +79 -26
- package/lib/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/axes.jsx +72 -29
- package/src/chart.jsx +31 -6
- package/src/line/common/line.jsx +1 -1
- package/src/mark-label.jsx +15 -4
- package/src/utils.js +75 -19
|
@@ -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","primaryLight","line","stroke","Plot","data","d","category","array"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,oBAAN,CAAZ;;IAEaC,O;;;;;AAiBX,mBAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AACjB,8BAAMA,KAAN;;AADiB,mEAOJ,UAAAC,SAAS;AAAA,aAAI,MAAKC,QAAL,CAAc;AAAED,QAAAA,SAAS,EAATA;AAAF,OAAd,CAAJ;AAAA,KAPL;;AAAA,+DASR,YAAM;AACf,wBAAoC,MAAKD,KAAzC;AAAA,UAAQG,KAAR,eAAQA,KAAR;AAAA,UAAeC,gBAAf,eAAeA,gBAAf;AACA,UAAQH,SAAR,GAAsB,MAAKI,KAA3B,CAAQJ,SAAR;AACAH,MAAAA,GAAG,CAAC,YAAD,EAAeG,SAAf,CAAH;;AAEA,UAAIA,SAAS,KAAKK,SAAlB,EAA6B;AAC3BF,QAAAA,gBAAgB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AMC,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"}
|
package/lib/plot/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
|
});
|
|
@@ -19,25 +21,27 @@ var _shape = require("@vx/shape");
|
|
|
19
21
|
|
|
20
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
23
|
|
|
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); }
|
|
23
|
-
|
|
24
24
|
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); }
|
|
25
25
|
|
|
26
26
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
27
27
|
|
|
28
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); } }
|
|
29
29
|
|
|
30
|
-
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; }
|
|
31
31
|
|
|
32
|
-
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); }
|
|
33
33
|
|
|
34
|
-
function
|
|
34
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
35
35
|
|
|
36
|
-
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); }; }
|
|
37
37
|
|
|
38
|
-
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); }
|
|
39
39
|
|
|
40
|
-
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); }
|
|
41
45
|
|
|
42
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; }
|
|
43
47
|
|
|
@@ -54,7 +58,7 @@ var CustomBarElement = function CustomBarElement(props) {
|
|
|
54
58
|
var r = pointDiameter / 2;
|
|
55
59
|
var cx = barX + (barWidth - pointDiameter) / 2 + r;
|
|
56
60
|
var cy = scale.y(index) - (pointHeight - pointDiameter) / 2 - r;
|
|
57
|
-
return _react["default"].createElement(_shape.Circle, {
|
|
61
|
+
return /*#__PURE__*/_react["default"].createElement(_shape.Circle, {
|
|
58
62
|
key: "point-".concat(label, "-").concat(value, "-").concat(index),
|
|
59
63
|
className: classes.dot,
|
|
60
64
|
cx: cx,
|
|
@@ -75,15 +79,15 @@ CustomBarElement.propTypes = {
|
|
|
75
79
|
scale: _propTypes["default"].object
|
|
76
80
|
};
|
|
77
81
|
|
|
78
|
-
var DotPlot =
|
|
79
|
-
/*#__PURE__*/
|
|
80
|
-
function (_React$Component) {
|
|
82
|
+
var DotPlot = /*#__PURE__*/function (_React$Component) {
|
|
81
83
|
_inherits(DotPlot, _React$Component);
|
|
82
84
|
|
|
85
|
+
var _super = _createSuper(DotPlot);
|
|
86
|
+
|
|
83
87
|
function DotPlot() {
|
|
84
88
|
_classCallCheck(this, DotPlot);
|
|
85
89
|
|
|
86
|
-
return
|
|
90
|
+
return _super.apply(this, arguments);
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
_createClass(DotPlot, [{
|
|
@@ -100,7 +104,7 @@ function (_React$Component) {
|
|
|
100
104
|
size = _ref$size === void 0 ? {} : _ref$size;
|
|
101
105
|
|
|
102
106
|
var xBand = (0, _utils.dataToXBand)(scale.x, data, size.width, 'dotPlot');
|
|
103
|
-
return _react["default"].createElement(_plot2["default"], _extends({}, props, {
|
|
107
|
+
return /*#__PURE__*/_react["default"].createElement(_plot2["default"], _extends({}, props, {
|
|
104
108
|
xBand: xBand,
|
|
105
109
|
CustomBarElement: CustomBarElement
|
|
106
110
|
}));
|
package/lib/plot/dot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plot/dot.js"],"names":["CustomBarElement","props","index","pointDiameter","barX","barWidth","pointHeight","label","value","classes","scale","r","cx","cy","y","dot","propTypes","PropTypes","number","string","object","DotPlot","data","graphProps","size","xBand","x","width","React","Component","array","onChange","func","types","GraphPropsType","isRequired","type","name"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/plot/dot.js"],"names":["CustomBarElement","props","index","pointDiameter","barX","barWidth","pointHeight","label","value","classes","scale","r","cx","cy","y","dot","propTypes","PropTypes","number","string","object","DotPlot","data","graphProps","size","xBand","x","width","React","Component","array","onChange","func","types","GraphPropsType","isRequired","type","name"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,gBAAgB,GAAG,SAAnBA,gBAAmB,CAAAC,KAAK,EAAI;AAChC,MAAQC,KAAR,GAA4FD,KAA5F,CAAQC,KAAR;AAAA,MAAeC,aAAf,GAA4FF,KAA5F,CAAeE,aAAf;AAAA,MAA8BC,IAA9B,GAA4FH,KAA5F,CAA8BG,IAA9B;AAAA,MAAoCC,QAApC,GAA4FJ,KAA5F,CAAoCI,QAApC;AAAA,MAA8CC,WAA9C,GAA4FL,KAA5F,CAA8CK,WAA9C;AAAA,MAA2DC,KAA3D,GAA4FN,KAA5F,CAA2DM,KAA3D;AAAA,MAAkEC,KAAlE,GAA4FP,KAA5F,CAAkEO,KAAlE;AAAA,MAAyEC,OAAzE,GAA4FR,KAA5F,CAAyEQ,OAAzE;AAAA,MAAkFC,KAAlF,GAA4FT,KAA5F,CAAkFS,KAAlF;AAEA,MAAMC,CAAC,GAAGR,aAAa,GAAG,CAA1B;AACA,MAAMS,EAAE,GAAGR,IAAI,GAAG,CAACC,QAAQ,GAAGF,aAAZ,IAA6B,CAApC,GAAwCQ,CAAnD;AACA,MAAME,EAAE,GAAGH,KAAK,CAACI,CAAN,CAAQZ,KAAR,IAAiB,CAACI,WAAW,GAAGH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EAAEwB,KAAxB;AAA+B,QAAA,gBAAgB,EAAEzB;AAAjD,SAAP;AACD;;;;EAd0B4B,kBAAMC,S;;;;gBAAtBR,O,eACQ;AACjBC,EAAAA,IAAI,EAAEL,sBAAUa,KADC;AAEjBC,EAAAA,QAAQ,EAAEd,sBAAUe,IAFH;AAGjBT,EAAAA,UAAU,EAAEU,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 Plot from './common/plot';\nimport { Circle } from '@vx/shape';\n\nconst CustomBarElement = props => {\n const { index, pointDiameter, barX, barWidth, pointHeight, label, value, classes, scale } = props;\n\n const r = pointDiameter / 2;\n const cx = barX + (barWidth - pointDiameter) / 2 + r;\n const cy = scale.y(index) - (pointHeight - pointDiameter) / 2 - r;\n\n return (\n <Circle\n key={`point-${label}-${value}-${index}`}\n className={classes.dot}\n cx={cx}\n cy={cy}\n r={r}\n />\n );\n};\n\nCustomBarElement.propTypes = {\n index: PropTypes.number,\n pointDiameter: PropTypes.number,\n barX: PropTypes.number,\n barWidth: PropTypes.number,\n pointHeight: PropTypes.number,\n value: PropTypes.number,\n label: PropTypes.string,\n classes: PropTypes.object,\n scale: PropTypes.object\n};\n\nexport class DotPlot 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, 'dotPlot');\n\n return <Plot {...props} xBand={xBand} CustomBarElement={CustomBarElement} />;\n }\n}\n\nexport default () => ({\n type: 'dotPlot',\n Component: DotPlot,\n name: 'Dot Plot'\n});\n"],"file":"dot.js"}
|
package/lib/plot/line.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,27 @@ var _group = require("@vx/group");
|
|
|
21
23
|
|
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
25
|
|
|
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); }
|
|
25
|
-
|
|
26
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); }
|
|
27
27
|
|
|
28
28
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
29
29
|
|
|
30
30
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
31
31
|
|
|
32
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
32
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
33
33
|
|
|
34
|
-
function
|
|
34
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
35
35
|
|
|
36
|
-
function
|
|
36
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
37
37
|
|
|
38
|
-
function
|
|
38
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
39
39
|
|
|
40
|
-
function
|
|
40
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
41
41
|
|
|
42
|
-
function
|
|
42
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
43
|
+
|
|
44
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
45
|
+
|
|
46
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
43
47
|
|
|
44
48
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
45
49
|
|
|
@@ -55,7 +59,7 @@ var CustomBarElement = function CustomBarElement(props) {
|
|
|
55
59
|
scale = props.scale;
|
|
56
60
|
var x = barX + (barWidth - pointDiameter) / 2;
|
|
57
61
|
var y = scale.y(index) - (pointHeight - pointDiameter) / 2;
|
|
58
|
-
return _react["default"].createElement(_group.Group, null, _react["default"].createElement(_shape.LinePath, {
|
|
62
|
+
return /*#__PURE__*/_react["default"].createElement(_group.Group, null, /*#__PURE__*/_react["default"].createElement(_shape.LinePath, {
|
|
59
63
|
data: [{
|
|
60
64
|
x: x,
|
|
61
65
|
y: y
|
|
@@ -72,7 +76,7 @@ var CustomBarElement = function CustomBarElement(props) {
|
|
|
72
76
|
return d.y;
|
|
73
77
|
},
|
|
74
78
|
strokeWidth: pointDiameter / 5
|
|
75
|
-
}), _react["default"].createElement(_shape.LinePath, {
|
|
79
|
+
}), /*#__PURE__*/_react["default"].createElement(_shape.LinePath, {
|
|
76
80
|
data: [{
|
|
77
81
|
x: x,
|
|
78
82
|
y: y - pointDiameter
|
|
@@ -104,15 +108,15 @@ CustomBarElement.propTypes = {
|
|
|
104
108
|
scale: _propTypes["default"].object
|
|
105
109
|
};
|
|
106
110
|
|
|
107
|
-
var LinePlot =
|
|
108
|
-
/*#__PURE__*/
|
|
109
|
-
function (_React$Component) {
|
|
111
|
+
var LinePlot = /*#__PURE__*/function (_React$Component) {
|
|
110
112
|
_inherits(LinePlot, _React$Component);
|
|
111
113
|
|
|
114
|
+
var _super = _createSuper(LinePlot);
|
|
115
|
+
|
|
112
116
|
function LinePlot() {
|
|
113
117
|
_classCallCheck(this, LinePlot);
|
|
114
118
|
|
|
115
|
-
return
|
|
119
|
+
return _super.apply(this, arguments);
|
|
116
120
|
}
|
|
117
121
|
|
|
118
122
|
_createClass(LinePlot, [{
|
|
@@ -129,7 +133,7 @@ function (_React$Component) {
|
|
|
129
133
|
size = _ref$size === void 0 ? {} : _ref$size;
|
|
130
134
|
|
|
131
135
|
var xBand = (0, _utils.dataToXBand)(scale.x, data, size.width, 'linePlot');
|
|
132
|
-
return _react["default"].createElement(_plot2["default"], _extends({}, props, {
|
|
136
|
+
return /*#__PURE__*/_react["default"].createElement(_plot2["default"], _extends({}, props, {
|
|
133
137
|
xBand: xBand,
|
|
134
138
|
CustomBarElement: CustomBarElement
|
|
135
139
|
}));
|
package/lib/plot/line.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plot/line.js"],"names":["CustomBarElement","props","index","pointDiameter","barX","barWidth","pointHeight","label","value","classes","scale","x","y","line","d","propTypes","PropTypes","number","string","object","LinePlot","data","graphProps","size","xBand","width","React","Component","array","onChange","func","types","GraphPropsType","isRequired","type","name"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/plot/line.js"],"names":["CustomBarElement","props","index","pointDiameter","barX","barWidth","pointHeight","label","value","classes","scale","x","y","line","d","propTypes","PropTypes","number","string","object","LinePlot","data","graphProps","size","xBand","width","React","Component","array","onChange","func","types","GraphPropsType","isRequired","type","name"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,gBAAgB,GAAG,SAAnBA,gBAAmB,CAAAC,KAAK,EAAI;AAChC,MAAQC,KAAR,GAA4FD,KAA5F,CAAQC,KAAR;AAAA,MAAeC,aAAf,GAA4FF,KAA5F,CAAeE,aAAf;AAAA,MAA8BC,IAA9B,GAA4FH,KAA5F,CAA8BG,IAA9B;AAAA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CAAlB,EAAqBU,IAArB,EAA2BE,IAAI,CAACE,KAAhC,EAAuC,UAAvC,CAAd;AAEA,0BAAO,gCAAC,iBAAD,eAAUxB,KAAV;AAAiB,QAAA,KAAK,EAAEuB,KAAxB;AAA+B,QAAA,gBAAgB,EAAExB;AAAjD,SAAP;AACD;;;;EAd2B0B,kBAAMC,S;;;;gBAAvBP,Q,eACQ;AACjBC,EAAAA,IAAI,EAAEL,sBAAUY,KADC;AAEjBC,EAAAA,QAAQ,EAAEb,sBAAUc,IAFH;AAGjBR,EAAAA,UAAU,EAAES,YAAMC,cAAN,CAAqBC;AAHhB,C;;eAgBN;AAAA,SAAO;AACpBC,IAAAA,IAAI,EAAE,UADc;AAEpBP,IAAAA,SAAS,EAAEP,QAFS;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 { dataToXBand } from '../utils';\nimport Plot from './common/plot';\nimport { LinePath } from '@vx/shape';\nimport { Group } from '@vx/group';\n\nconst CustomBarElement = props => {\n const { index, pointDiameter, barX, barWidth, pointHeight, label, value, classes, scale } = props;\n\n const x = barX + (barWidth - pointDiameter) / 2;\n const y = scale.y(index) - (pointHeight - pointDiameter) / 2;\n\n return (\n <Group>\n <LinePath\n data={[{ x, y }, { x: x + pointDiameter, y: y - pointDiameter }]}\n key={`point-${label}-${value}-${index}-1`}\n className={classes.line}\n x={d => d.x}\n y={d => d.y}\n strokeWidth={pointDiameter / 5}\n />\n <LinePath\n data={[{ x, y: y - pointDiameter }, { x: x + pointDiameter, y }]}\n key={`point-${label}-${value}-${index}-2`}\n className={classes.line}\n x={d => d.x}\n y={d => d.y}\n strokeWidth={pointDiameter / 5}\n />\n </Group>\n );\n};\n\nCustomBarElement.propTypes = {\n index: PropTypes.number,\n pointDiameter: PropTypes.number,\n barX: PropTypes.number,\n barWidth: PropTypes.number,\n pointHeight: PropTypes.number,\n value: PropTypes.number,\n label: PropTypes.string,\n classes: PropTypes.object,\n scale: PropTypes.object\n};\n\nexport class LinePlot 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, 'linePlot');\n\n return <Plot {...props} xBand={xBand} CustomBarElement={CustomBarElement} />;\n }\n}\n\nexport default () => ({\n type: 'linePlot',\n Component: LinePlot,\n name: 'Line Plot'\n});\n"],"file":"line.js"}
|
package/lib/tool-menu.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
|
});
|
|
@@ -19,23 +21,25 @@ var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
|
|
|
19
21
|
|
|
20
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
23
|
|
|
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); }
|
|
23
|
-
|
|
24
24
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
25
25
|
|
|
26
26
|
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
27
|
|
|
28
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
28
|
+
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
29
|
|
|
30
|
-
function
|
|
30
|
+
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
31
|
|
|
32
|
-
function
|
|
32
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
33
33
|
|
|
34
|
-
function
|
|
34
|
+
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
35
|
|
|
36
|
-
function
|
|
36
|
+
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
37
|
|
|
38
|
-
function
|
|
38
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
39
|
+
|
|
40
|
+
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; } }
|
|
41
|
+
|
|
42
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
39
43
|
|
|
40
44
|
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
45
|
|
|
@@ -78,7 +82,7 @@ var MiniButton = (0, _styles.withStyles)(buttonStyles)(function (props) {
|
|
|
78
82
|
selected = props.selected,
|
|
79
83
|
value = props.value,
|
|
80
84
|
onClick = props.onClick;
|
|
81
|
-
return _react["default"].createElement(_Button["default"], {
|
|
85
|
+
return /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
82
86
|
size: "small",
|
|
83
87
|
disabled: disabled,
|
|
84
88
|
color: selected ? 'secondary' : 'default',
|
|
@@ -102,15 +106,15 @@ MiniButton.propTypes = {
|
|
|
102
106
|
onClick: _propTypes["default"].func
|
|
103
107
|
};
|
|
104
108
|
|
|
105
|
-
var ToolMenu =
|
|
106
|
-
/*#__PURE__*/
|
|
107
|
-
function (_React$Component) {
|
|
109
|
+
var ToolMenu = /*#__PURE__*/function (_React$Component) {
|
|
108
110
|
_inherits(ToolMenu, _React$Component);
|
|
109
111
|
|
|
112
|
+
var _super = _createSuper(ToolMenu);
|
|
113
|
+
|
|
110
114
|
function ToolMenu() {
|
|
111
115
|
_classCallCheck(this, ToolMenu);
|
|
112
116
|
|
|
113
|
-
return
|
|
117
|
+
return _super.apply(this, arguments);
|
|
114
118
|
}
|
|
115
119
|
|
|
116
120
|
_createClass(ToolMenu, [{
|
|
@@ -120,9 +124,9 @@ function (_React$Component) {
|
|
|
120
124
|
className = _this$props.className,
|
|
121
125
|
disabled = _this$props.disabled,
|
|
122
126
|
addCategory = _this$props.addCategory;
|
|
123
|
-
return _react["default"].createElement("div", {
|
|
127
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
124
128
|
className: (0, _classnames["default"])(className)
|
|
125
|
-
}, !disabled && _react["default"].createElement(MiniButton, {
|
|
129
|
+
}, !disabled && /*#__PURE__*/_react["default"].createElement(MiniButton, {
|
|
126
130
|
value: 'Add Category',
|
|
127
131
|
onClick: addCategory
|
|
128
132
|
}));
|
package/lib/tool-menu.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/tool-menu.jsx"],"names":["buttonStyles","theme","root","backgroundColor","color","background","text","border","secondary","secondaryLight","fontSize","typography","selected","primaryDark","notSelected","primary","disabled","MiniButton","props","classes","className","value","onClick","propTypes","PropTypes","bool","string","disabledClassName","func","ToolMenu","addCategory","React","Component"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/tool-menu.jsx"],"names":["buttonStyles","theme","root","backgroundColor","color","background","text","border","secondary","secondaryLight","fontSize","typography","selected","primaryDark","notSelected","primary","disabled","MiniButton","props","classes","className","value","onClick","propTypes","PropTypes","bool","string","disabledClassName","func","ToolMenu","addCategory","React","Component"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,YAAY,GAAG,SAAfA,YAAe,CAAAC,KAAK;AAAA,SAAK;AAC7BC,IAAAA,IAAI,EAAE;AACJC,MAAAA,eAAe,EAAEC,gBAAMC,UAAN,EADb;AAEJD,MAAAA,KAAK,EAAEA,gBAAME,IAAN,EAFH;AAGJC,MAAAA,MAAM,sBAAeH,gBAAMI,SAAN,EAAf,CAHF;AAIJ,iBAAW;AACTL,QAAAA,eAAe,EAA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;AAAEJ,MAAAA,QAAQ,EAAE,4BAAGA,QAAQ,IAAIG,OAAO,CAACH,QAAvB;AAAZ,KALX;AAME,IAAA,KAAK,EAAEK,KANT;AAOE,IAAA,GAAG,EAAEA,KAPP;AAQE,IAAA,OAAO,EAAC,UARV;AASE,IAAA,OAAO,EAAEC;AATX,KAWGD,KAXH,CADF;AAeD,CAjByB,CAAnB;;AAkBPJ,UAAU,CAACM,SAAX,GAAuB;AACrBP,EAAAA,QAAQ,EAAEQ,sBAAUC,IADC;AAErBL,EAAAA,SAAS,EAAEI,sBAAUE,MAFA;AAGrBC,EAAAA,iBAAiB,EAAEH,sBAAUE,MAHR;AAIrBd,EAAAA,QAAQ,EAAEY,sBAAUC,IAJC;AAKrBJ,EAAAA,KAAK,EAAEG,sBAAUE,MALI;AAMrBJ,EAAAA,OAAO,EAAEE,sBAAUI;AANE,CAAvB;;IASaC,Q;;;;;;;;;;;;;WASX,kBAAS;AACP,wBAA6C,KAAKX,KAAlD;AAAA,UAAQE,SAAR,eAAQA,SAAR;AAAA,UAAmBJ,QAAnB,eAAmBA,QAAnB;AAAA,UAA6Bc,WAA7B,eAA6BA,WAA7B;AAEA,0BACE;AAAK,QAAA,SAAS,EAAE,4BAAWV,SAAX;AAAhB,SACG,CAACJ,QAAD,iBAAa,gCAAC,UAAD;AAAY,QAAA,KAAK,EAAE,cAAnB;AAAmC,QAAA,OAAO,EAAEc;AAA5C,QADhB,CADF;AAKD;;;;EAjB2BC,kBAAMC,S;;;;gBAAvBH,Q,eACQ;AACjBT,EAAAA,SAAS,EAAEI,sBAAUE,MADJ;AAEjBI,EAAAA,WAAW,EAAEN,sBAAUI,IAFN;AAGjBZ,EAAAA,QAAQ,EAAEQ,sBAAUC;AAHH,C;;gBADRI,Q,kBAOW,E;;eAaTA,Q","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { color } from '@pie-lib/render-ui';\n\nimport { withStyles } from '@material-ui/core/styles';\nimport cn from 'classnames';\nimport Button from '@material-ui/core/Button';\n\nconst buttonStyles = theme => ({\n root: {\n backgroundColor: color.background(),\n color: color.text(),\n border: `1px solid ${color.secondary()}`,\n '&:hover': {\n backgroundColor: color.secondaryLight()\n },\n fontSize: theme.typography.fontSize\n },\n selected: {\n backgroundColor: color.background(),\n '& span': {\n color: color.primaryDark()\n }\n },\n notSelected: {\n '& span': {\n color: color.primary()\n },\n backgroundColor: color.background()\n },\n disabled: {\n '& span': {\n color: color.primary()\n },\n backgroundColor: color.disabled()\n }\n});\n\nexport const MiniButton = withStyles(buttonStyles)(props => {\n const { disabled, classes, className, selected, value, onClick } = props;\n return (\n <Button\n size=\"small\"\n disabled={disabled}\n color={selected ? 'secondary' : 'default'}\n className={cn(classes.root, selected && classes.selected, className)}\n classes={{ disabled: cn(disabled && classes.disabled) }}\n value={value}\n key={value}\n variant=\"outlined\"\n onClick={onClick}\n >\n {value}\n </Button>\n );\n});\nMiniButton.propTypes = {\n disabled: PropTypes.bool,\n className: PropTypes.string,\n disabledClassName: PropTypes.string,\n selected: PropTypes.bool,\n value: PropTypes.string,\n onClick: PropTypes.func\n};\n\nexport class ToolMenu extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n addCategory: PropTypes.func,\n disabled: PropTypes.bool\n };\n\n static defaultProps = {};\n\n render() {\n const { className, disabled, addCategory } = this.props;\n\n return (\n <div className={classNames(className)}>\n {!disabled && <MiniButton value={'Add Category'} onClick={addCategory} />}\n </div>\n );\n }\n}\n\nexport default ToolMenu;\n"],"file":"tool-menu.js"}
|
package/lib/utils.js
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getTopPadding = exports.
|
|
6
|
+
exports.tickCount = exports.point = exports.getTopPadding = exports.getTickValues = exports.getRotateAngle = exports.getGridLinesAndAxisByChartType = exports.getDomainAndRangeByChartType = exports.dataToXBand = exports.customLabelStep = exports.crowdedTicks = exports.bounds = exports.bandKey = void 0;
|
|
7
7
|
|
|
8
8
|
var _scale = require("@vx/scale");
|
|
9
9
|
|
|
10
10
|
var _plot = require("@pie-lib/plot");
|
|
11
11
|
|
|
12
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
12
|
+
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; }
|
|
13
13
|
|
|
14
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
14
|
+
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; }
|
|
15
15
|
|
|
16
16
|
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; }
|
|
17
17
|
|
|
@@ -79,7 +79,49 @@ var getTickValues = function getTickValues() {
|
|
|
79
79
|
|
|
80
80
|
exports.getTickValues = getTickValues;
|
|
81
81
|
|
|
82
|
-
var
|
|
82
|
+
var customLabelStep = function customLabelStep(rangeMax, size, labelFontSize) {
|
|
83
|
+
var ceilMax = Math.ceil(rangeMax);
|
|
84
|
+
var segmentLength = size.height / ceilMax;
|
|
85
|
+
var ticksToFitInOneSegment = 2; // how many ticksWidth fit in a segment
|
|
86
|
+
|
|
87
|
+
var tickWidthPerSegment = segmentLength / labelFontSize;
|
|
88
|
+
var rawLabelStep = ticksToFitInOneSegment / tickWidthPerSegment;
|
|
89
|
+
var roundedStep = Math.ceil(rawLabelStep * 10 / 10);
|
|
90
|
+
var labelStep;
|
|
91
|
+
|
|
92
|
+
if (rawLabelStep > 0.15) {
|
|
93
|
+
labelStep = roundedStep;
|
|
94
|
+
} else if (rawLabelStep < 0.05) {
|
|
95
|
+
labelStep = 0.1;
|
|
96
|
+
} else {
|
|
97
|
+
labelStep = 0.5;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return labelStep;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
exports.customLabelStep = customLabelStep;
|
|
104
|
+
|
|
105
|
+
var crowdedTicks = function crowdedTicks(rangeMax, customLabelStep, size, labelFontSize) {
|
|
106
|
+
var ceilMax = Math.ceil(rangeMax);
|
|
107
|
+
var numberOfSegments = ceilMax * customLabelStep;
|
|
108
|
+
return size.height / numberOfSegments < labelFontSize && size.height / numberOfSegments > 0.5;
|
|
109
|
+
}; // multiply values with 10^number_of_decimals if needed because modulo function(%) is only defined for integers
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
exports.crowdedTicks = crowdedTicks;
|
|
113
|
+
|
|
114
|
+
var modulo = function modulo(a, b) {
|
|
115
|
+
if (Number.isInteger(b)) {
|
|
116
|
+
return a % b;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
var decimals = b.toString().split('.').pop().length;
|
|
120
|
+
var aux = Math.pow(10, decimals);
|
|
121
|
+
return a * aux % (b * aux);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
var getDomainAndRangeByChartType = function getDomainAndRangeByChartType(domain, range, size, chartType, labelFontSize) {
|
|
83
125
|
var _ref = range || {},
|
|
84
126
|
step = _ref.step,
|
|
85
127
|
labelStep = _ref.labelStep,
|
|
@@ -94,22 +136,41 @@ var getDomainAndRangeByChartType = function getDomainAndRangeByChartType(domain,
|
|
|
94
136
|
max = range.min + 1;
|
|
95
137
|
}
|
|
96
138
|
|
|
97
|
-
|
|
139
|
+
if (labelStep && !step) {
|
|
140
|
+
step = labelStep;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (!labelStep || isNaN(labelStep) && step) {
|
|
144
|
+
var _customLabelStep = step;
|
|
145
|
+
var crowded = crowdedTicks(max, _customLabelStep, size, labelFontSize);
|
|
98
146
|
|
|
99
|
-
|
|
100
|
-
|
|
147
|
+
if (crowded) {
|
|
148
|
+
_customLabelStep = _customLabelStep * 2;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
labelStep = _customLabelStep;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (!step || isNaN(step) && !labelStep || isNaN(labelStep)) {
|
|
155
|
+
labelStep = customLabelStep(max, size, labelFontSize);
|
|
156
|
+
|
|
157
|
+
if (labelStep <= 1) {
|
|
158
|
+
step = labelStep;
|
|
159
|
+
} else if (labelStep <= 4) {
|
|
101
160
|
step = 1;
|
|
102
|
-
} else if (
|
|
103
|
-
step =
|
|
161
|
+
} else if (labelStep > 4 && labelStep < 10) {
|
|
162
|
+
step = labelStep / 2;
|
|
104
163
|
} else {
|
|
105
|
-
step =
|
|
164
|
+
step = labelStep / 3;
|
|
106
165
|
}
|
|
107
166
|
}
|
|
108
167
|
|
|
109
|
-
if (
|
|
110
|
-
|
|
168
|
+
if (modulo(max, step) !== 0) {
|
|
169
|
+
max = max + step;
|
|
111
170
|
}
|
|
112
171
|
|
|
172
|
+
range.max = max;
|
|
173
|
+
|
|
113
174
|
switch (chartType) {
|
|
114
175
|
// if chart is dot plot or line plot, we should ignore step and make sure that min & max are integer values
|
|
115
176
|
case 'dotPlot':
|
|
@@ -118,13 +179,13 @@ var getDomainAndRangeByChartType = function getDomainAndRangeByChartType(domain,
|
|
|
118
179
|
var intMin = Math.round(min);
|
|
119
180
|
var intMax = Math.round(max);
|
|
120
181
|
return {
|
|
121
|
-
domain: _objectSpread({}, domain, {
|
|
182
|
+
domain: _objectSpread(_objectSpread({}, domain), {}, {
|
|
122
183
|
step: 1,
|
|
123
184
|
labelStep: 1,
|
|
124
185
|
min: 0,
|
|
125
186
|
max: 1
|
|
126
187
|
}),
|
|
127
|
-
range: _objectSpread({}, range, {
|
|
188
|
+
range: _objectSpread(_objectSpread({}, range), {}, {
|
|
128
189
|
min: intMin,
|
|
129
190
|
max: intMin === intMax ? intMin + 1 : intMax,
|
|
130
191
|
labelStep: labelStep,
|
|
@@ -135,13 +196,13 @@ var getDomainAndRangeByChartType = function getDomainAndRangeByChartType(domain,
|
|
|
135
196
|
|
|
136
197
|
default:
|
|
137
198
|
return {
|
|
138
|
-
domain: _objectSpread({}, domain, {
|
|
199
|
+
domain: _objectSpread(_objectSpread({}, domain), {}, {
|
|
139
200
|
step: 1,
|
|
140
201
|
labelStep: 1,
|
|
141
202
|
min: 0,
|
|
142
203
|
max: 1
|
|
143
204
|
}),
|
|
144
|
-
range: _objectSpread({}, range, {
|
|
205
|
+
range: _objectSpread(_objectSpread({}, range), {}, {
|
|
145
206
|
labelStep: labelStep,
|
|
146
207
|
step: step
|
|
147
208
|
})
|
|
@@ -180,16 +241,8 @@ var getGridLinesAndAxisByChartType = function getGridLinesAndAxisByChartType(ran
|
|
|
180
241
|
|
|
181
242
|
exports.getGridLinesAndAxisByChartType = getGridLinesAndAxisByChartType;
|
|
182
243
|
|
|
183
|
-
var getRotateAngle = function getRotateAngle(
|
|
184
|
-
if (
|
|
185
|
-
return 75;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (barWidth < 40) {
|
|
189
|
-
return 45;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (barWidth < 60) {
|
|
244
|
+
var getRotateAngle = function getRotateAngle(fontSize, height) {
|
|
245
|
+
if (height >= fontSize * 2) {
|
|
193
246
|
return 25;
|
|
194
247
|
}
|
|
195
248
|
|