@pie-lib/plot 2.7.3 → 2.8.1-beta.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/lib/root.js DELETED
@@ -1,379 +0,0 @@
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.Root = void 0;
9
-
10
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
-
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
-
16
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
17
-
18
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
19
-
20
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
21
-
22
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
23
-
24
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
25
-
26
- var _react = _interopRequireDefault(require("react"));
27
-
28
- var _types = require("./types");
29
-
30
- var _styles = require("@material-ui/core/styles");
31
-
32
- var _d3Selection = require("d3-selection");
33
-
34
- var _propTypes = _interopRequireDefault(require("prop-types"));
35
-
36
- var _renderUi = require("@pie-lib/render-ui");
37
-
38
- var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
39
-
40
- var _classnames = _interopRequireDefault(require("classnames"));
41
-
42
- var _label = _interopRequireDefault(require("./label"));
43
-
44
- 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; }
45
-
46
- 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) { (0, _defineProperty2["default"])(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; }
47
-
48
- 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); }; }
49
-
50
- 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; } }
51
-
52
- var Root = /*#__PURE__*/function (_React$Component) {
53
- (0, _inherits2["default"])(Root, _React$Component);
54
-
55
- var _super = _createSuper(Root);
56
-
57
- function Root() {
58
- var _this;
59
-
60
- (0, _classCallCheck2["default"])(this, Root);
61
-
62
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
63
- args[_key] = arguments[_key];
64
- }
65
-
66
- _this = _super.call.apply(_super, [this].concat(args));
67
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "mouseMove", function (g) {
68
- var _this$props = _this.props,
69
- graphProps = _this$props.graphProps,
70
- onMouseMove = _this$props.onMouseMove;
71
-
72
- if (!onMouseMove) {
73
- return;
74
- }
75
-
76
- var scale = graphProps.scale,
77
- snap = graphProps.snap;
78
- var coords = (0, _d3Selection.mouse)(g._groups[0][0]);
79
- var x = scale.x.invert(coords[0]);
80
- var y = scale.y.invert(coords[1]);
81
- var snapped = {
82
- x: snap.x(x),
83
- y: snap.y(y)
84
- };
85
- onMouseMove(snapped);
86
- });
87
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChangeLabel", function (newValue, side) {
88
- var _this$props2 = _this.props,
89
- labels = _this$props2.labels,
90
- onChangeLabels = _this$props2.onChangeLabels,
91
- isChart = _this$props2.isChart;
92
-
93
- if (isChart) {
94
- if (side === 'left') {
95
- onChangeLabels('range', newValue);
96
- } else {
97
- onChangeLabels('domain', newValue);
98
- }
99
-
100
- return;
101
- }
102
-
103
- onChangeLabels(_objectSpread(_objectSpread({}, labels), {}, (0, _defineProperty2["default"])({}, side, newValue)));
104
- });
105
- return _this;
106
- }
107
-
108
- (0, _createClass2["default"])(Root, [{
109
- key: "componentDidMount",
110
- value: function componentDidMount() {
111
- var g = (0, _d3Selection.select)(this.g);
112
- g.on('mousemove', this.mouseMove.bind(this, g));
113
- }
114
- }, {
115
- key: "componentWillUnmount",
116
- value: function componentWillUnmount() {
117
- var g = (0, _d3Selection.select)(this.g);
118
- g.on('mousemove', null);
119
- }
120
- }, {
121
- key: "render",
122
- value: function render() {
123
- var _this2 = this;
124
-
125
- var _this$props3 = this.props,
126
- disabledTitle = _this$props3.disabledTitle,
127
- disabledLabels = _this$props3.disabledLabels,
128
- labels = _this$props3.labels,
129
- labelsPlaceholders = _this$props3.labelsPlaceholders,
130
- titlePlaceholder = _this$props3.titlePlaceholder,
131
- graphProps = _this$props3.graphProps,
132
- children = _this$props3.children,
133
- classes = _this$props3.classes,
134
- defineChart = _this$props3.defineChart,
135
- onChangeTitle = _this$props3.onChangeTitle,
136
- isChart = _this$props3.isChart,
137
- showLabels = _this$props3.showLabels,
138
- showPixelGuides = _this$props3.showPixelGuides,
139
- showTitle = _this$props3.showTitle,
140
- title = _this$props3.title,
141
- rootRef = _this$props3.rootRef,
142
- _this$props3$mathMlOp = _this$props3.mathMlOptions,
143
- mathMlOptions = _this$props3$mathMlOp === void 0 ? {} : _this$props3$mathMlOp;
144
- var _graphProps$size = graphProps.size,
145
- _graphProps$size$widt = _graphProps$size.width,
146
- width = _graphProps$size$widt === void 0 ? 500 : _graphProps$size$widt,
147
- _graphProps$size$heig = _graphProps$size.height,
148
- height = _graphProps$size$heig === void 0 ? 500 : _graphProps$size$heig,
149
- domain = graphProps.domain,
150
- range = graphProps.range;
151
- var topPadding = 40;
152
- var leftPadding = showLabels ? 80 : 60;
153
- var finalWidth = width + leftPadding * 2 + (domain.padding || 0) * 2;
154
- var finalHeight = height + topPadding * 2 + (range.padding || 0) * 2;
155
- var activeTitlePlugins = ['bold', 'italic', 'underline', 'strikethrough', 'math' // 'languageCharacters'
156
- ];
157
- var actualHeight = defineChart && showPixelGuides ? height - 160 : height;
158
- var nbOfVerticalLines = parseInt(width / 100);
159
- var nbOfHorizontalLines = parseInt(actualHeight / 100);
160
- var sideGridlinesPadding = parseInt(actualHeight % 100);
161
- return /*#__PURE__*/_react["default"].createElement("div", {
162
- className: classes.root
163
- }, showPixelGuides && /*#__PURE__*/_react["default"].createElement("div", {
164
- className: classes.topPixelGuides,
165
- style: {
166
- marginLeft: isChart ? 60 : showLabels ? 30 : 10
167
- }
168
- }, (0, _toConsumableArray2["default"])(Array(nbOfVerticalLines + 1).keys()).map(function (value) {
169
- return /*#__PURE__*/_react["default"].createElement(_renderUi.Readable, {
170
- "false": true,
171
- key: "top-guide-".concat(value)
172
- }, /*#__PURE__*/_react["default"].createElement("div", {
173
- className: classes.topPixelIndicator
174
- }, /*#__PURE__*/_react["default"].createElement("div", null, value * 100, "px"), /*#__PURE__*/_react["default"].createElement("div", null, "|")));
175
- })), showTitle && (disabledTitle ? /*#__PURE__*/_react["default"].createElement("div", {
176
- style: isChart && {
177
- width: finalWidth
178
- },
179
- className: (0, _classnames["default"])(isChart ? classes.chartTitle : classes.graphTitle, classes.disabledTitle),
180
- dangerouslySetInnerHTML: {
181
- __html: title || ''
182
- }
183
- }) : /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
184
- style: isChart && {
185
- width: finalWidth
186
- },
187
- className: (0, _classnames["default"])((0, _defineProperty2["default"])({}, classes.rightMargin, showPixelGuides), isChart ? classes.chartTitle : classes.graphTitle),
188
- markup: title || '',
189
- onChange: onChangeTitle,
190
- placeholder: defineChart && titlePlaceholder || !disabledTitle && 'Click here to add a title for this graph',
191
- toolbarOpts: {
192
- noBorder: true
193
- },
194
- activePlugins: activeTitlePlugins,
195
- disableScrollbar: true
196
- })), showLabels && !isChart && /*#__PURE__*/_react["default"].createElement(_label["default"], {
197
- side: "top",
198
- text: labels.top,
199
- disabledLabel: disabledLabels,
200
- placeholder: labelsPlaceholders === null || labelsPlaceholders === void 0 ? void 0 : labelsPlaceholders.top,
201
- graphHeight: finalHeight,
202
- graphWidth: finalWidth,
203
- onChange: function onChange(value) {
204
- return _this2.onChangeLabel(value, 'top');
205
- },
206
- mathMlOptions: mathMlOptions
207
- }), /*#__PURE__*/_react["default"].createElement("div", {
208
- className: classes.wrapper
209
- }, showLabels && /*#__PURE__*/_react["default"].createElement(_label["default"], {
210
- side: "left",
211
- text: labels.left,
212
- disabledLabel: disabledLabels,
213
- placeholder: labelsPlaceholders === null || labelsPlaceholders === void 0 ? void 0 : labelsPlaceholders.left,
214
- graphHeight: finalHeight,
215
- graphWidth: finalWidth,
216
- isChartLeftLabel: isChart && !defineChart,
217
- isDefineChartLeftLabel: isChart && defineChart,
218
- onChange: function onChange(value) {
219
- return _this2.onChangeLabel(value, 'left');
220
- },
221
- mathMlOptions: mathMlOptions
222
- }), /*#__PURE__*/_react["default"].createElement("svg", {
223
- width: finalWidth,
224
- height: finalHeight,
225
- className: defineChart ? classes.defineChart : classes.chart
226
- }, /*#__PURE__*/_react["default"].createElement("g", {
227
- ref: function ref(r) {
228
- _this2.g = r;
229
-
230
- if (rootRef) {
231
- rootRef(r);
232
- }
233
- },
234
- className: classes.graphBox,
235
- transform: "translate(".concat(leftPadding, ", ").concat(topPadding, ")")
236
- }, children)), showLabels && !isChart && /*#__PURE__*/_react["default"].createElement(_label["default"], {
237
- side: "right",
238
- text: labels.right,
239
- disabledLabel: disabledLabels,
240
- placeholder: labelsPlaceholders === null || labelsPlaceholders === void 0 ? void 0 : labelsPlaceholders.right,
241
- graphHeight: finalHeight,
242
- graphWidth: finalWidth,
243
- onChange: function onChange(value) {
244
- return _this2.onChangeLabel(value, 'right');
245
- },
246
- mathMlOptions: mathMlOptions
247
- }), showPixelGuides && /*#__PURE__*/_react["default"].createElement("div", {
248
- className: classes.sidePixelGuides,
249
- style: {
250
- paddingTop: sideGridlinesPadding,
251
- marginTop: defineChart ? 25 : 31
252
- }
253
- }, (0, _toConsumableArray2["default"])(Array(nbOfHorizontalLines + 1).keys()).reverse().map(function (value) {
254
- return /*#__PURE__*/_react["default"].createElement(_renderUi.Readable, {
255
- "false": true,
256
- key: "top-guide-".concat(value)
257
- }, /*#__PURE__*/_react["default"].createElement("div", {
258
- className: classes.sidePixelIndicator
259
- }, "\u2501 ", value * 100, "px"));
260
- }))), showLabels && /*#__PURE__*/_react["default"].createElement(_label["default"], {
261
- side: "bottom",
262
- text: labels.bottom,
263
- disabledLabel: disabledLabels,
264
- placeholder: labelsPlaceholders === null || labelsPlaceholders === void 0 ? void 0 : labelsPlaceholders.bottom,
265
- graphHeight: finalHeight,
266
- graphWidth: finalWidth,
267
- isChartBottomLabel: isChart && !defineChart,
268
- isDefineChartBottomLabel: isChart && defineChart,
269
- onChange: function onChange(value) {
270
- return _this2.onChangeLabel(value, 'bottom');
271
- },
272
- mathMlOptions: mathMlOptions
273
- }));
274
- }
275
- }]);
276
- return Root;
277
- }(_react["default"].Component);
278
-
279
- exports.Root = Root;
280
- (0, _defineProperty2["default"])(Root, "propTypes", {
281
- title: _propTypes["default"].string,
282
- children: _types.ChildrenType,
283
- defineChart: _propTypes["default"].bool,
284
- disabledLabels: _propTypes["default"].bool,
285
- disabledTitle: _propTypes["default"].bool,
286
- graphProps: _types.GraphPropsType.isRequired,
287
- isChart: _propTypes["default"].bool,
288
- labels: _propTypes["default"].object,
289
- labelsPlaceholders: _propTypes["default"].object,
290
- onChangeTitle: _propTypes["default"].func,
291
- onMouseMove: _propTypes["default"].func,
292
- classes: _propTypes["default"].object.isRequired,
293
- showLabels: _propTypes["default"].bool,
294
- showTitle: _propTypes["default"].bool,
295
- showPixelGuides: _propTypes["default"].bool,
296
- rootRef: _propTypes["default"].func,
297
- onChangeLabels: _propTypes["default"].func,
298
- titlePlaceholder: _propTypes["default"].string
299
- });
300
-
301
- var styles = function styles(theme) {
302
- return {
303
- root: {
304
- border: "solid 1px ".concat(_renderUi.color.primaryLight()),
305
- color: _renderUi.color.text(),
306
- backgroundColor: _renderUi.color.background(),
307
- touchAction: 'none',
308
- position: 'relative'
309
- },
310
- wrapper: {
311
- display: 'flex',
312
- position: 'relative'
313
- },
314
- svg: {},
315
- defineChart: {
316
- paddingLeft: '50px',
317
- overflow: 'visible'
318
- },
319
- chart: {
320
- overflow: 'visible'
321
- },
322
- graphBox: {
323
- cursor: 'pointer',
324
- userSelect: 'none'
325
- },
326
- graphTitle: {
327
- color: _renderUi.color.text(),
328
- fontSize: theme.typography.fontSize + 2,
329
- padding: "".concat(theme.spacing.unit * 1.5, "px ").concat(theme.spacing.unit / 2, "px 0"),
330
- textAlign: 'center'
331
- },
332
- chartTitle: {
333
- color: _renderUi.color.text(),
334
- fontSize: theme.typography.fontSize + 4,
335
- padding: "".concat(theme.spacing.unit * 1.5, "px ").concat(theme.spacing.unit / 2, "px 0"),
336
- textAlign: 'center'
337
- },
338
- disabledTitle: {
339
- pointerEvents: 'none'
340
- },
341
- rightMargin: {
342
- marginRight: '74px'
343
- },
344
- topPixelGuides: {
345
- display: 'flex',
346
- paddingTop: '6px'
347
- },
348
- topPixelIndicator: {
349
- color: _renderUi.color.primaryLight(),
350
- display: 'flex',
351
- flexDirection: 'column',
352
- alignItems: 'center',
353
- width: '100px',
354
- pointerEvents: 'none',
355
- userSelect: 'none'
356
- },
357
- sidePixelGuides: {
358
- width: '70px',
359
- display: 'flex',
360
- flexDirection: 'column',
361
- marginRight: '6px'
362
- },
363
- sidePixelIndicator: {
364
- color: _renderUi.color.primaryLight(),
365
- textAlign: 'right',
366
- height: '20px',
367
- pointerEvents: 'none',
368
- userSelect: 'none',
369
- '&:not(:last-child)': {
370
- marginBottom: '80px'
371
- }
372
- }
373
- };
374
- };
375
-
376
- var _default = (0, _styles.withStyles)(styles)(Root);
377
-
378
- exports["default"] = _default;
379
- //# sourceMappingURL=root.js.map
package/lib/root.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/root.jsx"],"names":["Root","g","props","graphProps","onMouseMove","scale","snap","coords","_groups","x","invert","y","snapped","newValue","side","labels","onChangeLabels","isChart","on","mouseMove","bind","disabledTitle","disabledLabels","labelsPlaceholders","titlePlaceholder","children","classes","defineChart","onChangeTitle","showLabels","showPixelGuides","showTitle","title","rootRef","mathMlOptions","size","width","height","domain","range","topPadding","leftPadding","finalWidth","padding","finalHeight","activeTitlePlugins","actualHeight","nbOfVerticalLines","parseInt","nbOfHorizontalLines","sideGridlinesPadding","root","topPixelGuides","marginLeft","Array","keys","map","value","topPixelIndicator","chartTitle","graphTitle","__html","rightMargin","noBorder","top","onChangeLabel","wrapper","left","chart","r","graphBox","right","sidePixelGuides","paddingTop","marginTop","reverse","sidePixelIndicator","bottom","React","Component","PropTypes","string","ChildrenType","bool","GraphPropsType","isRequired","object","func","styles","theme","border","color","primaryLight","text","backgroundColor","background","touchAction","position","display","svg","paddingLeft","overflow","cursor","userSelect","fontSize","typography","spacing","unit","textAlign","pointerEvents","marginRight","flexDirection","alignItems","marginBottom"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;;IAEaA,I;;;;;;;;;;;;;;;kGAsBC,UAACC,CAAD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;AAIVC,MAAAA,SAAS,EAAE;AAJD,KA9Ba;AAoCzBvF,IAAAA,aAAa,EAAE;AACbwF,MAAAA,aAAa,EAAE;AADF,KApCU;AAuCzB/C,IAAAA,WAAW,EAAE;AACXgD,MAAAA,WAAW,EAAE;AADF,KAvCY;AA0CzB1D,IAAAA,cAAc,EAAE;AACd8C,MAAAA,OAAO,EAAE,MADK;AAEdzB,MAAAA,UAAU,EAAE;AAFE,KA1CS;AA8CzBf,IAAAA,iBAAiB,EAAE;AACjBiC,MAAAA,KAAK,EAAEA,gBAAMC,YAAN,EADU;AAEjBM,MAAAA,OAAO,EAAE,MAFQ;AAGjBa,MAAAA,aAAa,EAAE,QAHE;AAIjBC,MAAAA,UAAU,EAAE,QAJK;AAKjB5E,MAAAA,KAAK,EAAE,OALU;AAMjByE,MAAAA,aAAa,EAAE,MANE;AAOjBN,MAAAA,UAAU,EAAE;AAPK,KA9CM;AAuDzB/B,IAAAA,eAAe,EAAE;AACfpC,MAAAA,KAAK,EAAE,MADQ;AAEf8D,MAAAA,OAAO,EAAE,MAFM;AAGfa,MAAAA,aAAa,EAAE,QAHA;AAIfD,MAAAA,WAAW,EAAE;AAJE,KAvDQ;AA6DzBlC,IAAAA,kBAAkB,EAAE;AAClBe,MAAAA,KAAK,EAAEA,gBAAMC,YAAN,EADW;AAElBgB,MAAAA,SAAS,EAAE,OAFO;AAGlBvE,MAAAA,MAAM,EAAE,MAHU;AAIlBwE,MAAAA,aAAa,EAAE,MAJG;AAKlBN,MAAAA,UAAU,EAAE,MALM;AAOlB,4BAAsB;AACpBU,QAAAA,YAAY,EAAE;AADM;AAPJ;AA7DK,GAAZ;AAAA,CAAf;;eA0Ee,wBAAWzB,MAAX,EAAmBxF,IAAnB,C","sourcesContent":["import React from 'react';\nimport { ChildrenType } from './types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { select, mouse } from 'd3-selection';\nimport PropTypes from 'prop-types';\nimport { GraphPropsType } from './types';\nimport { color, Readable } from '@pie-lib/render-ui';\nimport EditableHtml from '@pie-lib/editable-html';\nimport cn from 'classnames';\nimport Label from './label';\n\nexport class Root extends React.Component {\n static propTypes = {\n title: PropTypes.string,\n children: ChildrenType,\n defineChart: PropTypes.bool,\n disabledLabels: PropTypes.bool,\n disabledTitle: PropTypes.bool,\n graphProps: GraphPropsType.isRequired,\n isChart: PropTypes.bool,\n labels: PropTypes.object,\n labelsPlaceholders: PropTypes.object,\n onChangeTitle: PropTypes.func,\n onMouseMove: PropTypes.func,\n classes: PropTypes.object.isRequired,\n showLabels: PropTypes.bool,\n showTitle: PropTypes.bool,\n showPixelGuides: PropTypes.bool,\n rootRef: PropTypes.func,\n onChangeLabels: PropTypes.func,\n titlePlaceholder: PropTypes.string,\n };\n\n mouseMove = (g) => {\n const { graphProps, onMouseMove } = this.props;\n\n if (!onMouseMove) {\n return;\n }\n\n const { scale, snap } = graphProps;\n const coords = mouse(g._groups[0][0]);\n const x = scale.x.invert(coords[0]);\n const y = scale.y.invert(coords[1]);\n\n const snapped = {\n x: snap.x(x),\n y: snap.y(y),\n };\n\n onMouseMove(snapped);\n };\n\n componentDidMount() {\n const g = select(this.g);\n g.on('mousemove', this.mouseMove.bind(this, g));\n }\n\n componentWillUnmount() {\n const g = select(this.g);\n g.on('mousemove', null);\n }\n\n onChangeLabel = (newValue, side) => {\n const { labels, onChangeLabels, isChart } = this.props;\n\n if (isChart) {\n if (side === 'left') {\n onChangeLabels('range', newValue);\n } else {\n onChangeLabels('domain', newValue);\n }\n\n return;\n }\n\n onChangeLabels({\n ...labels,\n [side]: newValue,\n });\n };\n\n render() {\n const {\n disabledTitle,\n disabledLabels,\n labels,\n labelsPlaceholders,\n titlePlaceholder,\n graphProps,\n children,\n classes,\n defineChart,\n onChangeTitle,\n isChart,\n showLabels,\n showPixelGuides,\n showTitle,\n title,\n rootRef,\n mathMlOptions = {},\n } = this.props;\n const {\n size: { width = 500, height = 500 },\n domain,\n range,\n } = graphProps;\n\n const topPadding = 40;\n const leftPadding = showLabels ? 80 : 60;\n const finalWidth = width + leftPadding * 2 + (domain.padding || 0) * 2;\n const finalHeight = height + topPadding * 2 + (range.padding || 0) * 2;\n\n const activeTitlePlugins = [\n 'bold',\n 'italic',\n 'underline',\n 'strikethrough',\n 'math',\n // 'languageCharacters'\n ];\n\n const actualHeight = defineChart && showPixelGuides ? height - 160 : height;\n const nbOfVerticalLines = parseInt(width / 100);\n const nbOfHorizontalLines = parseInt(actualHeight / 100);\n const sideGridlinesPadding = parseInt(actualHeight % 100);\n\n return (\n <div className={classes.root}>\n {showPixelGuides && (\n <div className={classes.topPixelGuides} style={{ marginLeft: isChart ? 60 : showLabels ? 30 : 10 }}>\n {[...Array(nbOfVerticalLines + 1).keys()].map((value) => (\n <Readable false key={`top-guide-${value}`}>\n <div className={classes.topPixelIndicator}>\n <div>{value * 100}px</div>\n <div>|</div>\n </div>\n </Readable>\n ))}\n </div>\n )}\n {showTitle &&\n (disabledTitle ? (\n <div\n style={\n isChart && {\n width: finalWidth,\n }\n }\n className={cn(isChart ? classes.chartTitle : classes.graphTitle, classes.disabledTitle)}\n dangerouslySetInnerHTML={{ __html: title || '' }}\n />\n ) : (\n <EditableHtml\n style={\n isChart && {\n width: finalWidth,\n }\n }\n className={cn(\n { [classes.rightMargin]: showPixelGuides },\n isChart ? classes.chartTitle : classes.graphTitle,\n )}\n markup={title || ''}\n onChange={onChangeTitle}\n placeholder={\n (defineChart && titlePlaceholder) || (!disabledTitle && 'Click here to add a title for this graph')\n }\n toolbarOpts={{ noBorder: true }}\n activePlugins={activeTitlePlugins}\n disableScrollbar\n />\n ))}\n {showLabels && !isChart && (\n <Label\n side=\"top\"\n text={labels.top}\n disabledLabel={disabledLabels}\n placeholder={labelsPlaceholders?.top}\n graphHeight={finalHeight}\n graphWidth={finalWidth}\n onChange={(value) => this.onChangeLabel(value, 'top')}\n mathMlOptions={mathMlOptions}\n />\n )}\n <div className={classes.wrapper}>\n {showLabels && (\n <Label\n side=\"left\"\n text={labels.left}\n disabledLabel={disabledLabels}\n placeholder={labelsPlaceholders?.left}\n graphHeight={finalHeight}\n graphWidth={finalWidth}\n isChartLeftLabel={isChart && !defineChart}\n isDefineChartLeftLabel={isChart && defineChart}\n onChange={(value) => this.onChangeLabel(value, 'left')}\n mathMlOptions={mathMlOptions}\n />\n )}\n <svg width={finalWidth} height={finalHeight} className={defineChart ? classes.defineChart : classes.chart}>\n <g\n ref={(r) => {\n this.g = r;\n if (rootRef) {\n rootRef(r);\n }\n }}\n className={classes.graphBox}\n transform={`translate(${leftPadding}, ${topPadding})`}\n >\n {children}\n </g>\n </svg>\n {showLabels && !isChart && (\n <Label\n side=\"right\"\n text={labels.right}\n disabledLabel={disabledLabels}\n placeholder={labelsPlaceholders?.right}\n graphHeight={finalHeight}\n graphWidth={finalWidth}\n onChange={(value) => this.onChangeLabel(value, 'right')}\n mathMlOptions={mathMlOptions}\n />\n )}\n {showPixelGuides && (\n <div\n className={classes.sidePixelGuides}\n style={{\n paddingTop: sideGridlinesPadding,\n marginTop: defineChart ? 25 : 31,\n }}\n >\n {[...Array(nbOfHorizontalLines + 1).keys()].reverse().map((value) => (\n <Readable false key={`top-guide-${value}`}>\n <div className={classes.sidePixelIndicator}>━ {value * 100}px</div>\n </Readable>\n ))}\n </div>\n )}\n </div>\n {showLabels && (\n <Label\n side=\"bottom\"\n text={labels.bottom}\n disabledLabel={disabledLabels}\n placeholder={labelsPlaceholders?.bottom}\n graphHeight={finalHeight}\n graphWidth={finalWidth}\n isChartBottomLabel={isChart && !defineChart}\n isDefineChartBottomLabel={isChart && defineChart}\n onChange={(value) => this.onChangeLabel(value, 'bottom')}\n mathMlOptions={mathMlOptions}\n />\n )}\n </div>\n );\n }\n}\n\nconst styles = (theme) => ({\n root: {\n border: `solid 1px ${color.primaryLight()}`,\n color: color.text(),\n backgroundColor: color.background(),\n touchAction: 'none',\n position: 'relative',\n },\n wrapper: {\n display: 'flex',\n position: 'relative',\n },\n svg: {},\n defineChart: {\n paddingLeft: '50px',\n overflow: 'visible',\n },\n chart: {\n overflow: 'visible',\n },\n graphBox: {\n cursor: 'pointer',\n userSelect: 'none',\n },\n graphTitle: {\n color: color.text(),\n fontSize: theme.typography.fontSize + 2,\n padding: `${theme.spacing.unit * 1.5}px ${theme.spacing.unit / 2}px 0`,\n textAlign: 'center',\n },\n chartTitle: {\n color: color.text(),\n fontSize: theme.typography.fontSize + 4,\n padding: `${theme.spacing.unit * 1.5}px ${theme.spacing.unit / 2}px 0`,\n textAlign: 'center',\n },\n disabledTitle: {\n pointerEvents: 'none',\n },\n rightMargin: {\n marginRight: '74px',\n },\n topPixelGuides: {\n display: 'flex',\n paddingTop: '6px',\n },\n topPixelIndicator: {\n color: color.primaryLight(),\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n width: '100px',\n pointerEvents: 'none',\n userSelect: 'none',\n },\n sidePixelGuides: {\n width: '70px',\n display: 'flex',\n flexDirection: 'column',\n marginRight: '6px',\n },\n sidePixelIndicator: {\n color: color.primaryLight(),\n textAlign: 'right',\n height: '20px',\n pointerEvents: 'none',\n userSelect: 'none',\n\n '&:not(:last-child)': {\n marginBottom: '80px',\n },\n },\n});\n\nexport default withStyles(styles)(Root);\n"],"file":"root.js"}
package/lib/trig.js DELETED
@@ -1,196 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.toRadians = exports.toDegrees = exports.hypotenuse = exports.getOpposingSide = exports.edges = exports.diffEdge = exports.angle = exports.acuteYAngle = exports.acuteXAngle = void 0;
9
-
10
- var _utils = require("../lib/utils");
11
-
12
- var _pointGeometry = _interopRequireDefault(require("@mapbox/point-geometry"));
13
-
14
- var _debug = _interopRequireDefault(require("debug"));
15
-
16
- var log = (0, _debug["default"])('pie-lib:plot:trig');
17
-
18
- var toDegrees = function toDegrees(radians) {
19
- return radians * (180 / Math.PI);
20
- };
21
-
22
- exports.toDegrees = toDegrees;
23
-
24
- var toRadians = function toRadians(degrees) {
25
- return degrees * (Math.PI / 180);
26
- };
27
- /**
28
- * return angle in radians between 2 points using counting degrees counter clockwise
29
- *
30
- * 0,0 + 1,1 = 45 in radians
31
- * 1,1 + 0,0 = 45?
32
- * @param {Point} a
33
- * @param {Point} b
34
- */
35
-
36
-
37
- exports.toRadians = toRadians;
38
-
39
- var angle = function angle(a, b) {
40
- var vd = b.y - a.y;
41
- var hd = b.x - a.x;
42
- log(a, b, 'vd: ', vd, 'hd: ', hd);
43
- var radians = Math.atan2(vd, hd);
44
- return radians < 0 ? radians + Math.PI * 2 : radians;
45
- };
46
-
47
- exports.angle = angle;
48
- var NINETY = Math.PI / 2;
49
- var ONE_EIGHTY = Math.PI;
50
- var TWO_SEVENTY = ONE_EIGHTY + NINETY;
51
-
52
- var acuteXAngle = function acuteXAngle(a) {
53
- log(toDegrees(a));
54
-
55
- if (a < NINETY) {
56
- return a;
57
- }
58
-
59
- if (a < ONE_EIGHTY) {
60
- return Math.abs(ONE_EIGHTY - a);
61
- }
62
-
63
- if (a < TWO_SEVENTY) {
64
- return Math.abs(ONE_EIGHTY - a);
65
- }
66
-
67
- return Math.abs(Math.PI * 2 - a);
68
- };
69
-
70
- exports.acuteXAngle = acuteXAngle;
71
-
72
- var acuteYAngle = function acuteYAngle(a) {
73
- return NINETY - acuteXAngle(a);
74
- };
75
-
76
- exports.acuteYAngle = acuteYAngle;
77
-
78
- var hypotenuse = function hypotenuse(a, alpha) {
79
- var out = Math.abs(a / Math.sin(alpha));
80
- return out;
81
- };
82
- /**
83
- * return 2 edge points for a,b within domain + range.
84
- * - one edge is from following a -> b to the bounds
85
- * - one edge is from following b -> a to the bounds
86
- * @param {{min: number, max: number}} domain
87
- * @param {{min: number, max: number}} range
88
- * @param {{x: number, y: number}} a
89
- * @param {{x: number, y: number}} b
90
- * @returns [{x: number, y: number}, {x: number, y: number}]
91
- */
92
-
93
-
94
- exports.hypotenuse = hypotenuse;
95
-
96
- var edges = function edges(domain, range) {
97
- return function (a, b) {
98
- // const xDest =
99
- var destX = a.x < b.x ? domain.max : domain.min;
100
- var destY = a.y < b.y ? range.max : range.min;
101
- var aToB = diffEdge((0, _utils.xy)(destX, destY), a, b);
102
- var dX = b.x < a.x ? domain.max : domain.min;
103
- var dY = b.y < a.y ? range.max : range.min;
104
- var bToA = diffEdge((0, _utils.xy)(dX, dY), b, a);
105
- return [aToB, bToA];
106
- };
107
- };
108
- /** get length of side A of a triangle from H and angle Alpha */
109
-
110
-
111
- exports.edges = edges;
112
-
113
- var getOpposingSide = function getOpposingSide(hyp, angle) {
114
- log('[getOpposingSide] hyp: ', hyp, 'angle:', angle);
115
- return Math.abs(hyp * Math.sin(angle));
116
- };
117
-
118
- exports.getOpposingSide = getOpposingSide;
119
-
120
- var getShortestSide = function getShortestSide(xh, yh) {
121
- if (Number.isFinite(xh) && Number.isFinite(yh)) {
122
- if (xh === 0 && yh > 0) {
123
- return 'y';
124
- }
125
-
126
- if (yh === 0 && xh > 0) {
127
- return 'x';
128
- }
129
-
130
- return xh < yh ? 'x' : 'y';
131
- }
132
-
133
- if (isNaN(xh) && !isNaN(yh)) {
134
- return 'y';
135
- }
136
-
137
- if (!isNaN(xh) && isNaN(yh)) {
138
- return 'x';
139
- }
140
-
141
- if (xh === Infinity) {
142
- return 'y';
143
- }
144
-
145
- if (yh === Infinity) {
146
- return 'x';
147
- } // eslint-disable-next-line no-console
148
-
149
-
150
- console.warn('hypotenuse - which is shorter? x:', xh, 'y:', yh);
151
- };
152
- /**
153
- * return the difference between bounds and a as a Point
154
- * @param {*} bounds
155
- */
156
-
157
-
158
- var diffEdge = function diffEdge(bounds, a, b) {
159
- var l = log.enabled ? log.bind(log, "diffEdge: [".concat(a.x, ",").concat(a.y, " -> ").concat(b.x, ",").concat(b.y, "]")) : function () {};
160
- var xRadians = angle(a, b);
161
- l('x angle', toDegrees(xRadians));
162
- var yRadians = Math.abs(xRadians - toRadians(90));
163
- l('y angle', toDegrees(yRadians));
164
- var xSide = Math.abs(a.x - bounds.x);
165
- /**
166
- * Draw 2 triangles:
167
- * 1 with a horizontal line from a to the graph x edge
168
- * 1 with a vertical line from a to the graph y edge
169
- * Calculate the hypotenuse for both, whichever is shorter
170
- * indicates that we should use that triangle to get the edge point.
171
- */
172
-
173
- var xH = hypotenuse(xSide, yRadians);
174
- var ySide = Math.abs(a.y - bounds.y);
175
- var yH = hypotenuse(ySide, xRadians);
176
- l('x: side', xSide, 'h:', xH);
177
- l('y: side', ySide, 'h:', yH);
178
- var side = getShortestSide(xH, yH);
179
-
180
- if (side !== 'x' && side !== 'y') {
181
- throw new Error('Cant decide which hypotenuse to use');
182
- }
183
-
184
- var point = side === 'x' ? new _pointGeometry["default"](xSide, getOpposingSide(xH, xRadians)) : new _pointGeometry["default"](getOpposingSide(yH, yRadians), ySide);
185
- l('point:', point);
186
- var multiplier = new _pointGeometry["default"](b.x < a.x ? -1 : 1, b.y < a.y ? -1 : 1);
187
- l('multiplier:', multiplier);
188
- var out = point.multByPoint(multiplier);
189
- l('out:', out);
190
- var normalized = out.add(new _pointGeometry["default"](a.x, a.y));
191
- l('normalized:', normalized);
192
- return normalized;
193
- };
194
-
195
- exports.diffEdge = diffEdge;
196
- //# sourceMappingURL=trig.js.map
package/lib/trig.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/trig.js"],"names":["log","toDegrees","radians","Math","PI","toRadians","degrees","angle","a","b","vd","y","hd","x","atan2","NINETY","ONE_EIGHTY","TWO_SEVENTY","acuteXAngle","abs","acuteYAngle","hypotenuse","alpha","out","sin","edges","domain","range","destX","max","min","destY","aToB","diffEdge","dX","dY","bToA","getOpposingSide","hyp","getShortestSide","xh","yh","Number","isFinite","isNaN","Infinity","console","warn","bounds","l","enabled","bind","xRadians","yRadians","xSide","xH","ySide","yH","side","Error","point","Point","multiplier","multByPoint","normalized","add"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA,IAAMA,GAAG,GAA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UAAhB,CAAD;AACA,SAAOA,UAAP;AACD,CAtCM","sourcesContent":["import { xy } from '../lib/utils';\nimport Point from '@mapbox/point-geometry';\nimport debug from 'debug';\nconst log = debug('pie-lib:plot:trig');\n\nexport const toDegrees = (radians) => radians * (180 / Math.PI);\nexport const toRadians = (degrees) => degrees * (Math.PI / 180);\n/**\n * return angle in radians between 2 points using counting degrees counter clockwise\n *\n * 0,0 + 1,1 = 45 in radians\n * 1,1 + 0,0 = 45?\n * @param {Point} a\n * @param {Point} b\n */\nexport const angle = (a, b) => {\n const vd = b.y - a.y;\n const hd = b.x - a.x;\n log(a, b, 'vd: ', vd, 'hd: ', hd);\n const radians = Math.atan2(vd, hd);\n return radians < 0 ? radians + Math.PI * 2 : radians;\n};\n\nconst NINETY = Math.PI / 2;\nconst ONE_EIGHTY = Math.PI;\nconst TWO_SEVENTY = ONE_EIGHTY + NINETY;\n\nexport const acuteXAngle = (a) => {\n log(toDegrees(a));\n\n if (a < NINETY) {\n return a;\n }\n\n if (a < ONE_EIGHTY) {\n return Math.abs(ONE_EIGHTY - a);\n }\n\n if (a < TWO_SEVENTY) {\n return Math.abs(ONE_EIGHTY - a);\n }\n\n return Math.abs(Math.PI * 2 - a);\n};\n\nexport const acuteYAngle = (a) => NINETY - acuteXAngle(a);\n\nexport const hypotenuse = (a, alpha) => {\n const out = Math.abs(a / Math.sin(alpha));\n\n return out;\n};\n\n/**\n * return 2 edge points for a,b within domain + range.\n * - one edge is from following a -> b to the bounds\n * - one edge is from following b -> a to the bounds\n * @param {{min: number, max: number}} domain\n * @param {{min: number, max: number}} range\n * @param {{x: number, y: number}} a\n * @param {{x: number, y: number}} b\n * @returns [{x: number, y: number}, {x: number, y: number}]\n */\nexport const edges = (domain, range) => (a, b) => {\n // const xDest =\n const destX = a.x < b.x ? domain.max : domain.min;\n const destY = a.y < b.y ? range.max : range.min;\n const aToB = diffEdge(xy(destX, destY), a, b);\n\n const dX = b.x < a.x ? domain.max : domain.min;\n const dY = b.y < a.y ? range.max : range.min;\n const bToA = diffEdge(xy(dX, dY), b, a);\n return [aToB, bToA];\n};\n\n/** get length of side A of a triangle from H and angle Alpha */\nexport const getOpposingSide = (hyp, angle) => {\n log('[getOpposingSide] hyp: ', hyp, 'angle:', angle);\n return Math.abs(hyp * Math.sin(angle));\n};\n\nconst getShortestSide = (xh, yh) => {\n if (Number.isFinite(xh) && Number.isFinite(yh)) {\n if (xh === 0 && yh > 0) {\n return 'y';\n }\n if (yh === 0 && xh > 0) {\n return 'x';\n }\n return xh < yh ? 'x' : 'y';\n }\n if (isNaN(xh) && !isNaN(yh)) {\n return 'y';\n }\n if (!isNaN(xh) && isNaN(yh)) {\n return 'x';\n }\n if (xh === Infinity) {\n return 'y';\n }\n if (yh === Infinity) {\n return 'x';\n }\n\n // eslint-disable-next-line no-console\n console.warn('hypotenuse - which is shorter? x:', xh, 'y:', yh);\n};\n/**\n * return the difference between bounds and a as a Point\n * @param {*} bounds\n */\nexport const diffEdge = (bounds, a, b) => {\n let l = log.enabled ? log.bind(log, `diffEdge: [${a.x},${a.y} -> ${b.x},${b.y}]`) : () => {};\n const xRadians = angle(a, b);\n l('x angle', toDegrees(xRadians));\n const yRadians = Math.abs(xRadians - toRadians(90));\n l('y angle', toDegrees(yRadians));\n const xSide = Math.abs(a.x - bounds.x);\n\n /**\n * Draw 2 triangles:\n * 1 with a horizontal line from a to the graph x edge\n * 1 with a vertical line from a to the graph y edge\n * Calculate the hypotenuse for both, whichever is shorter\n * indicates that we should use that triangle to get the edge point.\n */\n const xH = hypotenuse(xSide, yRadians);\n\n const ySide = Math.abs(a.y - bounds.y);\n const yH = hypotenuse(ySide, xRadians);\n\n l('x: side', xSide, 'h:', xH);\n l('y: side', ySide, 'h:', yH);\n const side = getShortestSide(xH, yH);\n\n if (side !== 'x' && side !== 'y') {\n throw new Error('Cant decide which hypotenuse to use');\n }\n const point =\n side === 'x' ? new Point(xSide, getOpposingSide(xH, xRadians)) : new Point(getOpposingSide(yH, yRadians), ySide);\n\n l('point:', point);\n const multiplier = new Point(b.x < a.x ? -1 : 1, b.y < a.y ? -1 : 1);\n l('multiplier:', multiplier);\n const out = point.multByPoint(multiplier);\n l('out:', out);\n const normalized = out.add(new Point(a.x, a.y));\n l('normalized:', normalized);\n return normalized;\n};\n"],"file":"trig.js"}