@pie-lib/plot 2.4.2 → 2.5.1

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,41 @@
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.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.5.0...@pie-lib/plot@2.5.1) (2022-09-29)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **charting:** center Chart Title ([2b7e39f](https://github.com/pie-framework/pie-lib/commit/2b7e39f2aa39e0db0a003f154abdfa4852f3b141))
12
+ * **charting:** fix left label position for define correct response and player chart ([4a50663](https://github.com/pie-framework/pie-lib/commit/4a5066351901cbe400180b1d19d9a54781eb726e))
13
+ * **charting:** make space for delete category buttons in define correct response and in player ([7c0f653](https://github.com/pie-framework/pie-lib/commit/7c0f6536f106099da9a9ab5a7328fed827841c5c))
14
+
15
+
16
+
17
+
18
+
19
+ # [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)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * **charting:** arrange the position of the checkboxes labels, fix style amd arrangement ([c5f2f7a](https://github.com/pie-framework/pie-lib/commit/c5f2f7acf60898e77ecc0b47b190256537605c8e))
25
+ * **charting:** change position for checbox labels in order to fit without overlapping the checboxes ([98a56cb](https://github.com/pie-framework/pie-lib/commit/98a56cbae47c4bcadd0d4087d6b7df3c4d5d3e2e))
26
+ * **charting:** fix conflicts ([2b3da1b](https://github.com/pie-framework/pie-lib/commit/2b3da1b4b87a518b5c18daf6f6c57db1ccc1c536))
27
+ * **charting:** prevent page scroll on devices when a charting category is dragged ([6fe37ff](https://github.com/pie-framework/pie-lib/commit/6fe37ffa0e2c387d7174d0daf5cfc1cf9e8abf80))
28
+ * **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))
29
+
30
+
31
+ ### Features
32
+
33
+ * **charting:** refactor ability to edit chart title and labels, fix style ([6edcdfb](https://github.com/pie-framework/pie-lib/commit/6edcdfbfbd83806a8487c29c42ae447b11850ac7))
34
+ * **charting:** try to set up labels for charting, work in progress ([c6cd049](https://github.com/pie-framework/pie-lib/commit/c6cd049723dadab329748511da2f6c4f1fa943db))
35
+ * **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))
36
+
37
+
38
+
39
+
40
+
6
41
  ## [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)
7
42
 
8
43
 
package/lib/label.js ADDED
@@ -0,0 +1,137 @@
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
+ isDefineChartBottomLabel = props.isDefineChartBottomLabel,
39
+ isChartLeftLabel = props.isChartLeftLabel,
40
+ isDefineChartLeftLabel = props.isDefineChartLeftLabel,
41
+ placeholder = props.placeholder,
42
+ text = props.text,
43
+ side = props.side,
44
+ onChange = props.onChange;
45
+
46
+ var _useState = (0, _react.useState)(false),
47
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
48
+ rotatedToHorizontal = _useState2[0],
49
+ setRotatedToHorizontal = _useState2[1];
50
+
51
+ var activePlugins = ['bold', 'italic', 'underline', 'strikethrough', 'math' // 'languageCharacters'
52
+ ];
53
+ var chartValue = side === 'left' && isDefineChartLeftLabel && graphHeight - 220;
54
+ var defaultStyle = {
55
+ width: chartValue || (side === 'left' || side === 'right' ? graphHeight - 8 : graphWidth - 8),
56
+ top: chartValue || isChartLeftLabel && "".concat(graphHeight - 70, "px") || side === 'left' && "".concat(graphHeight - 8, "px") || isChartBottomLabel && "".concat(graphHeight - 40, "px") || side === 'bottom' && "".concat(graphHeight - 90, "px") || 0,
57
+ left: side === 'right' && "".concat(graphWidth - 8, "px") || (isDefineChartLeftLabel || isDefineChartBottomLabel) && '40px' || isChartBottomLabel && '-10px' || 0
58
+ };
59
+ var rotatedStyle = {
60
+ width: graphWidth - 8,
61
+ top: side === 'right' && "".concat(graphHeight - 22, "px") || 0,
62
+ left: 0
63
+ };
64
+
65
+ var rotateLabel = function rotateLabel() {
66
+ return !disabledLabel && (side === 'left' || side === 'right') && setRotatedToHorizontal(true);
67
+ };
68
+
69
+ return /*#__PURE__*/_react["default"].createElement(_renderUi.Readable, {
70
+ "false": true
71
+ }, /*#__PURE__*/_react["default"].createElement("div", {
72
+ 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 || isDefineChartBottomLabel), _cn)),
73
+ style: rotatedToHorizontal ? rotatedStyle : defaultStyle,
74
+ onClick: rotateLabel
75
+ }, disabledLabel ? /*#__PURE__*/_react["default"].createElement("div", {
76
+ className: classes.disabledLabel,
77
+ dangerouslySetInnerHTML: {
78
+ __html: text || ''
79
+ }
80
+ }) : /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
81
+ markup: text || '',
82
+ onChange: onChange,
83
+ placeholder: !disabledLabel && placeholder,
84
+ toolbarOpts: {
85
+ position: side === 'bottom' ? 'top' : 'bottom',
86
+ noBorder: true
87
+ },
88
+ disableScrollbar: true,
89
+ activePlugins: activePlugins,
90
+ onDone: function onDone() {
91
+ return setRotatedToHorizontal(false);
92
+ }
93
+ })));
94
+ };
95
+
96
+ var _default = (0, _styles.withStyles)(function (theme) {
97
+ return {
98
+ label: {
99
+ fill: _renderUi.color.secondary()
100
+ },
101
+ axisLabel: {
102
+ fontSize: theme.typography.fontSize - 2,
103
+ textAlign: 'center',
104
+ margin: '4px',
105
+ padding: '4px 0'
106
+ },
107
+ disabledLabel: {
108
+ pointerEvents: 'none',
109
+ width: '100%'
110
+ },
111
+ editLabel: {
112
+ position: 'absolute',
113
+ backgroundColor: 'white',
114
+ borderRadius: '4px',
115
+ boxShadow: '0px 5px 8px rgba(0, 0, 0, 0.15)',
116
+ zIndex: 10
117
+ },
118
+ rotateLeftLabel: {
119
+ rotate: '-90deg',
120
+ transformOrigin: '0 0',
121
+ transformStyle: 'preserve-3d',
122
+ position: 'absolute'
123
+ },
124
+ rotateRightLabel: {
125
+ rotate: '90deg',
126
+ transformOrigin: '0 0',
127
+ transformStyle: 'preserve-3d',
128
+ position: 'absolute'
129
+ },
130
+ customBottom: {
131
+ position: 'absolute'
132
+ }
133
+ };
134
+ })(LabelComponent);
135
+
136
+ exports["default"] = _default;
137
+ //# sourceMappingURL=label.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/label.jsx"],"names":["LabelComponent","props","classes","disabledLabel","graphHeight","graphWidth","isChartBottomLabel","isDefineChartBottomLabel","isChartLeftLabel","isDefineChartLeftLabel","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,IAAMA,cAAc,GAAG,SAAjBA,cAAiB,CAAAC,KAAK,EAAI;AAAA;;AAC9B,MACEC,OADF,GAaID,KAbJ,CACEC,OADF;AAAA,MAEEC,aAFF,GAaIF,KAbJ,CAEEE,aAFF;AAAA,MAGEC,WAHF,GAaIH,KAbJ,CAGEG,WAHF;AAAA,MAIEC,UAJF,GAaIJ,KAbJ,CAIEI,UAJF;AAAA,MAKEC,kBALF,GAaIL,KAbJ,CAKEK,kBALF;AAAA,MAMEC,wBANF,GAaIN,KAbJ,CAMEM,wBANF;AAAA,MAOEC,gBAPF,GAaIP,KAbJ,CAOEO,gBAPF;AAAA,MAQEC,sBARF,GAaIR,KAbJ,CAQEQ,sBARF;AAAA,MASEC,WATF,GAaIT,KAbJ,CASES,WATF;AAAA,MAUEC,IAVF,GAaIV,KAbJ,CAUEU,IAVF;AAAA,MAWEC,IAXF,GAaIX,KAbJ,CAWEW,IAXF;AAAA,MAYEC,QAZF,GAaIZ,KAbJ,CAYEY,QAZF;;AAcA,kBAAsD,qBAAS,KAAT,CAAtD;AAAA;AAAA,MAAOC,mBAAP;AAAA,MAA4BC,sBAA5B;;AACA,MAAMC,aAAa,GAAG,CACpB,MADoB,EAEpB,QAFoB,EAGpB,WAHoB,EAIpB,eAJoB,EAKpB,MALoB,CAMpB;AANoB,GAAtB;AASA,MAAMC,UAAU,GAAGL,IAAI,KAAK,MAAT,IAAmBH,sBAAnB,IAA6CL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AAE;AAFM,KAVmB;AAclCQ,IAAAA,SAAS,EAAE;AACTG,MAAAA,QAAQ,EAAE,UADD;AAETa,MAAAA,eAAe,EAAE,OAFR;AAGTC,MAAAA,YAAY,EAAE,KAHL;AAITC,MAAAA,SAAS,EAAE,iCAJF;AAKTC,MAAAA,MAAM,EAAE;AALC,KAduB;AAqBlCrB,IAAAA,eAAe,EAAE;AACfsB,MAAAA,MAAM,EAAE,QADO;AAEfC,MAAAA,eAAe,EAAE,KAFF;AAGfC,MAAAA,cAAc,EAAE,aAHD;AAIfnB,MAAAA,QAAQ,EAAE;AAJK,KArBiB;AA2BlCJ,IAAAA,gBAAgB,EAAE;AAChBqB,MAAAA,MAAM,EAAE,OADQ;AAEhBC,MAAAA,eAAe,EAAE,KAFD;AAGhBC,MAAAA,cAAc,EAAE,aAHA;AAIhBnB,MAAAA,QAAQ,EAAE;AAJM,KA3BgB;AAiClCF,IAAAA,YAAY,EAAE;AACZE,MAAAA,QAAQ,EAAE;AADE;AAjCoB,GAAL;AAAA,CAAhB,EAoCX9B,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 isDefineChartBottomLabel,\n isChartLeftLabel,\n isDefineChartLeftLabel,\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' && isDefineChartLeftLabel && graphHeight - 220;\n const defaultStyle = {\n width: chartValue || (side === 'left' || side === 'right' ? graphHeight - 8 : graphWidth - 8),\n top:\n chartValue ||\n (isChartLeftLabel && `${graphHeight - 70}px`) ||\n (side === 'left' && `${graphHeight - 8}px`) ||\n (isChartBottomLabel && `${graphHeight - 40}px`) ||\n (side === 'bottom' && `${graphHeight - 90}px`) ||\n 0,\n left:\n (side === 'right' && `${graphWidth - 8}px`) ||\n ((isDefineChartLeftLabel || isDefineChartBottomLabel) && '40px') ||\n (isChartBottomLabel && '-10px') ||\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 || isDefineChartBottomLabel\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,13 +146,13 @@ 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 padding = showLabels ? 70 : 40;
121
- var extraPadding = showLabels ? 16 : 40;
122
- var finalWidth = width + padding * 2 + (domain.padding || 0) * 2 + extraPadding;
123
- 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;
124
153
  var activeTitlePlugins = ['bold', 'italic', 'underline', 'strikethrough', 'math' // 'languageCharacters'
125
154
  ];
126
- var actualHeight = thisIsChart && showPixelGuides ? height - 80 : height;
155
+ var actualHeight = defineChart && showPixelGuides ? height - 160 : height;
127
156
  var nbOfVerticalLines = parseInt(width / 100);
128
157
  var nbOfHorizontalLines = parseInt(actualHeight / 100);
129
158
  var sideGridlinesPadding = parseInt(actualHeight % 100);
@@ -132,7 +161,7 @@ var Root = /*#__PURE__*/function (_React$Component) {
132
161
  }, showPixelGuides && /*#__PURE__*/_react["default"].createElement("div", {
133
162
  className: classes.topPixelGuides,
134
163
  style: {
135
- marginLeft: thisIsChart ? 10 : 20
164
+ marginLeft: isChart ? 60 : showLabels ? 30 : 10
136
165
  }
137
166
  }, (0, _toConsumableArray2["default"])(Array(nbOfVerticalLines + 1).keys()).map(function (value) {
138
167
  return /*#__PURE__*/_react["default"].createElement(_renderUi.Readable, {
@@ -141,22 +170,55 @@ var Root = /*#__PURE__*/function (_React$Component) {
141
170
  }, /*#__PURE__*/_react["default"].createElement("div", {
142
171
  className: classes.topPixelIndicator
143
172
  }, /*#__PURE__*/_react["default"].createElement("div", null, value * 100, "px"), /*#__PURE__*/_react["default"].createElement("div", null, "|")));
144
- })), showTitle && /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
145
- className: (0, _classnames["default"])((0, _defineProperty2["default"])({}, classes.disabledTitle, disabledTitle), classes.graphTitle),
173
+ })), showTitle && (disabledTitle ? /*#__PURE__*/_react["default"].createElement("div", {
174
+ style: isChart && {
175
+ width: finalWidth
176
+ },
177
+ className: (0, _classnames["default"])(classes.graphTitle, classes.disabledTitle),
178
+ dangerouslySetInnerHTML: {
179
+ __html: title || ''
180
+ }
181
+ }) : /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
182
+ style: isChart && {
183
+ width: finalWidth
184
+ },
185
+ className: (0, _classnames["default"])((0, _defineProperty2["default"])({}, classes.rightMargin, showPixelGuides), classes.graphTitle),
146
186
  markup: title || '',
147
- width: finalWidth,
148
187
  onChange: onChangeTitle,
149
- placeholder: !disabledTitle && 'Click here to add a title for this graph',
188
+ placeholder: defineChart && titlePlaceholder || !disabledTitle && 'Click here to add a title for this graph',
150
189
  toolbarOpts: {
151
190
  noBorder: true
152
191
  },
153
- activePlugins: activeTitlePlugins
192
+ activePlugins: activeTitlePlugins,
193
+ disableScrollbar: true
194
+ })), showLabels && !isChart && /*#__PURE__*/_react["default"].createElement(_label["default"], {
195
+ side: "top",
196
+ text: labels.top,
197
+ disabledLabel: disabledLabels,
198
+ placeholder: labelsPlaceholders === null || labelsPlaceholders === void 0 ? void 0 : labelsPlaceholders.top,
199
+ graphHeight: finalHeight,
200
+ graphWidth: finalWidth,
201
+ onChange: function onChange(value) {
202
+ return _this2.onChangeLabel(value, 'top');
203
+ }
154
204
  }), /*#__PURE__*/_react["default"].createElement("div", {
155
205
  className: classes.wrapper
156
- }, /*#__PURE__*/_react["default"].createElement("svg", {
206
+ }, showLabels && /*#__PURE__*/_react["default"].createElement(_label["default"], {
207
+ side: "left",
208
+ text: labels.left,
209
+ disabledLabel: disabledLabels,
210
+ placeholder: labelsPlaceholders === null || labelsPlaceholders === void 0 ? void 0 : labelsPlaceholders.left,
211
+ graphHeight: finalHeight,
212
+ graphWidth: finalWidth,
213
+ isChartLeftLabel: isChart && !defineChart,
214
+ isDefineChartLeftLabel: isChart && defineChart,
215
+ onChange: function onChange(value) {
216
+ return _this2.onChangeLabel(value, 'left');
217
+ }
218
+ }), /*#__PURE__*/_react["default"].createElement("svg", {
157
219
  width: finalWidth,
158
220
  height: finalHeight,
159
- className: classes.svg
221
+ className: defineChart ? classes.defineChart : classes.chart
160
222
  }, /*#__PURE__*/_react["default"].createElement("g", {
161
223
  ref: function ref(r) {
162
224
  _this2.g = r;
@@ -166,12 +228,22 @@ var Root = /*#__PURE__*/function (_React$Component) {
166
228
  }
167
229
  },
168
230
  className: classes.graphBox,
169
- transform: "translate(".concat(padding, ", ").concat(padding, ")")
170
- }, children)), showPixelGuides && /*#__PURE__*/_react["default"].createElement("div", {
231
+ transform: "translate(".concat(leftPadding, ", ").concat(topPadding, ")")
232
+ }, children)), showLabels && !isChart && /*#__PURE__*/_react["default"].createElement(_label["default"], {
233
+ side: "right",
234
+ text: labels.right,
235
+ disabledLabel: disabledLabels,
236
+ placeholder: labelsPlaceholders === null || labelsPlaceholders === void 0 ? void 0 : labelsPlaceholders.right,
237
+ graphHeight: finalHeight,
238
+ graphWidth: finalWidth,
239
+ onChange: function onChange(value) {
240
+ return _this2.onChangeLabel(value, 'right');
241
+ }
242
+ }), showPixelGuides && /*#__PURE__*/_react["default"].createElement("div", {
171
243
  className: classes.sidePixelGuides,
172
244
  style: {
173
245
  paddingTop: sideGridlinesPadding,
174
- marginTop: thisIsChart ? 25 : 60
246
+ marginTop: defineChart ? 25 : 31
175
247
  }
176
248
  }, (0, _toConsumableArray2["default"])(Array(nbOfHorizontalLines + 1).keys()).reverse().map(function (value) {
177
249
  return /*#__PURE__*/_react["default"].createElement(_renderUi.Readable, {
@@ -180,7 +252,19 @@ var Root = /*#__PURE__*/function (_React$Component) {
180
252
  }, /*#__PURE__*/_react["default"].createElement("div", {
181
253
  className: classes.sidePixelIndicator
182
254
  }, "\u2501 ", value * 100, "px"));
183
- }))));
255
+ }))), showLabels && /*#__PURE__*/_react["default"].createElement(_label["default"], {
256
+ side: "bottom",
257
+ text: labels.bottom,
258
+ disabledLabel: disabledLabels,
259
+ placeholder: labelsPlaceholders === null || labelsPlaceholders === void 0 ? void 0 : labelsPlaceholders.bottom,
260
+ graphHeight: finalHeight,
261
+ graphWidth: finalWidth,
262
+ isChartBottomLabel: isChart && !defineChart,
263
+ isDefineChartBottomLabel: isChart && defineChart,
264
+ onChange: function onChange(value) {
265
+ return _this2.onChangeLabel(value, 'bottom');
266
+ }
267
+ }));
184
268
  }
