@pie-lib/plot 2.4.1 → 2.5.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.json CHANGED
@@ -333,5 +333,20 @@
333
333
  "committerDate": "2021-03-26 12:18:14 +0200",
334
334
  "isTagged": true,
335
335
  "tag": "@pie-lib/plot@2.1.5"
336
+ },
337
+ {
338
+ "type": "fix",
339
+ "scope": "charting",
340
+ "subject": "fix conflicts",
341
+ "merge": null,
342
+ "header": "fix(charting): fix conflicts",
343
+ "body": null,
344
+ "footer": null,
345
+ "notes": [],
346
+ "hash": "2b3da1b4b87a518b5c18daf6f6c57db1ccc1c536",
347
+ "gitTags": "",
348
+ "committerDate": "2022-09-19 15:27:23 +0300",
349
+ "isTagged": true,
350
+ "tag": "@pie-lib/plot@2.5.0"
336
351
  }
337
352
  ]
package/CHANGELOG.md CHANGED
@@ -3,6 +3,39 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.5.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.4.2...@pie-lib/plot@2.5.0) (2022-09-28)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **charting:** arrange the position of the checkboxes labels, fix style amd arrangement ([c5f2f7a](https://github.com/pie-framework/pie-lib/commit/c5f2f7acf60898e77ecc0b47b190256537605c8e))
12
+ * **charting:** change position for checbox labels in order to fit without overlapping the checboxes ([98a56cb](https://github.com/pie-framework/pie-lib/commit/98a56cbae47c4bcadd0d4087d6b7df3c4d5d3e2e))
13
+ * **charting:** fix conflicts ([2b3da1b](https://github.com/pie-framework/pie-lib/commit/2b3da1b4b87a518b5c18daf6f6c57db1ccc1c536))
14
+ * **charting:** prevent page scroll on devices when a charting category is dragged ([6fe37ff](https://github.com/pie-framework/pie-lib/commit/6fe37ffa0e2c387d7174d0daf5cfc1cf9e8abf80))
15
+ * **editable-html, graphing:** Add support to remove scrollbar from editable-html and removed scrollbar from graphing labels PD-1968 ([d04a0d3](https://github.com/pie-framework/pie-lib/commit/d04a0d3bc66d4b861f60b24198301459c15bd151))
16
+
17
+
18
+ ### Features
19
+
20
+ * **charting:** refactor ability to edit chart title and labels, fix style ([6edcdfb](https://github.com/pie-framework/pie-lib/commit/6edcdfbfbd83806a8487c29c42ae447b11850ac7))
21
+ * **charting:** try to set up labels for charting, work in progress ([c6cd049](https://github.com/pie-framework/pie-lib/commit/c6cd049723dadab329748511da2f6c4f1fa943db))
22
+ * **graphing, plot:** moved graphing labels to plot package + fixed math input + added support for labels rotation PD-1962 ([a85ec39](https://github.com/pie-framework/pie-lib/commit/a85ec3911dd1f6bc89e4eb20a19ef8f957deebf1))
23
+
24
+
25
+
26
+
27
+
28
+ ## [2.4.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.4.1...@pie-lib/plot@2.4.2) (2022-08-30)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * **plot, charting, graphing:** adjusted side pixel guides, fixed graphing rendering issue, adjusted charting dimensions PD-1963 ([5043231](https://github.com/pie-framework/pie-lib/commit/5043231ba73a0aa475115fb5fe9af29e0e67a4b6))
34
+
35
+
36
+
37
+
38
+
6
39
  ## [2.4.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.4.0...@pie-lib/plot@2.4.1) (2022-08-29)
7
40
 
8
41
  **Note:** Version bump only for package @pie-lib/plot
package/lib/label.js ADDED
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports["default"] = void 0;
11
+
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
+
16
+ var _react = _interopRequireWildcard(require("react"));
17
+
18
+ var _renderUi = require("@pie-lib/render-ui");
19
+
20
+ var _classnames = _interopRequireDefault(require("classnames"));
21
+
22
+ var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
23
+
24
+ var _styles = require("@material-ui/core/styles");
25
+
26
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
+
28
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
+
30
+ var LabelComponent = function LabelComponent(props) {
31
+ var _cn;
32
+
33
+ var classes = props.classes,
34
+ disabledLabel = props.disabledLabel,
35
+ graphHeight = props.graphHeight,
36
+ graphWidth = props.graphWidth,
37
+ isChartBottomLabel = props.isChartBottomLabel,
38
+ isChartLeftLabel = props.isChartLeftLabel,
39
+ placeholder = props.placeholder,
40
+ text = props.text,
41
+ side = props.side,
42
+ onChange = props.onChange;
43
+
44
+ var _useState = (0, _react.useState)(false),
45
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
46
+ rotatedToHorizontal = _useState2[0],
47
+ setRotatedToHorizontal = _useState2[1];
48
+
49
+ var activePlugins = ['bold', 'italic', 'underline', 'strikethrough', 'math' // 'languageCharacters'
50
+ ];
51
+ var chartValue = side === 'left' && isChartLeftLabel && graphHeight - 148;
52
+ var defaultStyle = {
53
+ width: chartValue || (side === 'left' || side === 'right' ? graphHeight - 8 : graphWidth - 8),
54
+ top: chartValue || side === 'left' && "".concat(graphHeight - 8, "px") || side === 'bottom' && "".concat(graphHeight - 90, "px") || 0,
55
+ left: side === 'right' && "".concat(graphWidth - 8, "px") || (isChartLeftLabel || isChartBottomLabel) && '50px' || 0
56
+ };
57
+ var rotatedStyle = {
58
+ width: graphWidth - 8,
59
+ top: side === 'right' && "".concat(graphHeight - 22, "px") || 0,
60
+ left: 0
61
+ };
62
+
63
+ var rotateLabel = function rotateLabel() {
64
+ return !disabledLabel && (side === 'left' || side === 'right') && setRotatedToHorizontal(true);
65
+ };
66
+
67
+ return /*#__PURE__*/_react["default"].createElement(_renderUi.Readable, {
68
+ "false": true
69
+ }, /*#__PURE__*/_react["default"].createElement("div", {
70
+ className: (0, _classnames["default"])(classes.axisLabel, (_cn = {}, (0, _defineProperty2["default"])(_cn, classes.rotateLeftLabel, side === 'left' && !rotatedToHorizontal), (0, _defineProperty2["default"])(_cn, classes.rotateRightLabel, side === 'right' && !rotatedToHorizontal), (0, _defineProperty2["default"])(_cn, classes.editLabel, rotatedToHorizontal), (0, _defineProperty2["default"])(_cn, classes.customBottom, isChartBottomLabel), _cn)),
71
+ style: rotatedToHorizontal ? rotatedStyle : defaultStyle,
72
+ onClick: rotateLabel
73
+ }, disabledLabel ? /*#__PURE__*/_react["default"].createElement("div", {
74
+ className: classes.disabledLabel,
75
+ dangerouslySetInnerHTML: {
76
+ __html: text || ''
77
+ }
78
+ }) : /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
79
+ markup: text || '',
80
+ onChange: onChange,
81
+ placeholder: !disabledLabel && placeholder,
82
+ toolbarOpts: {
83
+ position: side === 'bottom' ? 'top' : 'bottom',
84
+ noBorder: true
85
+ },
86
+ disableScrollbar: true,
87
+ activePlugins: activePlugins,
88
+ onDone: function onDone() {
89
+ return setRotatedToHorizontal(false);
90
+ }
91
+ })));
92
+ };
93
+
94
+ var _default = (0, _styles.withStyles)(function (theme) {
95
+ return {
96
+ label: {
97
+ fill: _renderUi.color.secondary()
98
+ },
99
+ axisLabel: {
100
+ fontSize: theme.typography.fontSize - 2,
101
+ textAlign: 'center',
102
+ margin: '4px',
103
+ padding: '4px 0'
104
+ },
105
+ disabledLabel: {
106
+ pointerEvents: 'none',
107
+ width: '100%'
108
+ },
109
+ editLabel: {
110
+ position: 'absolute',
111
+ backgroundColor: 'white',
112
+ borderRadius: '4px',
113
+ boxShadow: '0px 5px 8px rgba(0, 0, 0, 0.15)',
114
+ zIndex: 10
115
+ },
116
+ rotateLeftLabel: {
117
+ rotate: '-90deg',
118
+ transformOrigin: '0 0',
119
+ transformStyle: 'preserve-3d',
120
+ position: 'absolute'
121
+ },
122
+ rotateRightLabel: {
123
+ rotate: '90deg',
124
+ transformOrigin: '0 0',
125
+ transformStyle: 'preserve-3d',
126
+ position: 'absolute'
127
+ },
128
+ customBottom: {
129
+ position: 'absolute'
130
+ }
131
+ };
132
+ })(LabelComponent);
133
+
134
+ exports["default"] = _default;
135
+ //# sourceMappingURL=label.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/label.jsx"],"names":["LabelComponent","props","classes","disabledLabel","graphHeight","graphWidth","isChartBottomLabel","isChartLeftLabel","placeholder","text","side","onChange","rotatedToHorizontal","setRotatedToHorizontal","activePlugins","chartValue","defaultStyle","width","top","left","rotatedStyle","rotateLabel","axisLabel","rotateLeftLabel","rotateRightLabel","editLabel","customBottom","__html","position","noBorder","theme","label","fill","color","secondary","fontSize","typography","textAlign","margin","padding","pointerEvents","backgroundColor","borderRadius","boxShadow","zIndex","rotate","transformOrigin","transformStyle"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAA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AQ,EAAE;AADE;AAjCoB,GAAL;AAAA,CAAhB,EAoCX5B,cApCW,C","sourcesContent":["import React, { useState } from 'react';\nimport { color, Readable } from '@pie-lib/render-ui';\nimport cn from 'classnames';\nimport EditableHtml from '@pie-lib/editable-html';\nimport { withStyles } from '@material-ui/core/styles';\n\nconst LabelComponent = props => {\n const {\n classes,\n disabledLabel,\n graphHeight,\n graphWidth,\n isChartBottomLabel,\n isChartLeftLabel,\n placeholder,\n text,\n side,\n onChange\n } = props;\n const [rotatedToHorizontal, setRotatedToHorizontal] = useState(false);\n const activePlugins = [\n 'bold',\n 'italic',\n 'underline',\n 'strikethrough',\n 'math'\n // 'languageCharacters'\n ];\n\n const chartValue = side === 'left' && isChartLeftLabel && graphHeight - 148;\n const defaultStyle = {\n width: chartValue || (side === 'left' || side === 'right' ? graphHeight - 8 : graphWidth - 8),\n top:\n chartValue ||\n (side === 'left' && `${graphHeight - 8}px`) ||\n (side === 'bottom' && `${graphHeight - 90}px`) ||\n 0,\n left:\n (side === 'right' && `${graphWidth - 8}px`) ||\n ((isChartLeftLabel || isChartBottomLabel) && '50px') ||\n 0\n };\n\n const rotatedStyle = {\n width: graphWidth - 8,\n top: (side === 'right' && `${graphHeight - 22}px`) || 0,\n left: 0\n };\n\n const rotateLabel = () =>\n !disabledLabel && (side === 'left' || side === 'right') && setRotatedToHorizontal(true);\n\n return (\n <Readable false>\n <div\n className={cn(classes.axisLabel, {\n [classes.rotateLeftLabel]: side === 'left' && !rotatedToHorizontal,\n [classes.rotateRightLabel]: side === 'right' && !rotatedToHorizontal,\n [classes.editLabel]: rotatedToHorizontal,\n [classes.customBottom]: isChartBottomLabel\n })}\n style={rotatedToHorizontal ? rotatedStyle : defaultStyle}\n onClick={rotateLabel}\n >\n {disabledLabel ? (\n <div className={classes.disabledLabel} dangerouslySetInnerHTML={{ __html: text || '' }} />\n ) : (\n <EditableHtml\n markup={text || ''}\n onChange={onChange}\n placeholder={!disabledLabel && placeholder}\n toolbarOpts={{\n position: side === 'bottom' ? 'top' : 'bottom',\n noBorder: true\n }}\n disableScrollbar\n activePlugins={activePlugins}\n onDone={() => setRotatedToHorizontal(false)}\n />\n )}\n </div>\n </Readable>\n );\n};\n\nexport default withStyles(theme => ({\n label: {\n fill: color.secondary()\n },\n axisLabel: {\n fontSize: theme.typography.fontSize - 2,\n textAlign: 'center',\n margin: '4px',\n padding: '4px 0'\n },\n disabledLabel: {\n pointerEvents: 'none',\n width: '100%'\n },\n editLabel: {\n position: 'absolute',\n backgroundColor: 'white',\n borderRadius: '4px',\n boxShadow: '0px 5px 8px rgba(0, 0, 0, 0.15)',\n zIndex: 10\n },\n rotateLeftLabel: {\n rotate: '-90deg',\n transformOrigin: '0 0',\n transformStyle: 'preserve-3d',\n position: 'absolute'\n },\n rotateRightLabel: {\n rotate: '90deg',\n transformOrigin: '0 0',\n transformStyle: 'preserve-3d',\n position: 'absolute'\n },\n customBottom: {\n position: 'absolute'\n }\n}))(LabelComponent);\n"],"file":"label.js"}
package/lib/root.js CHANGED
@@ -39,6 +39,12 @@ var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
39
39
 
40
40
  var _classnames = _interopRequireDefault(require("classnames"));
41
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
+
42
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); }; }
43
49
 
44
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; } }
@@ -78,6 +84,24 @@ var Root = /*#__PURE__*/function (_React$Component) {
78
84
  };
79
85
  onMouseMove(snapped);
80
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
+ });
81
105
  return _this;
82
106
  }
83
107
 
@@ -98,18 +122,23 @@ var Root = /*#__PURE__*/function (_React$Component) {
98
122
  value: function render() {
99
123
  var _this2 = this;
100
124
 
101
- var _this$props2 = this.props,
102
- disabledTitle = _this$props2.disabledTitle,
103
- graphProps = _this$props2.graphProps,
104
- children = _this$props2.children,
105
- classes = _this$props2.classes,
106
- onChangeTitle = _this$props2.onChangeTitle,
107
- thisIsChart = _this$props2.thisIsChart,
108
- showLabels = _this$props2.showLabels,
109
- showPixelGuides = _this$props2.showPixelGuides,
110
- showTitle = _this$props2.showTitle,
111
- title = _this$props2.title,
112
- rootRef = _this$props2.rootRef;
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;
113
142
  var _graphProps$size = graphProps.size,
114
143
  _graphProps$size$widt = _graphProps$size.width,
115
144
  width = _graphProps$size$widt === void 0 ? 500 : _graphProps$size$widt,
@@ -117,20 +146,23 @@ var Root = /*#__PURE__*/function (_React$Component) {
117
146
  height = _graphProps$size$heig === void 0 ? 500 : _graphProps$size$heig,
118
147
  domain = graphProps.domain,
119
148
  range = graphProps.range;
120
- var chartPadding = thisIsChart ? 45 : 0;
121
- var padding = showLabels ? 70 : 40;
122
- var extraPadding = showLabels ? 16 : 40;
123
- var finalWidth = width + padding * 2 + (domain.padding || 0) * 2 + extraPadding;
124
- var finalHeight = height + padding * 2 + (range.padding || 0) * 2;
149
+ var topPadding = 40;
150
+ var leftPadding = showLabels ? 80 : 60;
151
+ var finalWidth = width + leftPadding * 2 + (domain.padding || 0) * 2;
152
+ var finalHeight = height + topPadding * 2 + (range.padding || 0) * 2;
125
153
  var activeTitlePlugins = ['bold', 'italic', 'underline', 'strikethrough', 'math' // 'languageCharacters'
126
154
  ];
155
+ var actualHeight = defineChart && showPixelGuides ? height - 150 : height;
127
156
  var nbOfVerticalLines = parseInt(width / 100);
128
- var nbOfHorizontalLines = parseInt(height / 100);
129
- var sideGridlinesPadding = parseInt(height % 100);
157
+ var nbOfHorizontalLines = parseInt(actualHeight / 100);
158
+ var sideGridlinesPadding = parseInt(actualHeight % 100);
130
159
  return /*#__PURE__*/_react["default"].createElement("div", {
131
160
  className: classes.root
132
161
  }, showPixelGuides && /*#__PURE__*/_react["default"].createElement("div", {
133
- className: classes.topPixelGuides
162
+ className: classes.topPixelGuides,
163
+ style: {
164
+ marginLeft: isChart ? 60 : showLabels ? 30 : 10
165
+ }
134
166
  }, (0, _toConsumableArray2["default"])(Array(nbOfVerticalLines + 1).keys()).map(function (value) {
135
167
  return /*#__PURE__*/_react["default"].createElement(_renderUi.Readable, {
136
168
  "false": true,
@@ -138,22 +170,48 @@ var Root = /*#__PURE__*/function (_React$Component) {
138
170
  }, /*#__PURE__*/_react["default"].createElement("div", {
139
171
  className: classes.topPixelIndicator
140
172
  }, /*#__PURE__*/_react["default"].createElement("div", null, value * 100, "px"), /*#__PURE__*/_react["default"].createElement("div", null, "|")));
141
- })), showTitle && /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
142
- className: (0, _classnames["default"])((0, _defineProperty2["default"])({}, classes.disabledTitle, disabledTitle), classes.graphTitle),
173
+ })), showTitle && (disabledTitle ? /*#__PURE__*/_react["default"].createElement("div", {
174
+ className: (0, _classnames["default"])(classes.graphTitle, classes.disabledTitle),
175
+ dangerouslySetInnerHTML: {
176
+ __html: title || ''
177
+ }
178
+ }) : /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
179
+ className: (0, _classnames["default"])((0, _defineProperty2["default"])({}, classes.rightMargin, showPixelGuides), classes.graphTitle),
143
180
  markup: title || '',
144
- width: finalWidth,
145
181
  onChange: onChangeTitle,
146
- placeholder: !disabledTitle && 'Click here to add a title for this graph',
182
+ placeholder: defineChart && titlePlaceholder || !disabledTitle && 'Click here to add a title for this graph',
147
183
  toolbarOpts: {
148
184
  noBorder: true
149
185
  },
150
- activePlugins: activeTitlePlugins
186
+ activePlugins: activeTitlePlugins,
187
+ disableScrollbar: true
188
+ })), showLabels && !isChart && /*#__PURE__*/_react["default"].createElement(_label["default"], {
189
+ side: "top",
190
+ text: labels.top,
191
+ disabledLabel: disabledLabels,
192
+ placeholder: labelsPlaceholders === null || labelsPlaceholders === void 0 ? void 0 : labelsPlaceholders.top,
193
+ graphHeight: finalHeight,
194
+ graphWidth: finalWidth,
195
+ onChange: function onChange(value) {
196
+ return _this2.onChangeLabel(value, 'top');
197
+ }
151
198
  }), /*#__PURE__*/_react["default"].createElement("div", {
152
199
  className: classes.wrapper
153
- }, /*#__PURE__*/_react["default"].createElement("svg", {
200
+ }, showLabels && /*#__PURE__*/_react["default"].createElement(_label["default"], {
201
+ side: "left",
202
+ text: labels.left,
203
+ disabledLabel: disabledLabels,
204
+ placeholder: labelsPlaceholders === null || labelsPlaceholders === void 0 ? void 0 : labelsPlaceholders.left,
205
+ graphHeight: finalHeight,
206
+ graphWidth: finalWidth,
207
+ isChartLeftLabel: isChart && defineChart,
208
+ onChange: function onChange(value) {
209
+ return _this2.onChangeLabel(value, 'left');
210
+ }
211
+ }), /*#__PURE__*/_react["default"].createElement("svg", {
154
212
  width: finalWidth,
155
213
  height: finalHeight,
156
- className: classes.svg
214
+ className: defineChart ? classes.defineChart : classes.chart
157
215
  }, /*#__PURE__*/_react["default"].createElement("g", {
158
216
  ref: function ref(r) {
159
217
  _this2.g = r;
@@ -163,20 +221,42 @@ var Root = /*#__PURE__*/function (_React$Component) {
163
221
  }
164
222
  },
165
223
  className: classes.graphBox,
166
- transform: "translate(".concat(padding, ", ").concat(padding, ")")
167
- }, children)), showPixelGuides && /*#__PURE__*/_react["default"].createElement("div", {
224
+ transform: "translate(".concat(leftPadding, ", ").concat(topPadding, ")")
225
+ }, children)), showLabels && !isChart && /*#__PURE__*/_react["default"].createElement(_label["default"], {
226
+ side: "right",
227
+ text: labels.right,
228
+ disabledLabel: disabledLabels,
229
+ placeholder: labelsPlaceholders === null || labelsPlaceholders === void 0 ? void 0 : labelsPlaceholders.right,
230
+ graphHeight: finalHeight,
231
+ graphWidth: finalWidth,
232
+ onChange: function onChange(value) {
233
+ return _this2.onChangeLabel(value, 'right');
234
+ }
235
+ }), showPixelGuides && /*#__PURE__*/_react["default"].createElement("div", {
168
236
  className: classes.sidePixelGuides,
169
237
  style: {
170
- paddingTop: sideGridlinesPadding + chartPadding
238
+ paddingTop: sideGridlinesPadding,
239
+ marginTop: defineChart ? 25 : 31
171
240
  }
172
- }, (0, _toConsumableArray2["default"])(Array(nbOfHorizontalLines + 1 - thisIsChart).keys()).reverse().map(function (value) {
241
+ }, (0, _toConsumableArray2["default"])(Array(nbOfHorizontalLines + 1).keys()).reverse().map(function (value) {
173
242
  return /*#__PURE__*/_react["default"].createElement(_renderUi.Readable, {
174
243
  "false": true,
175
244
  key: "top-guide-".concat(value)
176
245
  }, /*#__PURE__*/_react["default"].createElement("div", {
177
246
  className: classes.sidePixelIndicator
178
247
  }, "\u2501 ", value * 100, "px"));
179
- }))));
248
+ }))), showLabels && /*#__PURE__*/_react["default"].createElement(_label["default"], {
249
+ side: "bottom",
250
+ text: labels.bottom,
251
+ disabledLabel: disabledLabels,
252
+ placeholder: labelsPlaceholders === null || labelsPlaceholders === void 0 ? void 0 : labelsPlaceholders.bottom,
253
+ graphHeight: finalHeight,
254
+ graphWidth: finalWidth,
255
+ isChartBottomLabel: isChart && defineChart,
256
+ onChange: function onChange(value) {
257
+ return _this2.onChangeLabel(value, 'bottom');
258
+ }
259
+ }));
180
260
  }
