@pie-lib/charting 5.21.0 → 5.23.0
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 +6 -10
- package/lib/actions-button.js +174 -0
- package/lib/actions-button.js.map +1 -0
- package/lib/axes.js +614 -0
- package/lib/axes.js.map +1 -0
- package/lib/bars/bar.js +86 -0
- package/lib/bars/bar.js.map +1 -0
- package/lib/bars/common/bars.js +299 -0
- package/lib/bars/common/bars.js.map +1 -0
- package/lib/bars/histogram.js +87 -0
- package/lib/bars/histogram.js.map +1 -0
- package/lib/chart-setup.js +458 -0
- package/lib/chart-setup.js.map +1 -0
- package/lib/chart-type.js +71 -0
- package/lib/chart-type.js.map +1 -0
- package/lib/chart-types.js +31 -0
- package/lib/chart-types.js.map +1 -0
- package/lib/chart.js +447 -0
- package/lib/chart.js.map +1 -0
- package/lib/common/drag-handle.js +175 -0
- package/lib/common/drag-handle.js.map +1 -0
- package/lib/common/drag-icon.js +52 -0
- package/lib/common/drag-icon.js.map +1 -0
- package/lib/common/styles.js +40 -0
- package/lib/common/styles.js.map +1 -0
- package/lib/grid.js +141 -0
- package/lib/grid.js.map +1 -0
- package/lib/index.js +48 -0
- package/lib/index.js.map +1 -0
- package/lib/key-legend.js +111 -0
- package/lib/key-legend.js.map +1 -0
- package/lib/line/common/drag-handle.js +151 -0
- package/lib/line/common/drag-handle.js.map +1 -0
- package/lib/line/common/line.js +257 -0
- package/lib/line/common/line.js.map +1 -0
- package/lib/line/line-cross.js +203 -0
- package/lib/line/line-cross.js.map +1 -0
- package/lib/line/line-dot.js +156 -0
- package/lib/line/line-dot.js.map +1 -0
- package/lib/mark-label.js +260 -0
- package/lib/mark-label.js.map +1 -0
- package/lib/plot/common/plot.js +281 -0
- package/lib/plot/common/plot.js.map +1 -0
- package/lib/plot/dot.js +123 -0
- package/lib/plot/dot.js.map +1 -0
- package/lib/plot/line.js +152 -0
- package/lib/plot/line.js.map +1 -0
- package/lib/tool-menu.js +142 -0
- package/lib/tool-menu.js.map +1 -0
- package/lib/utils.js +244 -0
- package/lib/utils.js.map +1 -0
- package/package.json +5 -5
- package/src/chart-types.js +2 -2
- package/src/line/common/__tests__/drag-handle.test.jsx +2 -2
- package/src/plot/common/__tests__/plot.test.jsx +1 -1
- package/src/plot/dot.js +1 -1
- package/src/plot/line.js +1 -1
package/lib/plot/dot.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = exports.DotPlot = void 0;
|
|
9
|
+
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
+
|
|
18
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
+
|
|
20
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
+
|
|
22
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
+
|
|
24
|
+
var _react = _interopRequireDefault(require("react"));
|
|
25
|
+
|
|
26
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
27
|
+
|
|
28
|
+
var _plot = require("@pie-lib/plot");
|
|
29
|
+
|
|
30
|
+
var _utils = require("../utils");
|
|
31
|
+
|
|
32
|
+
var _plot2 = _interopRequireDefault(require("./common/plot"));
|
|
33
|
+
|
|
34
|
+
var _shape = require("@vx/shape");
|
|
35
|
+
|
|
36
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
37
|
+
|
|
38
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
39
|
+
|
|
40
|
+
var CustomBarElement = function CustomBarElement(props) {
|
|
41
|
+
var index = props.index,
|
|
42
|
+
pointDiameter = props.pointDiameter,
|
|
43
|
+
barX = props.barX,
|
|
44
|
+
barWidth = props.barWidth,
|
|
45
|
+
pointHeight = props.pointHeight,
|
|
46
|
+
label = props.label,
|
|
47
|
+
value = props.value,
|
|
48
|
+
classes = props.classes,
|
|
49
|
+
scale = props.scale;
|
|
50
|
+
var r = pointDiameter / 2;
|
|
51
|
+
var cx = barX + (barWidth - pointDiameter) / 2 + r;
|
|
52
|
+
var cy = scale.y(index) - (pointHeight - pointDiameter) / 2 - r;
|
|
53
|
+
return /*#__PURE__*/_react["default"].createElement(_shape.Circle, {
|
|
54
|
+
key: "point-".concat(label, "-").concat(value, "-").concat(index),
|
|
55
|
+
className: classes.dot,
|
|
56
|
+
cx: cx,
|
|
57
|
+
cy: cy,
|
|
58
|
+
r: r
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
CustomBarElement.propTypes = {
|
|
63
|
+
index: _propTypes["default"].number,
|
|
64
|
+
pointDiameter: _propTypes["default"].number,
|
|
65
|
+
barX: _propTypes["default"].number,
|
|
66
|
+
barWidth: _propTypes["default"].number,
|
|
67
|
+
pointHeight: _propTypes["default"].number,
|
|
68
|
+
value: _propTypes["default"].number,
|
|
69
|
+
label: _propTypes["default"].string,
|
|
70
|
+
classes: _propTypes["default"].object,
|
|
71
|
+
scale: _propTypes["default"].object
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
var DotPlot = /*#__PURE__*/function (_React$Component) {
|
|
75
|
+
(0, _inherits2["default"])(DotPlot, _React$Component);
|
|
76
|
+
|
|
77
|
+
var _super = _createSuper(DotPlot);
|
|
78
|
+
|
|
79
|
+
function DotPlot() {
|
|
80
|
+
(0, _classCallCheck2["default"])(this, DotPlot);
|
|
81
|
+
return _super.apply(this, arguments);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
(0, _createClass2["default"])(DotPlot, [{
|
|
85
|
+
key: "render",
|
|
86
|
+
value: function render() {
|
|
87
|
+
var props = this.props;
|
|
88
|
+
var data = props.data,
|
|
89
|
+
graphProps = props.graphProps;
|
|
90
|
+
|
|
91
|
+
var _ref = graphProps || {},
|
|
92
|
+
_ref$scale = _ref.scale,
|
|
93
|
+
scale = _ref$scale === void 0 ? {} : _ref$scale,
|
|
94
|
+
_ref$size = _ref.size,
|
|
95
|
+
size = _ref$size === void 0 ? {} : _ref$size;
|
|
96
|
+
|
|
97
|
+
var xBand = (0, _utils.dataToXBand)(scale.x, data, size.width, 'dotPlot');
|
|
98
|
+
return /*#__PURE__*/_react["default"].createElement(_plot2["default"], (0, _extends2["default"])({}, props, {
|
|
99
|
+
xBand: xBand,
|
|
100
|
+
CustomBarElement: CustomBarElement
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
}]);
|
|
104
|
+
return DotPlot;
|
|
105
|
+
}(_react["default"].Component);
|
|
106
|
+
|
|
107
|
+
exports.DotPlot = DotPlot;
|
|
108
|
+
(0, _defineProperty2["default"])(DotPlot, "propTypes", {
|
|
109
|
+
data: _propTypes["default"].array,
|
|
110
|
+
onChange: _propTypes["default"].func,
|
|
111
|
+
graphProps: _plot.types.GraphPropsType.isRequired
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
var _default = function _default() {
|
|
115
|
+
return {
|
|
116
|
+
type: 'dotPlot',
|
|
117
|
+
Component: DotPlot,
|
|
118
|
+
name: 'Dot Plot'
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
exports["default"] = _default;
|
|
123
|
+
//# sourceMappingURL=dot.js.map
|
|
@@ -0,0 +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":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,KAAD,EAAW;AAClC,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,QAA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AACgB,CAAlB,EAAqBJ,IAArB,EAA2BE,IAAI,CAACG,KAAhC,EAAuC,SAAvC,CAAd;AAEA,0BAAO,gCAAC,iBAAD,gCAAU1B,KAAV;AAAiB,QAAA,KAAK,EAAEwB,KAAxB;AAA+B,QAAA,gBAAgB,EAAEzB;AAAjD,SAAP;AACD;;;EAd0B4B,kBAAMC,S;;;iCAAtBR,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 <Circle key={`point-${label}-${value}-${index}`} className={classes.dot} cx={cx} cy={cy} r={r} />;\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
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = exports.LinePlot = void 0;
|
|
9
|
+
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
+
|
|
18
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
+
|
|
20
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
+
|
|
22
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
+
|
|
24
|
+
var _react = _interopRequireDefault(require("react"));
|
|
25
|
+
|
|
26
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
27
|
+
|
|
28
|
+
var _plot = require("@pie-lib/plot");
|
|
29
|
+
|
|
30
|
+
var _utils = require("../utils");
|
|
31
|
+
|
|
32
|
+
var _plot2 = _interopRequireDefault(require("./comm@pie-lib/plot"));
|
|
33
|
+
|
|
34
|
+
var _shape = require("@vx/shape");
|
|
35
|
+
|
|
36
|
+
var _group = require("@vx/group");
|
|
37
|
+
|
|
38
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
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
|
+
var CustomBarElement = function CustomBarElement(props) {
|
|
43
|
+
var index = props.index,
|
|
44
|
+
pointDiameter = props.pointDiameter,
|
|
45
|
+
barX = props.barX,
|
|
46
|
+
barWidth = props.barWidth,
|
|
47
|
+
pointHeight = props.pointHeight,
|
|
48
|
+
label = props.label,
|
|
49
|
+
value = props.value,
|
|
50
|
+
classes = props.classes,
|
|
51
|
+
scale = props.scale;
|
|
52
|
+
var x = barX + (barWidth - pointDiameter) / 2;
|
|
53
|
+
var y = scale.y(index) - (pointHeight - pointDiameter) / 2;
|
|
54
|
+
return /*#__PURE__*/_react["default"].createElement(_group.Group, null, /*#__PURE__*/_react["default"].createElement(_shape.LinePath, {
|
|
55
|
+
data: [{
|
|
56
|
+
x: x,
|
|
57
|
+
y: y
|
|
58
|
+
}, {
|
|
59
|
+
x: x + pointDiameter,
|
|
60
|
+
y: y - pointDiameter
|
|
61
|
+
}],
|
|
62
|
+
key: "point-".concat(label, "-").concat(value, "-").concat(index, "-1"),
|
|
63
|
+
className: classes.line,
|
|
64
|
+
x: function x(d) {
|
|
65
|
+
return d.x;
|
|
66
|
+
},
|
|
67
|
+
y: function y(d) {
|
|
68
|
+
return d.y;
|
|
69
|
+
},
|
|
70
|
+
strokeWidth: pointDiameter / 5
|
|
71
|
+
}), /*#__PURE__*/_react["default"].createElement(_shape.LinePath, {
|
|
72
|
+
data: [{
|
|
73
|
+
x: x,
|
|
74
|
+
y: y - pointDiameter
|
|
75
|
+
}, {
|
|
76
|
+
x: x + pointDiameter,
|
|
77
|
+
y: y
|
|
78
|
+
}],
|
|
79
|
+
key: "point-".concat(label, "-").concat(value, "-").concat(index, "-2"),
|
|
80
|
+
className: classes.line,
|
|
81
|
+
x: function x(d) {
|
|
82
|
+
return d.x;
|
|
83
|
+
},
|
|
84
|
+
y: function y(d) {
|
|
85
|
+
return d.y;
|
|
86
|
+
},
|
|
87
|
+
strokeWidth: pointDiameter / 5
|
|
88
|
+
}));
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
CustomBarElement.propTypes = {
|
|
92
|
+
index: _propTypes["default"].number,
|
|
93
|
+
pointDiameter: _propTypes["default"].number,
|
|
94
|
+
barX: _propTypes["default"].number,
|
|
95
|
+
barWidth: _propTypes["default"].number,
|
|
96
|
+
pointHeight: _propTypes["default"].number,
|
|
97
|
+
value: _propTypes["default"].number,
|
|
98
|
+
label: _propTypes["default"].string,
|
|
99
|
+
classes: _propTypes["default"].object,
|
|
100
|
+
scale: _propTypes["default"].object
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
var LinePlot = /*#__PURE__*/function (_React$Component) {
|
|
104
|
+
(0, _inherits2["default"])(LinePlot, _React$Component);
|
|
105
|
+
|
|
106
|
+
var _super = _createSuper(LinePlot);
|
|
107
|
+
|
|
108
|
+
function LinePlot() {
|
|
109
|
+
(0, _classCallCheck2["default"])(this, LinePlot);
|
|
110
|
+
return _super.apply(this, arguments);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
(0, _createClass2["default"])(LinePlot, [{
|
|
114
|
+
key: "render",
|
|
115
|
+
value: function render() {
|
|
116
|
+
var props = this.props;
|
|
117
|
+
var data = props.data,
|
|
118
|
+
graphProps = props.graphProps;
|
|
119
|
+
|
|
120
|
+
var _ref = graphProps || {},
|
|
121
|
+
_ref$scale = _ref.scale,
|
|
122
|
+
scale = _ref$scale === void 0 ? {} : _ref$scale,
|
|
123
|
+
_ref$size = _ref.size,
|
|
124
|
+
size = _ref$size === void 0 ? {} : _ref$size;
|
|
125
|
+
|
|
126
|
+
var xBand = (0, _utils.dataToXBand)(scale.x, data, size.width, 'linePlot');
|
|
127
|
+
return /*#__PURE__*/_react["default"].createElement(_plot2["default"], (0, _extends2["default"])({}, props, {
|
|
128
|
+
xBand: xBand,
|
|
129
|
+
CustomBarElement: CustomBarElement
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
}]);
|
|
133
|
+
return LinePlot;
|
|
134
|
+
}(_react["default"].Component);
|
|
135
|
+
|
|
136
|
+
exports.LinePlot = LinePlot;
|
|
137
|
+
(0, _defineProperty2["default"])(LinePlot, "propTypes", {
|
|
138
|
+
data: _propTypes["default"].array,
|
|
139
|
+
onChange: _propTypes["default"].func,
|
|
140
|
+
graphProps: _plot.types.GraphPropsType.isRequired
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
var _default = function _default() {
|
|
144
|
+
return {
|
|
145
|
+
type: 'linePlot',
|
|
146
|
+
Component: LinePlot,
|
|
147
|
+
name: 'Line Plot'
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
exports["default"] = _default;
|
|
152
|
+
//# sourceMappingURL=line.js.map
|
|
@@ -0,0 +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":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,gBAAgB,GA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UAAU,IAAI,EAAhD;AAAA,4BAAQZ,KAAR;AAAA,UAAQA,KAAR,2BAAgB,EAAhB;AAAA,2BAAoBa,IAApB;AAAA,UAAoBA,IAApB,0BAA2B,EAA3B;;AACA,UAAMC,KAAK,GAAG,wBAAYd,KAAK,CAACC,CAAlB,EAAqBU,IAArB,EAA2BE,IAAI,CAACE,KAAhC,EAAuC,UAAvC,CAAd;AAEA,0BAAO,gCAAC,iBAAD,gCAAUxB,KAAV;AAAiB,QAAA,KAAK,EAAEuB,KAAxB;AAA+B,QAAA,gBAAgB,EAAExB;AAAjD,SAAP;AACD;;;EAd2B0B,kBAAMC,S;;;iCAAvBP,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 './comm@pie-lib/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={[\n { x, y },\n { x: x + pointDiameter, y: y - pointDiameter },\n ]}\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={[\n { x, y: y - pointDiameter },\n { x: x + pointDiameter, y },\n ]}\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
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = exports.ToolMenu = exports.MiniButton = void 0;
|
|
9
|
+
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
14
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
|
+
|
|
16
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
17
|
+
|
|
18
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
19
|
+
|
|
20
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
|
+
|
|
22
|
+
var _react = _interopRequireDefault(require("react"));
|
|
23
|
+
|
|
24
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
25
|
+
|
|
26
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
27
|
+
|
|
28
|
+
var _renderUi = require("@pie-lib/render-ui");
|
|
29
|
+
|
|
30
|
+
var _styles = require("@material-ui/core/styles");
|
|
31
|
+
|
|
32
|
+
var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
|
|
33
|
+
|
|
34
|
+
var _translator = _interopRequireDefault(require("@pie-lib/translator"));
|
|
35
|
+
|
|
36
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
37
|
+
|
|
38
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
39
|
+
|
|
40
|
+
var translator = _translator["default"].translator;
|
|
41
|
+
|
|
42
|
+
var buttonStyles = function buttonStyles(theme) {
|
|
43
|
+
return {
|
|
44
|
+
root: {
|
|
45
|
+
color: _renderUi.color.text(),
|
|
46
|
+
border: "1px solid ".concat(_renderUi.color.secondary()),
|
|
47
|
+
fontSize: theme.typography.fontSize
|
|
48
|
+
},
|
|
49
|
+
selected: {
|
|
50
|
+
backgroundColor: _renderUi.color.background(),
|
|
51
|
+
'& span': {
|
|
52
|
+
color: _renderUi.color.primaryDark()
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
notSelected: {
|
|
56
|
+
'& span': {
|
|
57
|
+
color: _renderUi.color.primary()
|
|
58
|
+
},
|
|
59
|
+
backgroundColor: _renderUi.color.background()
|
|
60
|
+
},
|
|
61
|
+
disabled: {
|
|
62
|
+
'& span': {
|
|
63
|
+
color: _renderUi.color.primary()
|
|
64
|
+
},
|
|
65
|
+
backgroundColor: _renderUi.color.disabled()
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
var MiniButton = (0, _styles.withStyles)(buttonStyles)(function (props) {
|
|
71
|
+
var disabled = props.disabled,
|
|
72
|
+
classes = props.classes,
|
|
73
|
+
className = props.className,
|
|
74
|
+
selected = props.selected,
|
|
75
|
+
value = props.value,
|
|
76
|
+
onClick = props.onClick;
|
|
77
|
+
return /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
78
|
+
size: "small",
|
|
79
|
+
disabled: disabled,
|
|
80
|
+
color: selected ? 'secondary' : 'default',
|
|
81
|
+
className: (0, _classnames["default"])(classes.root, selected && classes.selected, className),
|
|
82
|
+
classes: {
|
|
83
|
+
disabled: (0, _classnames["default"])(disabled && classes.disabled)
|
|
84
|
+
},
|
|
85
|
+
value: value,
|
|
86
|
+
key: value,
|
|
87
|
+
variant: "outlined",
|
|
88
|
+
onClick: onClick
|
|
89
|
+
}, value);
|
|
90
|
+
});
|
|
91
|
+
exports.MiniButton = MiniButton;
|
|
92
|
+
MiniButton.propTypes = {
|
|
93
|
+
disabled: _propTypes["default"].bool,
|
|
94
|
+
className: _propTypes["default"].string,
|
|
95
|
+
disabledClassName: _propTypes["default"].string,
|
|
96
|
+
selected: _propTypes["default"].bool,
|
|
97
|
+
value: _propTypes["default"].string,
|
|
98
|
+
onClick: _propTypes["default"].func
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
var ToolMenu = /*#__PURE__*/function (_React$Component) {
|
|
102
|
+
(0, _inherits2["default"])(ToolMenu, _React$Component);
|
|
103
|
+
|
|
104
|
+
var _super = _createSuper(ToolMenu);
|
|
105
|
+
|
|
106
|
+
function ToolMenu() {
|
|
107
|
+
(0, _classCallCheck2["default"])(this, ToolMenu);
|
|
108
|
+
return _super.apply(this, arguments);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
(0, _createClass2["default"])(ToolMenu, [{
|
|
112
|
+
key: "render",
|
|
113
|
+
value: function render() {
|
|
114
|
+
var _this$props = this.props,
|
|
115
|
+
className = _this$props.className,
|
|
116
|
+
disabled = _this$props.disabled,
|
|
117
|
+
addCategory = _this$props.addCategory,
|
|
118
|
+
language = _this$props.language;
|
|
119
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
120
|
+
className: (0, _classnames["default"])(className)
|
|
121
|
+
}, !disabled && /*#__PURE__*/_react["default"].createElement(MiniButton, {
|
|
122
|
+
value: translator.t('charting.addCategory', {
|
|
123
|
+
lng: language
|
|
124
|
+
}),
|
|
125
|
+
onClick: addCategory
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
}]);
|
|
129
|
+
return ToolMenu;
|
|
130
|
+
}(_react["default"].Component);
|
|
131
|
+
|
|
132
|
+
exports.ToolMenu = ToolMenu;
|
|
133
|
+
(0, _defineProperty2["default"])(ToolMenu, "propTypes", {
|
|
134
|
+
className: _propTypes["default"].string,
|
|
135
|
+
addCategory: _propTypes["default"].func,
|
|
136
|
+
disabled: _propTypes["default"].bool,
|
|
137
|
+
language: _propTypes["default"].string
|
|
138
|
+
});
|
|
139
|
+
(0, _defineProperty2["default"])(ToolMenu, "defaultProps", {});
|
|
140
|
+
var _default = ToolMenu;
|
|
141
|
+
exports["default"] = _default;
|
|
142
|
+
//# sourceMappingURL=tool-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/tool-menu.jsx"],"names":["translator","Translator","buttonStyles","theme","root","color","text","border","secondary","fontSize","typography","selected","backgroundColor","background","primaryDark","notSelected","primary","disabled","MiniButton","props","classes","className","value","onClick","propTypes","PropTypes","bool","string","disabledClassName","func","ToolMenu","addCategory","language","t","lng","React","Component"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;;;;;AAEA,IAAQA,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;;AAEA,IAAME,YAAY,GAAG,SAAfA,YAAe,CAACC,KAAD;AAAA,SAAY;AAC/BC,IAAAA,IAAI,EAAE;AACJC,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADH;AAEJC,MAAAA,MAAM,sBAAeF,gBAAMG,SAAN,EAAf,CAFF;AAGJC,MAAAA,QAAQ,EAAEN,KAAK,CAACO,UAAN,CAAiBD;AAHvB,KADyB;AAM/BE,IAAAA,QAAQ,EAAE;AACRC,MAAAA,eAAe,EAAEP,gBAAMQ,UAAN,EADT;AAER,gBAAU;AACRR,QAAAA,KAAK,EAAEA,gBAAMS,WAAN;AADC;AAFF,KANqB;AAY/BC,IAAAA,WAAW,EAAE;AACX,gBAAU;AACRV,QAAAA,KAAK,EAAEA,gBAAMW,OAAN;AADC,OADC;AAIXJ,MAAAA,eAAe,EAAEP,gBAAMQ,UAAN;AAJN,KAZkB;AAkB/BI,IAAAA,QAAQ,EAAE;AACR,gBAAU;AACRZ,QAAAA,KAAK,EAAEA,gBAAMW,OAAN;AADC,OADF;AAIRJ,MAAAA,eAAe,EAAEP,gBAAMY,QAAN;AAJT;AAlBqB,GAAZ;AAAA,CAArB;;AA0BO,IAAMC,UAAU,GAAG,wBAAWhB,YAAX,EAAyB,UAACiB,KAAD,EAAW;AAC5D,MAAQF,QAAR,GAAmEE,KAAnE,CAAQF,QAAR;AAAA,MAAkBG,OAAlB,GAAmED,KAAnE,CAAkBC,OAAlB;AAAA,MAA2BC,SAA3B,GAAmEF,KAAnE,CAA2BE,SAA3B;AAAA,MAAsCV,QAAtC,GAAmEQ,KAAnE,CAAsCR,Q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BACC,gCAAC,UAAD;AAAY,QAAA,KAAK,EAAEjB,UAAU,CAACiC,CAAX,CAAa,sBAAb,EAAqC;AAAEC,UAAAA,GAAG,EAAEF;AAAP,SAArC,CAAnB;AAA4E,QAAA,OAAO,EAAED;AAArF,QAFJ,CADF;AAOD;;;EApB2BI,kBAAMC,S;;;iCAAvBN,Q,eACQ;AACjBT,EAAAA,SAAS,EAAEI,sBAAUE,MADJ;AAEjBI,EAAAA,WAAW,EAAEN,sBAAUI,IAFN;AAGjBZ,EAAAA,QAAQ,EAAEQ,sBAAUC,IAHH;AAIjBM,EAAAA,QAAQ,EAAEP,sBAAUE;AAJH,C;iCADRG,Q,kBAQW,E;eAeTA,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';\nimport Translator from '@pie-lib/translator';\n\nconst { translator } = Translator;\n\nconst buttonStyles = (theme) => ({\n root: {\n color: color.text(),\n border: `1px solid ${color.secondary()}`,\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 language: PropTypes.string,\n };\n\n static defaultProps = {};\n\n render() {\n const { className, disabled, addCategory, language } = this.props;\n\n return (\n <div className={classNames(className)}>\n {!disabled && (\n <MiniButton value={translator.t('charting.addCategory', { lng: language })} onClick={addCategory} />\n )}\n </div>\n );\n }\n}\n\nexport default ToolMenu;\n"],"file":"tool-menu.js"}
|