185
269
  }]);
186
270
  return Root;
@@ -206,12 +290,22 @@ var styles = function styles(theme) {
206
290
  root: {
207
291
  border: "solid 1px ".concat(_renderUi.color.primaryLight()),
208
292
  color: _renderUi.color.text(),
209
- backgroundColor: _renderUi.color.background()
293
+ backgroundColor: _renderUi.color.background(),
294
+ touchAction: 'none',
295
+ position: 'relative'
210
296
  },
211
297
  wrapper: {
212
- display: 'flex'
298
+ display: 'flex',
299
+ position: 'relative'
213
300
  },
214
301
  svg: {},
302
+ defineChart: {
303
+ paddingLeft: '50px',
304
+ overflow: 'visible'
305
+ },
306
+ chart: {
307
+ overflow: 'visible'
308
+ },
215
309
  graphBox: {
216
310
  cursor: 'pointer',
217
311
  userSelect: 'none'
@@ -225,6 +319,9 @@ var styles = function styles(theme) {
225
319
  disabledTitle: {
226
320
  pointerEvents: 'none'
227
321
  },
322
+ rightMargin: {
323
+ marginRight: '74px'
324
+ },
228
325
  topPixelGuides: {
229
326
  display: 'flex',
230
327
  paddingTop: '6px'
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","padding","extraPadding","finalWidth","finalHeight","activeTitlePlugins","actualHeight","nbOfVerticalLines","parseInt","nbOfHorizontalLines","sideGridlinesPadding","root","topPixelGuides","marginLeft","Array","keys","map","value","topPixelIndicator","graphTitle","noBorder","wrapper","svg","r","graphBox","sidePixelGuides","paddingTop","marginTop","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","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;AACD;;AAED,UAAQC,KAAR,GAAwBF,UAAxB,CAAQE,KAAR;AAAA,UAAeC,IAAf,GAAwBH,UAAxB,CAAeG,IAAf;AACA,UAAMC,MAAM,GAAG,wBAAMN,CAAC,CAACO,OAAF,CAAU,CAAV,EAAa,CAAb,CAAN,CAAf;AACA,UAAMC,CAAC,GAAGJ,KAAK,CAACI,CAAN,CAAQC,MAAR,CAAeH,MAAM,CAAC,CAAD,CAArB,CAAV;AACA,UAAMI,CAAC,GAAGN,KAAK,CAACM,CAAN,CAAQD,MAAR,CAAeH,MAAM,CAAC,CAAD,CAArB,CAAV;AAEA,UAAMK,OAAO,GAAG;AACdH,QAAAA,CAAC,EAAEH,IAAI,CAACG,CAAL,CAAOA,CAAP,CADW;AAEdE,QAAAA,CAAC,EAAEL,IAAI,CAACK,CAAL,CAAOA,CAAP;AAFW,OAAhB;AA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AS,EAAE;AAJD,KAdW;AAoBvBnE,IAAAA,aAAa,EAAE;AACboE,MAAAA,aAAa,EAAE;AADF,KApBQ;AAuBvB1C,IAAAA,cAAc,EAAE;AACdoC,MAAAA,OAAO,EAAE,MADK;AAEdtB,MAAAA,UAAU,EAAE;AAFE,KAvBO;AA2BvBR,IAAAA,iBAAiB,EAAE;AACjByB,MAAAA,KAAK,EAAEA,gBAAMC,YAAN,EADU;AAEjBI,MAAAA,OAAO,EAAE,MAFQ;AAGjBO,MAAAA,aAAa,EAAE,QAHE;AAIjBC,MAAAA,UAAU,EAAE,QAJK;AAKjB3D,MAAAA,KAAK,EAAE,OALU;AAMjByD,MAAAA,aAAa,EAAE,MANE;AAOjBJ,MAAAA,UAAU,EAAE;AAPK,KA3BI;AAoCvBzB,IAAAA,eAAe,EAAE;AACf5B,MAAAA,KAAK,EAAE,MADQ;AAEfmD,MAAAA,OAAO,EAAE,MAFM;AAGfO,MAAAA,aAAa,EAAE,QAHA;AAIfE,MAAAA,WAAW,EAAE;AAJE,KApCM;AA0CvB5B,IAAAA,kBAAkB,EAAE;AAClBc,MAAAA,KAAK,EAAEA,gBAAMC,YAAN,EADW;AAElBS,MAAAA,SAAS,EAAE,OAFO;AAGlBvD,MAAAA,MAAM,EAAE,MAHU;AAIlBwD,MAAAA,aAAa,EAAE,MAJG;AAKlBJ,MAAAA,UAAU,EAAE,MALM;AAOlB,4BAAsB;AACpBQ,QAAAA,YAAY,EAAE;AADM;AAPJ;AA1CG,GAAL;AAAA,CAApB;;eAuDe,wBAAWlB,MAAX,EAAmBtE,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 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 actualHeight = thisIsChart && showPixelGuides ? height - 80 : 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: thisIsChart ? 10 : 20 }}>\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={{\n paddingTop: sideGridlinesPadding,\n marginTop: thisIsChart ? 25 : 60\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 </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 },\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"}
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;;;;;;;;;;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;AACD;;AAED,UAAQC,KAAR,GAAwBF,UAAxB,CAAQE,KAAR;AAAA,UAAeC,IAAf,GAAwBH,UAAxB,CAAeG,IAAf;AACA,UAAMC,MAAM,GAAG,wBAAMN,CAAC,CAACO,OAAF,CAAU,CAAV,EAAa,CAAb,C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C,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 - 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\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 style={\n isChart && {\n width: finalWidth\n }\n }\n className={cn(classes.graphTitle, classes.disabledTitle)}\n dangerouslySetInnerHTML={{ __html: title || '' }}\n />\n ) : (\n <EditableHtml\n style={\n isChart && {\n width: finalWidth\n }\n }\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 isDefineChartLeftLabel={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 isDefineChartBottomLabel={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.2",
6
+ "version": "2.5.1",
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": "0963c3d69d1b57497c4366de26056ca82a3a7aa2",
41
+ "gitHead": "a847c8ebb4b4d6df9b7c011d2275c38910bf4ea1",
42
42
  "scripts": {}
43
43
  }
package/src/label.jsx ADDED
@@ -0,0 +1,127 @@
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
+ isDefineChartBottomLabel,
15
+ isChartLeftLabel,
16
+ isDefineChartLeftLabel,
17
+ placeholder,
18
+ text,
19
+ side,
20
+ onChange
21
+ } = props;
22
+ const [rotatedToHorizontal, setRotatedToHorizontal] = useState(false);
23
+ const activePlugins = [
24
+ 'bold',
25
+ 'italic',
26
+ 'underline',
27
+ 'strikethrough',
28
+ 'math'
29
+ // 'languageCharacters'
30
+ ];
31
+
32
+ const chartValue = side === 'left' && isDefineChartLeftLabel && graphHeight - 220;
33
+ const defaultStyle = {
34
+ width: chartValue || (side === 'left' || side === 'right' ? graphHeight - 8 : graphWidth - 8),
35
+ top:
36
+ chartValue ||
37
+ (isChartLeftLabel && `${graphHeight - 70}px`) ||
38
+ (side === 'left' && `${graphHeight - 8}px`) ||
39
+ (isChartBottomLabel && `${graphHeight - 40}px`) ||
40
+ (side === 'bottom' && `${graphHeight - 90}px`) ||
41
+ 0,
42
+ left:
43
+ (side === 'right' && `${graphWidth - 8}px`) ||
44
+ ((isDefineChartLeftLabel || isDefineChartBottomLabel) && '40px') ||
45
+ (isChartBottomLabel && '-10px') ||
46
+ 0
47
+ };
48
+
49
+ const rotatedStyle = {
50
+ width: graphWidth - 8,
51
+ top: (side === 'right' && `${graphHeight - 22}px`) || 0,
52
+ left: 0
53
+ };
54
+
55
+ const rotateLabel = () =>
56
+ !disabledLabel && (side === 'left' || side === 'right') && setRotatedToHorizontal(true);
57
+
58
+ return (
59
+ <Readable false>
60
+ <div
61
+ className={cn(classes.axisLabel, {
62
+ [classes.rotateLeftLabel]: side === 'left' && !rotatedToHorizontal,
63
+ [classes.rotateRightLabel]: side === 'right' && !rotatedToHorizontal,
64
+ [classes.editLabel]: rotatedToHorizontal,
65
+ [classes.customBottom]: isChartBottomLabel || isDefineChartBottomLabel
66
+ })}
67
+ style={rotatedToHorizontal ? rotatedStyle : defaultStyle}
68
+ onClick={rotateLabel}
69
+ >
70
+ {disabledLabel ? (
71
+ <div className={classes.disabledLabel} dangerouslySetInnerHTML={{ __html: text || '' }} />
72
+ ) : (
73
+ <EditableHtml
74
+ markup={text || ''}
75
+ onChange={onChange}
76
+ placeholder={!disabledLabel && placeholder}
77
+ toolbarOpts={{
78
+ position: side === 'bottom' ? 'top' : 'bottom',
79
+ noBorder: true
80
+ }}
81
+ disableScrollbar
82
+ activePlugins={activePlugins}
83
+ onDone={() => setRotatedToHorizontal(false)}
84
+ />
85
+ )}
86
+ </div>
87
+ </Readable>
88
+ );
89
+ };
90
+
91
+ export default withStyles(theme => ({
92
+ label: {
93
+ fill: color.secondary()
94
+ },
95
+ axisLabel: {
96
+ fontSize: theme.typography.fontSize - 2,
97
+ textAlign: 'center',
98
+ margin: '4px',
99
+ padding: '4px 0'
100
+ },
101
+ disabledLabel: {
102
+ pointerEvents: 'none',
103
+ width: '100%'
104
+ },
105
+ editLabel: {
106
+ position: 'absolute',
107
+ backgroundColor: 'white',
108
+ borderRadius: '4px',
109
+ boxShadow: '0px 5px 8px rgba(0, 0, 0, 0.15)',
110
+ zIndex: 10
111
+ },
112
+ rotateLeftLabel: {
113
+ rotate: '-90deg',
114
+ transformOrigin: '0 0',
115
+ transformStyle: 'preserve-3d',
116
+ position: 'absolute'
117
+ },
118
+ rotateRightLabel: {
119
+ rotate: '90deg',
120
+ transformOrigin: '0 0',
121
+ transformStyle: 'preserve-3d',
122
+ position: 'absolute'
123
+ },
124
+ customBottom: {
125
+ position: 'absolute'
126
+ }
127
+ }))(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,10 +98,10 @@ export class Root extends React.Component {
73
98
  range
74
99
  } = graphProps;
75
100
 
76
- const padding = showLabels ? 70 : 40;
77
- const extraPadding = showLabels ? 16 : 40;
78
- const finalWidth = width + padding * 2 + (domain.padding || 0) * 2 + extraPadding;
79
- 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;
80
105
 
81
106
  const activeTitlePlugins = [
82
107
  'bold',
@@ -87,7 +112,7 @@ export class Root extends React.Component {
87
112
  // 'languageCharacters'
88
113
  ];
89
114
 
90
- const actualHeight = thisIsChart && showPixelGuides ? height - 80 : height;
115
+ const actualHeight = defineChart && showPixelGuides ? height - 160 : height;
91
116
  const nbOfVerticalLines = parseInt(width / 100);
92
117
  const nbOfHorizontalLines = parseInt(actualHeight / 100);
93
118
  const sideGridlinesPadding = parseInt(actualHeight % 100);
@@ -95,7 +120,10 @@ export class Root extends React.Component {
95
120
  return (
96
121
  <div className={classes.root}>
97
122
  {showPixelGuides && (
98
- <div className={classes.topPixelGuides} style={{ marginLeft: thisIsChart ? 10 : 20 }}>
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,66 @@ 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
+ style={
141
+ isChart && {
142
+ width: finalWidth
143
+ }
144
+ }
145
+ className={cn(classes.graphTitle, classes.disabledTitle)}
146
+ dangerouslySetInnerHTML={{ __html: title || '' }}
147
+ />
148
+ ) : (
149
+ <EditableHtml
150
+ style={
151
+ isChart && {
152
+ width: finalWidth
153
+ }
154
+ }
155
+ className={cn({ [classes.rightMargin]: showPixelGuides }, classes.graphTitle)}
156
+ markup={title || ''}
157
+ onChange={onChangeTitle}
158
+ placeholder={
159
+ (defineChart && titlePlaceholder) ||
160
+ (!disabledTitle && 'Click here to add a title for this graph')
161
+ }
162
+ toolbarOpts={{ noBorder: true }}
163
+ activePlugins={activeTitlePlugins}
164
+ disableScrollbar
165
+ />
166
+ ))}
167
+ {showLabels && !isChart && (
168
+ <Label
169
+ side="top"
170
+ text={labels.top}
171
+ disabledLabel={disabledLabels}
172
+ placeholder={labelsPlaceholders?.top}
173
+ graphHeight={finalHeight}
174
+ graphWidth={finalWidth}
175
+ onChange={value => this.onChangeLabel(value, 'top')}
123
176
  />
124
177
  )}
125
178
  <div className={classes.wrapper}>
126
- <svg width={finalWidth} height={finalHeight} className={classes.svg}>
179
+ {showLabels && (
180
+ <Label
181
+ side="left"
182
+ text={labels.left}
183
+ disabledLabel={disabledLabels}
184
+ placeholder={labelsPlaceholders?.left}
185
+ graphHeight={finalHeight}
186
+ graphWidth={finalWidth}
187
+ isChartLeftLabel={isChart && !defineChart}
188
+ isDefineChartLeftLabel={isChart && defineChart}
189
+ onChange={value => this.onChangeLabel(value, 'left')}
190
+ />
191
+ )}
192
+ <svg
193
+ width={finalWidth}
194
+ height={finalHeight}
195
+ className={defineChart ? classes.defineChart : classes.chart}
196
+ >
127
197
  <g
128
198
  ref={r => {
129
199
  this.g = r;
@@ -132,17 +202,28 @@ export class Root extends React.Component {
132
202
  }
133
203
  }}
134
204
  className={classes.graphBox}
135
- transform={`translate(${padding}, ${padding})`}
205
+ transform={`translate(${leftPadding}, ${topPadding})`}
136
206
  >
137
207
  {children}
138
208
  </g>
139
209
  </svg>
210
+ {showLabels && !isChart && (
211
+ <Label
212
+ side="right"
213
+ text={labels.right}
214
+ disabledLabel={disabledLabels}
215
+ placeholder={labelsPlaceholders?.right}
216
+ graphHeight={finalHeight}
217
+ graphWidth={finalWidth}
218
+ onChange={value => this.onChangeLabel(value, 'right')}
219
+ />
220
+ )}
140
221
  {showPixelGuides && (
141
222
  <div
142
223
  className={classes.sidePixelGuides}
143
224
  style={{
144
225
  paddingTop: sideGridlinesPadding,
145
- marginTop: thisIsChart ? 25 : 60
226
+ marginTop: defineChart ? 25 : 31
146
227
  }}
147
228
  >
148
229
  {[...Array(nbOfHorizontalLines + 1).keys()].reverse().map(value => (
@@ -153,20 +234,44 @@ export class Root extends React.Component {
153
234
  </div>
154
235
  )}
155
236
  </div>
237
+ {showLabels && (
238
+ <Label
239
+ side="bottom"
240
+ text={labels.bottom}
241
+ disabledLabel={disabledLabels}
242
+ placeholder={labelsPlaceholders?.bottom}
243
+ graphHeight={finalHeight}
244
+ graphWidth={finalWidth}
245
+ isChartBottomLabel={isChart && !defineChart}
246
+ isDefineChartBottomLabel={isChart && defineChart}
247
+ onChange={value => this.onChangeLabel(value, 'bottom')}
248
+ />
249
+ )}
156
250
  </div>
157
251
  );
158
252
  }
159
253
  }
254
+
160
255
  const styles = theme => ({
161
256
  root: {
162
257
  border: `solid 1px ${color.primaryLight()}`,
163
258
  color: color.text(),
164
- backgroundColor: color.background()
259
+ backgroundColor: color.background(),
260
+ touchAction: 'none',
261
+ position: 'relative'
165
262
  },
166
263
  wrapper: {
167
- display: 'flex'
264
+ display: 'flex',
265
+ position: 'relative'
168
266
  },
169
267
  svg: {},
268
+ defineChart: {
269
+ paddingLeft: '50px',
270
+ overflow: 'visible'
271
+ },
272
+ chart: {
273
+ overflow: 'visible'
274
+ },
170
275
  graphBox: {
171
276
  cursor: 'pointer',
172
277
  userSelect: 'none'
@@ -180,6 +285,9 @@ const styles = theme => ({
180
285
  disabledTitle: {
181
286
  pointerEvents: 'none'
182
287
  },
288
+ rightMargin: {
289
+ marginRight: '74px'
290
+ },
183
291
  topPixelGuides: {
184
292
  display: 'flex',
185
293
  paddingTop: '6px'