181
261
  }]);
182
262
  return Root;
@@ -202,12 +282,22 @@ var styles = function styles(theme) {
202
282
  root: {
203
283
  border: "solid 1px ".concat(_renderUi.color.primaryLight()),
204
284
  color: _renderUi.color.text(),
205
- backgroundColor: _renderUi.color.background()
285
+ backgroundColor: _renderUi.color.background(),
286
+ touchAction: 'none',
287
+ position: 'relative'
206
288
  },
207
289
  wrapper: {
208
- display: 'flex'
290
+ display: 'flex',
291
+ position: 'relative'
209
292
  },
210
293
  svg: {},
294
+ defineChart: {
295
+ paddingLeft: '50px',
296
+ overflow: 'visible'
297
+ },
298
+ chart: {
299
+ overflow: 'visible'
300
+ },
211
301
  graphBox: {
212
302
  cursor: 'pointer',
213
303
  userSelect: 'none'
@@ -221,10 +311,12 @@ var styles = function styles(theme) {
221
311
  disabledTitle: {
222
312
  pointerEvents: 'none'
223
313
  },
314
+ rightMargin: {
315
+ marginRight: '74px'
316
+ },
224
317
  topPixelGuides: {
225
318
  display: 'flex',
226
- paddingTop: '6px',
227
- marginLeft: '10px'
319
+ paddingTop: '6px'
228
320
  },
229
321
  topPixelIndicator: {
230
322
  color: _renderUi.color.primaryLight(),
package/lib/root.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/root.jsx"],"names":["Root","g","props","graphProps","onMouseMove","scale","snap","coords","_groups","x","invert","y","snapped","on","mouseMove","bind","disabledTitle","children","classes","onChangeTitle","thisIsChart","showLabels","showPixelGuides","showTitle","title","rootRef","size","width","height","domain","range","chartPadding","padding","extraPadding","finalWidth","finalHeight","activeTitlePlugins","nbOfVerticalLines","parseInt","nbOfHorizontalLines","sideGridlinesPadding","root","topPixelGuides","Array","keys","map","value","topPixelIndicator","graphTitle","noBorder","wrapper","svg","r","graphBox","sidePixelGuides","paddingTop","reverse","sidePixelIndicator","React","Component","PropTypes","string","ChildrenType","bool","GraphPropsType","isRequired","func","object","styles","theme","border","color","primaryLight","text","backgroundColor","background","display","cursor","userSelect","fontSize","typography","textAlign","pointerEvents","marginLeft","flexDirection","alignItems","marginRight","marginBottom"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;IAEaA,I;;;;;;;;;;;;;;;kGAeC,UAAAC,CAAC,EAAI;AACf,wBAAoC,MAAKC,KAAzC;AAAA,UAAQC,UAAR,eAAQA,UAAR;AAAA,UAAoBC,WAApB,eAAoBA,WAApB;;AAEA,UAAI,CAACA,WAAL,EAAkB;AAChB;A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Aa,EAAE,MAJG;AAKlBJ,MAAAA,UAAU,EAAE,MALM;AAOlB,4BAAsB;AACpBS,QAAAA,YAAY,EAAE;AADM;AAPJ;AA5CG,GAAL;AAAA,CAApB;;eAyDe,wBAAWnB,MAAX,EAAmBpE,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';\n\nexport class Root extends React.Component {\n static propTypes = {\n title: PropTypes.string,\n children: ChildrenType,\n disabledTitle: PropTypes.bool,\n graphProps: GraphPropsType.isRequired,\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 };\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 render() {\n const {\n disabledTitle,\n graphProps,\n children,\n classes,\n onChangeTitle,\n thisIsChart,\n showLabels,\n showPixelGuides,\n showTitle,\n title,\n rootRef\n } = this.props;\n const {\n size: { width = 500, height = 500 },\n domain,\n range\n } = graphProps;\n\n const chartPadding = thisIsChart ? 45 : 0;\n const padding = showLabels ? 70 : 40;\n const extraPadding = showLabels ? 16 : 40;\n const finalWidth = width + padding * 2 + (domain.padding || 0) * 2 + extraPadding;\n const finalHeight = height + padding * 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 nbOfVerticalLines = parseInt(width / 100);\n const nbOfHorizontalLines = parseInt(height / 100);\n const sideGridlinesPadding = parseInt(height % 100);\n\n return (\n <div className={classes.root}>\n {showPixelGuides && (\n <div className={classes.topPixelGuides}>\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 <EditableHtml\n className={cn(\n {\n [classes.disabledTitle]: disabledTitle\n },\n classes.graphTitle\n )}\n markup={title || ''}\n width={finalWidth}\n onChange={onChangeTitle}\n placeholder={!disabledTitle && 'Click here to add a title for this graph'}\n toolbarOpts={{ noBorder: true }}\n activePlugins={activeTitlePlugins}\n />\n )}\n <div className={classes.wrapper}>\n <svg width={finalWidth} height={finalHeight} className={classes.svg}>\n <g\n ref={r => {\n this.g = r;\n if (rootRef) {\n rootRef(r);\n }\n }}\n className={classes.graphBox}\n transform={`translate(${padding}, ${padding})`}\n >\n {children}\n </g>\n </svg>\n {showPixelGuides && (\n <div\n className={classes.sidePixelGuides}\n style={{ paddingTop: sideGridlinesPadding + chartPadding }}\n >\n {[...Array(nbOfHorizontalLines + 1 - thisIsChart).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 </div>\n );\n }\n}\nconst styles = theme => ({\n root: {\n border: `solid 1px ${color.primaryLight()}`,\n color: color.text(),\n backgroundColor: color.background()\n },\n wrapper: {\n display: 'flex'\n },\n svg: {},\n graphBox: {\n cursor: 'pointer',\n userSelect: 'none'\n },\n graphTitle: {\n color: color.text(),\n fontSize: theme.typography.fontSize + 2,\n padding: '12px 4px 0',\n textAlign: 'center'\n },\n disabledTitle: {\n pointerEvents: 'none'\n },\n topPixelGuides: {\n display: 'flex',\n paddingTop: '6px',\n marginLeft: '10px'\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\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"}
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","size","width","height","domain","range","topPadding","leftPadding","finalWidth","padding","finalHeight","activeTitlePlugins","actualHeight","nbOfVerticalLines","parseInt","nbOfHorizontalLines","sideGridlinesPadding","root","topPixelGuides","marginLeft","Array","keys","map","value","topPixelIndicator","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","func","object","styles","theme","border","color","primaryLight","text","backgroundColor","background","touchAction","position","display","svg","paddingLeft","overflow","cursor","userSelect","fontSize","typography","textAlign","pointerEvents","marginRight","flexDirection","alignItems","marginBottom"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;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;AAJD,KAxBW;AA8BvBnF,IAAAA,aAAa,EAAE;AACboF,MAAAA,aAAa,EAAE;AADF,KA9BQ;AAiCvB7C,IAAAA,WAAW,EAAE;AACX8C,MAAAA,WAAW,EAAE;AADF,KAjCU;AAoCvBvD,IAAAA,cAAc,EAAE;AACd6C,MAAAA,OAAO,EAAE,MADK;AAEdzB,MAAAA,UAAU,EAAE;AAFE,KApCO;AAwCvBd,IAAAA,iBAAiB,EAAE;AACjBgC,MAAAA,KAAK,EAAEA,gBAAMC,YAAN,EADU;AAEjBM,MAAAA,OAAO,EAAE,MAFQ;AAGjBW,MAAAA,aAAa,EAAE,QAHE;AAIjBC,MAAAA,UAAU,EAAE,QAJK;AAKjBzE,MAAAA,KAAK,EAAE,OALU;AAMjBsE,MAAAA,aAAa,EAAE,MANE;AAOjBJ,MAAAA,UAAU,EAAE;AAPK,KAxCI;AAiDvB/B,IAAAA,eAAe,EAAE;AACfnC,MAAAA,KAAK,EAAE,MADQ;AAEf6D,MAAAA,OAAO,EAAE,MAFM;AAGfW,MAAAA,aAAa,EAAE,QAHA;AAIfD,MAAAA,WAAW,EAAE;AAJE,KAjDM;AAuDvBhC,IAAAA,kBAAkB,EAAE;AAClBe,MAAAA,KAAK,EAAEA,gBAAMC,YAAN,EADW;AAElBc,MAAAA,SAAS,EAAE,OAFO;AAGlBpE,MAAAA,MAAM,EAAE,MAHU;AAIlBqE,MAAAA,aAAa,EAAE,MAJG;AAKlBJ,MAAAA,UAAU,EAAE,MALM;AAOlB,4BAAsB;AACpBQ,QAAAA,YAAY,EAAE;AADM;AAPJ;AAvDG,GAAL;AAAA,CAApB;;eAoEe,wBAAWvB,MAAX,EAAmBtF,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 disabledTitle: PropTypes.bool,\n graphProps: GraphPropsType.isRequired,\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 };\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 } = 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 - 150 : 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\n className={classes.topPixelGuides}\n style={{ marginLeft: isChart ? 60 : showLabels ? 30 : 10 }}\n >\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 className={cn(classes.graphTitle, classes.disabledTitle)}\n dangerouslySetInnerHTML={{ __html: title || '' }}\n />\n ) : (\n <EditableHtml\n className={cn({ [classes.rightMargin]: showPixelGuides }, classes.graphTitle)}\n markup={title || ''}\n onChange={onChangeTitle}\n placeholder={\n (defineChart && titlePlaceholder) ||\n (!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 />\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 onChange={value => this.onChangeLabel(value, 'left')}\n />\n )}\n <svg\n width={finalWidth}\n height={finalHeight}\n className={defineChart ? classes.defineChart : classes.chart}\n >\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 />\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 onChange={value => this.onChangeLabel(value, 'bottom')}\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: '12px 4px 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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "2.4.1",
6
+ "version": "2.5.0",
7
7
  "description": "Some underlying components for building charts/graphs",
8
8
  "keywords": [
9
9
  "react",
@@ -38,6 +38,6 @@
38
38
  "peerDependencies": {
39
39
  "react": "^16.8.1"
40
40
  },
41
- "gitHead": "8d1a2fb82ba23cb20ba1cfca61d76153731b9001",
41
+ "gitHead": "7ad98ca33a39276da5e170339b3bd8bb626dd54b",
42
42
  "scripts": {}
43
43
  }
package/src/label.jsx ADDED
@@ -0,0 +1,122 @@
1
+ import React, { useState } from 'react';
2
+ import { color, Readable } from '@pie-lib/render-ui';
3
+ import cn from 'classnames';
4
+ import EditableHtml from '@pie-lib/editable-html';
5
+ import { withStyles } from '@material-ui/core/styles';
6
+
7
+ const LabelComponent = props => {
8
+ const {
9
+ classes,
10
+ disabledLabel,
11
+ graphHeight,
12
+ graphWidth,
13
+ isChartBottomLabel,
14
+ isChartLeftLabel,
15
+ placeholder,
16
+ text,
17
+ side,
18
+ onChange
19
+ } = props;
20
+ const [rotatedToHorizontal, setRotatedToHorizontal] = useState(false);
21
+ const activePlugins = [
22
+ 'bold',
23
+ 'italic',
24
+ 'underline',
25
+ 'strikethrough',
26
+ 'math'
27
+ // 'languageCharacters'
28
+ ];
29
+
30
+ const chartValue = side === 'left' && isChartLeftLabel && graphHeight - 148;
31
+ const defaultStyle = {
32
+ width: chartValue || (side === 'left' || side === 'right' ? graphHeight - 8 : graphWidth - 8),
33
+ top:
34
+ chartValue ||
35
+ (side === 'left' && `${graphHeight - 8}px`) ||
36
+ (side === 'bottom' && `${graphHeight - 90}px`) ||
37
+ 0,
38
+ left:
39
+ (side === 'right' && `${graphWidth - 8}px`) ||
40
+ ((isChartLeftLabel || isChartBottomLabel) && '50px') ||
41
+ 0
42
+ };
43
+
44
+ const rotatedStyle = {
45
+ width: graphWidth - 8,
46
+ top: (side === 'right' && `${graphHeight - 22}px`) || 0,
47
+ left: 0
48
+ };
49
+
50
+ const rotateLabel = () =>
51
+ !disabledLabel && (side === 'left' || side === 'right') && setRotatedToHorizontal(true);
52
+
53
+ return (
54
+ <Readable false>
55
+ <div
56
+ className={cn(classes.axisLabel, {
57
+ [classes.rotateLeftLabel]: side === 'left' && !rotatedToHorizontal,
58
+ [classes.rotateRightLabel]: side === 'right' && !rotatedToHorizontal,
59
+ [classes.editLabel]: rotatedToHorizontal,
60
+ [classes.customBottom]: isChartBottomLabel
61
+ })}
62
+ style={rotatedToHorizontal ? rotatedStyle : defaultStyle}
63
+ onClick={rotateLabel}
64
+ >
65
+ {disabledLabel ? (
66
+ <div className={classes.disabledLabel} dangerouslySetInnerHTML={{ __html: text || '' }} />
67
+ ) : (
68
+ <EditableHtml
69
+ markup={text || ''}
70
+ onChange={onChange}
71
+ placeholder={!disabledLabel && placeholder}
72
+ toolbarOpts={{
73
+ position: side === 'bottom' ? 'top' : 'bottom',
74
+ noBorder: true
75
+ }}
76
+ disableScrollbar
77
+ activePlugins={activePlugins}
78
+ onDone={() => setRotatedToHorizontal(false)}
79
+ />
80
+ )}
81
+ </div>
82
+ </Readable>
83
+ );
84
+ };
85
+
86
+ export default withStyles(theme => ({
87
+ label: {
88
+ fill: color.secondary()
89
+ },
90
+ axisLabel: {
91
+ fontSize: theme.typography.fontSize - 2,
92
+ textAlign: 'center',
93
+ margin: '4px',
94
+ padding: '4px 0'
95
+ },
96
+ disabledLabel: {
97
+ pointerEvents: 'none',
98
+ width: '100%'
99
+ },
100
+ editLabel: {
101
+ position: 'absolute',
102
+ backgroundColor: 'white',
103
+ borderRadius: '4px',
104
+ boxShadow: '0px 5px 8px rgba(0, 0, 0, 0.15)',
105
+ zIndex: 10
106
+ },
107
+ rotateLeftLabel: {
108
+ rotate: '-90deg',
109
+ transformOrigin: '0 0',
110
+ transformStyle: 'preserve-3d',
111
+ position: 'absolute'
112
+ },
113
+ rotateRightLabel: {
114
+ rotate: '90deg',
115
+ transformOrigin: '0 0',
116
+ transformStyle: 'preserve-3d',
117
+ position: 'absolute'
118
+ },
119
+ customBottom: {
120
+ position: 'absolute'
121
+ }
122
+ }))(LabelComponent);
package/src/root.jsx CHANGED
@@ -7,6 +7,7 @@ import { GraphPropsType } from './types';
7
7
  import { color, Readable } from '@pie-lib/render-ui';
8
8
  import EditableHtml from '@pie-lib/editable-html';
9
9
  import cn from 'classnames';
10
+ import Label from './label';
10
11
 
11
12
  export class Root extends React.Component {
12
13
  static propTypes = {
@@ -53,14 +54,38 @@ export class Root extends React.Component {
53
54
  g.on('mousemove', null);
54
55
  }
55
56
 
57
+ onChangeLabel = (newValue, side) => {
58
+ const { labels, onChangeLabels, isChart } = this.props;
59
+
60
+ if (isChart) {
61
+ if (side === 'left') {
62
+ onChangeLabels('range', newValue);
63
+ } else {
64
+ onChangeLabels('domain', newValue);
65
+ }
66
+
67
+ return;
68
+ }
69
+
70
+ onChangeLabels({
71
+ ...labels,
72
+ [side]: newValue
73
+ });
74
+ };
75
+
56
76
  render() {
57
77
  const {
58
78
  disabledTitle,
79
+ disabledLabels,
80
+ labels,
81
+ labelsPlaceholders,
82
+ titlePlaceholder,
59
83
  graphProps,
60
84
  children,
61
85
  classes,
86
+ defineChart,
62
87
  onChangeTitle,
63
- thisIsChart,
88
+ isChart,
64
89
  showLabels,
65
90
  showPixelGuides,
66
91
  showTitle,
@@ -73,11 +98,10 @@ export class Root extends React.Component {
73
98
  range
74
99
  } = graphProps;
75
100
 
76
- const chartPadding = thisIsChart ? 45 : 0;
77
- const padding = showLabels ? 70 : 40;
78
- const extraPadding = showLabels ? 16 : 40;
79
- const finalWidth = width + padding * 2 + (domain.padding || 0) * 2 + extraPadding;
80
- const finalHeight = height + padding * 2 + (range.padding || 0) * 2;
101
+ const topPadding = 40;
102
+ const leftPadding = showLabels ? 80 : 60;
103
+ const finalWidth = width + leftPadding * 2 + (domain.padding || 0) * 2;
104
+ const finalHeight = height + topPadding * 2 + (range.padding || 0) * 2;
81
105
 
82
106
  const activeTitlePlugins = [
83
107
  'bold',
@@ -88,14 +112,18 @@ export class Root extends React.Component {
88
112
  // 'languageCharacters'
89
113
  ];
90
114
 
115
+ const actualHeight = defineChart && showPixelGuides ? height - 150 : height;
91
116
  const nbOfVerticalLines = parseInt(width / 100);
92
- const nbOfHorizontalLines = parseInt(height / 100);
93
- const sideGridlinesPadding = parseInt(height % 100);
117
+ const nbOfHorizontalLines = parseInt(actualHeight / 100);
118
+ const sideGridlinesPadding = parseInt(actualHeight % 100);
94
119
 
95
120
  return (
96
121
  <div className={classes.root}>
97
122
  {showPixelGuides && (
98
- <div className={classes.topPixelGuides}>
123
+ <div
124
+ className={classes.topPixelGuides}
125
+ style={{ marginLeft: isChart ? 60 : showLabels ? 30 : 10 }}
126
+ >
99
127
  {[...Array(nbOfVerticalLines + 1).keys()].map(value => (
100
128
  <Readable false key={`top-guide-${value}`}>
101
129
  <div className={classes.topPixelIndicator}>
@@ -106,24 +134,55 @@ export class Root extends React.Component {
106
134
  ))}
107
135
  </div>
108
136
  )}
109
- {showTitle && (
110
- <EditableHtml
111
- className={cn(
112
- {
113
- [classes.disabledTitle]: disabledTitle
114
- },
115
- classes.graphTitle
116
- )}
117
- markup={title || ''}
118
- width={finalWidth}
119
- onChange={onChangeTitle}
120
- placeholder={!disabledTitle && 'Click here to add a title for this graph'}
121
- toolbarOpts={{ noBorder: true }}
122
- activePlugins={activeTitlePlugins}
137
+ {showTitle &&
138
+ (disabledTitle ? (
139
+ <div
140
+ className={cn(classes.graphTitle, classes.disabledTitle)}
141
+ dangerouslySetInnerHTML={{ __html: title || '' }}
142
+ />
143
+ ) : (
144
+ <EditableHtml
145
+ className={cn({ [classes.rightMargin]: showPixelGuides }, classes.graphTitle)}
146
+ markup={title || ''}
147
+ onChange={onChangeTitle}
148
+ placeholder={
149
+ (defineChart && titlePlaceholder) ||
150
+ (!disabledTitle && 'Click here to add a title for this graph')
151
+ }
152
+ toolbarOpts={{ noBorder: true }}
153
+ activePlugins={activeTitlePlugins}
154
+ disableScrollbar
155
+ />
156
+ ))}
157
+ {showLabels && !isChart && (
158
+ <Label
159
+ side="top"
160
+ text={labels.top}
161
+ disabledLabel={disabledLabels}
162
+ placeholder={labelsPlaceholders?.top}
163
+ graphHeight={finalHeight}
164
+ graphWidth={finalWidth}
165
+ onChange={value => this.onChangeLabel(value, 'top')}
123
166
  />
124
167
  )}
125
168
  <div className={classes.wrapper}>
126
- <svg width={finalWidth} height={finalHeight} className={classes.svg}>
169
+ {showLabels && (
170
+ <Label
171
+ side="left"
172
+ text={labels.left}
173
+ disabledLabel={disabledLabels}
174
+ placeholder={labelsPlaceholders?.left}
175
+ graphHeight={finalHeight}
176
+ graphWidth={finalWidth}
177
+ isChartLeftLabel={isChart && defineChart}
178
+ onChange={value => this.onChangeLabel(value, 'left')}
179
+ />
180
+ )}
181
+ <svg
182
+ width={finalWidth}
183
+ height={finalHeight}
184
+ className={defineChart ? classes.defineChart : classes.chart}
185
+ >
127
186
  <g
128
187
  ref={r => {
129
188
  this.g = r;
@@ -132,17 +191,31 @@ export class Root extends React.Component {
132
191
  }
133
192
  }}
134
193
  className={classes.graphBox}
135
- transform={`translate(${padding}, ${padding})`}
194
+ transform={`translate(${leftPadding}, ${topPadding})`}
136
195
  >
137
196
  {children}
138
197
  </g>
139
198
  </svg>
199
+ {showLabels && !isChart && (
200
+ <Label
201
+ side="right"
202
+ text={labels.right}
203
+ disabledLabel={disabledLabels}
204
+ placeholder={labelsPlaceholders?.right}
205
+ graphHeight={finalHeight}
206
+ graphWidth={finalWidth}
207
+ onChange={value => this.onChangeLabel(value, 'right')}
208
+ />
209
+ )}
140
210
  {showPixelGuides && (
141
211
  <div
142
212
  className={classes.sidePixelGuides}
143
- style={{ paddingTop: sideGridlinesPadding + chartPadding }}
213
+ style={{
214
+ paddingTop: sideGridlinesPadding,
215
+ marginTop: defineChart ? 25 : 31
216
+ }}
144
217
  >
145
- {[...Array(nbOfHorizontalLines + 1 - thisIsChart).keys()].reverse().map(value => (
218
+ {[...Array(nbOfHorizontalLines + 1).keys()].reverse().map(value => (
146
219
  <Readable false key={`top-guide-${value}`}>
147
220
  <div className={classes.sidePixelIndicator}>━ {value * 100}px</div>
148
221
  </Readable>
@@ -150,20 +223,43 @@ export class Root extends React.Component {
150
223
  </div>
151
224
  )}
152
225
  </div>
226
+ {showLabels && (
227
+ <Label
228
+ side="bottom"
229
+ text={labels.bottom}
230
+ disabledLabel={disabledLabels}
231
+ placeholder={labelsPlaceholders?.bottom}
232
+ graphHeight={finalHeight}
233
+ graphWidth={finalWidth}
234
+ isChartBottomLabel={isChart && defineChart}
235
+ onChange={value => this.onChangeLabel(value, 'bottom')}
236
+ />
237
+ )}
153
238
  </div>
154
239
  );
155
240
  }
156
241
  }
242
+
157
243
  const styles = theme => ({
158
244
  root: {
159
245
  border: `solid 1px ${color.primaryLight()}`,
160
246
  color: color.text(),
161
- backgroundColor: color.background()
247
+ backgroundColor: color.background(),
248
+ touchAction: 'none',
249
+ position: 'relative'
162
250
  },
163
251
  wrapper: {
164
- display: 'flex'
252
+ display: 'flex',
253
+ position: 'relative'
165
254
  },
166
255
  svg: {},
256
+ defineChart: {
257
+ paddingLeft: '50px',
258
+ overflow: 'visible'
259
+ },
260
+ chart: {
261
+ overflow: 'visible'
262
+ },
167
263
  graphBox: {
168
264
  cursor: 'pointer',
169
265
  userSelect: 'none'
@@ -177,10 +273,12 @@ const styles = theme => ({
177
273
  disabledTitle: {
178
274
  pointerEvents: 'none'
179
275
  },
276
+ rightMargin: {
277
+ marginRight: '74px'
278
+ },
180
279
  topPixelGuides: {
181
280
  display: 'flex',
182
- paddingTop: '6px',
183
- marginLeft: '10px'
281
+ paddingTop: '6px'
184
282
  },
185
283
  topPixelIndicator: {
186
284
  color: color.primaryLight(),
@@ -195,7 +293,6 @@ const styles = theme => ({
195
293
  width: '70px',
196
294
  display: 'flex',
197
295
  flexDirection: 'column',
198
-
199
296
  marginRight: '6px'
200
297
  },
201
298
  sidePixelIndicator: {