@pie-lib/plot 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/lib/root.js +78 -11
- package/lib/root.js.map +1 -1
- package/package.json +2 -2
- package/src/root.jsx +91 -21
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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.4.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.3.0...@pie-lib/plot@2.4.0) (2022-08-15)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **graphing, plot:** added pixel guide lines + ui improvements ([02ddff1](https://github.com/pie-framework/pie-lib/commit/02ddff1aed6a279b8a4ae1fcf100c766596c29c4))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [2.3.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.2.0...@pie-lib/plot@2.3.0) (2022-08-01)
|
|
7
18
|
|
|
8
19
|
|
package/lib/root.js
CHANGED
|
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = exports.Root = void 0;
|
|
9
9
|
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
|
|
10
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
13
|
|
|
12
14
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -102,6 +104,8 @@ var Root = /*#__PURE__*/function (_React$Component) {
|
|
|
102
104
|
children = _this$props2.children,
|
|
103
105
|
classes = _this$props2.classes,
|
|
104
106
|
onChangeTitle = _this$props2.onChangeTitle,
|
|
107
|
+
showLabels = _this$props2.showLabels,
|
|
108
|
+
showPixelGuides = _this$props2.showPixelGuides,
|
|
105
109
|
showTitle = _this$props2.showTitle,
|
|
106
110
|
title = _this$props2.title,
|
|
107
111
|
rootRef = _this$props2.rootRef;
|
|
@@ -112,16 +116,27 @@ var Root = /*#__PURE__*/function (_React$Component) {
|
|
|
112
116
|
height = _graphProps$size$heig === void 0 ? 500 : _graphProps$size$heig,
|
|
113
117
|
domain = graphProps.domain,
|
|
114
118
|
range = graphProps.range;
|
|
115
|
-
var
|
|
116
|
-
var
|
|
117
|
-
|
|
118
|
-
var
|
|
119
|
-
var
|
|
120
|
-
var activeTitlePlugins = ['bold', 'italic', 'underline', 'strikethrough' // 'languageCharacters'
|
|
119
|
+
var padding = showLabels ? 70 : 40;
|
|
120
|
+
var extraPadding = showLabels ? 16 : 40;
|
|
121
|
+
var finalWidth = width + padding * 2 + (domain.padding || 0) * 2 + extraPadding;
|
|
122
|
+
var finalHeight = height + padding * 2 + (range.padding || 0) * 2;
|
|
123
|
+
var activeTitlePlugins = ['bold', 'italic', 'underline', 'strikethrough', 'math' // 'languageCharacters'
|
|
121
124
|
];
|
|
125
|
+
var nbOfVerticalLines = parseInt(width / 100);
|
|
126
|
+
var nbOfHorizontalLines = parseInt(height / 100);
|
|
127
|
+
var sideGridlinesPadding = parseInt(height % 100);
|
|
122
128
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
123
129
|
className: classes.root
|
|
124
|
-
},
|
|
130
|
+
}, showPixelGuides && /*#__PURE__*/_react["default"].createElement("div", {
|
|
131
|
+
className: classes.topPixelGuides
|
|
132
|
+
}, (0, _toConsumableArray2["default"])(Array(nbOfVerticalLines + 1).keys()).map(function (value) {
|
|
133
|
+
return /*#__PURE__*/_react["default"].createElement(_renderUi.Readable, {
|
|
134
|
+
"false": true,
|
|
135
|
+
key: "top-guide-".concat(value)
|
|
136
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
137
|
+
className: classes.topPixelIndicator
|
|
138
|
+
}, /*#__PURE__*/_react["default"].createElement("div", null, value * 100, "px"), /*#__PURE__*/_react["default"].createElement("div", null, "|")));
|
|
139
|
+
})), showTitle && /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
|
|
125
140
|
className: (0, _classnames["default"])((0, _defineProperty2["default"])({}, classes.disabledTitle, disabledTitle), classes.graphTitle),
|
|
126
141
|
markup: title || '',
|
|
127
142
|
width: finalWidth,
|
|
@@ -131,7 +146,9 @@ var Root = /*#__PURE__*/function (_React$Component) {
|
|
|
131
146
|
noBorder: true
|
|
132
147
|
},
|
|
133
148
|
activePlugins: activeTitlePlugins
|
|
134
|
-
}), /*#__PURE__*/_react["default"].createElement("
|
|
149
|
+
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
150
|
+
className: classes.wrapper
|
|
151
|
+
}, /*#__PURE__*/_react["default"].createElement("svg", {
|
|
135
152
|
width: finalWidth,
|
|
136
153
|
height: finalHeight,
|
|
137
154
|
className: classes.svg
|
|
@@ -144,8 +161,20 @@ var Root = /*#__PURE__*/function (_React$Component) {
|
|
|
144
161
|
}
|
|
145
162
|
},
|
|
146
163
|
className: classes.graphBox,
|
|
147
|
-
transform: "translate(".concat(
|
|
148
|
-
}, children))
|
|
164
|
+
transform: "translate(".concat(padding, ", ").concat(padding, ")")
|
|
165
|
+
}, children)), showPixelGuides && /*#__PURE__*/_react["default"].createElement("div", {
|
|
166
|
+
className: classes.sidePixelGuides,
|
|
167
|
+
style: {
|
|
168
|
+
paddingTop: sideGridlinesPadding
|
|
169
|
+
}
|
|
170
|
+
}, (0, _toConsumableArray2["default"])(Array(nbOfHorizontalLines + 1).keys()).reverse().map(function (value) {
|
|
171
|
+
return /*#__PURE__*/_react["default"].createElement(_renderUi.Readable, {
|
|
172
|
+
"false": true,
|
|
173
|
+
key: "top-guide-".concat(value)
|
|
174
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
175
|
+
className: classes.sidePixelIndicator
|
|
176
|
+
}, "\u2501 ", value * 100, "px"));
|
|
177
|
+
}))));
|
|
149
178
|
}
|
|
150
179
|
}]);
|
|
151
180
|
return Root;
|
|
@@ -155,10 +184,14 @@ exports.Root = Root;
|
|
|
155
184
|
(0, _defineProperty2["default"])(Root, "propTypes", {
|
|
156
185
|
title: _propTypes["default"].string,
|
|
157
186
|
children: _types.ChildrenType,
|
|
187
|
+
disabledTitle: _propTypes["default"].bool,
|
|
158
188
|
graphProps: _types.GraphPropsType.isRequired,
|
|
189
|
+
onChangeTitle: _propTypes["default"].func,
|
|
159
190
|
onMouseMove: _propTypes["default"].func,
|
|
160
191
|
classes: _propTypes["default"].object.isRequired,
|
|
192
|
+
showLabels: _propTypes["default"].bool,
|
|
161
193
|
showTitle: _propTypes["default"].bool,
|
|
194
|
+
showPixelGuides: _propTypes["default"].bool,
|
|
162
195
|
rootRef: _propTypes["default"].func
|
|
163
196
|
});
|
|
164
197
|
|
|
@@ -169,6 +202,9 @@ var styles = function styles(theme) {
|
|
|
169
202
|
color: _renderUi.color.text(),
|
|
170
203
|
backgroundColor: _renderUi.color.background()
|
|
171
204
|
},
|
|
205
|
+
wrapper: {
|
|
206
|
+
display: 'flex'
|
|
207
|
+
},
|
|
172
208
|
svg: {},
|
|
173
209
|
graphBox: {
|
|
174
210
|
cursor: 'pointer',
|
|
@@ -177,11 +213,42 @@ var styles = function styles(theme) {
|
|
|
177
213
|
graphTitle: {
|
|
178
214
|
color: _renderUi.color.text(),
|
|
179
215
|
fontSize: theme.typography.fontSize + 2,
|
|
180
|
-
padding: '
|
|
216
|
+
padding: '12px 4px 0',
|
|
181
217
|
textAlign: 'center'
|
|
182
218
|
},
|
|
183
219
|
disabledTitle: {
|
|
184
220
|
pointerEvents: 'none'
|
|
221
|
+
},
|
|
222
|
+
topPixelGuides: {
|
|
223
|
+
display: 'flex',
|
|
224
|
+
paddingTop: '6px',
|
|
225
|
+
marginLeft: '10px'
|
|
226
|
+
},
|
|
227
|
+
topPixelIndicator: {
|
|
228
|
+
color: _renderUi.color.primaryLight(),
|
|
229
|
+
display: 'flex',
|
|
230
|
+
flexDirection: 'column',
|
|
231
|
+
alignItems: 'center',
|
|
232
|
+
width: '100px',
|
|
233
|
+
pointerEvents: 'none',
|
|
234
|
+
userSelect: 'none'
|
|
235
|
+
},
|
|
236
|
+
sidePixelGuides: {
|
|
237
|
+
width: '70px',
|
|
238
|
+
display: 'flex',
|
|
239
|
+
flexDirection: 'column',
|
|
240
|
+
marginTop: '40px',
|
|
241
|
+
marginRight: '6px'
|
|
242
|
+
},
|
|
243
|
+
sidePixelIndicator: {
|
|
244
|
+
color: _renderUi.color.primaryLight(),
|
|
245
|
+
textAlign: 'right',
|
|
246
|
+
height: '20px',
|
|
247
|
+
pointerEvents: 'none',
|
|
248
|
+
userSelect: 'none',
|
|
249
|
+
'&:not(:last-child)': {
|
|
250
|
+
marginBottom: '80px'
|
|
251
|
+
}
|
|
185
252
|
}
|
|
186
253
|
};
|
|
187
254
|
};
|
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","showTitle","title","rootRef","size","width","height","domain","range","topPadding","leftPadding","finalWidth","padding","finalHeight","activeTitlePlugins","root","graphTitle","noBorder","svg","r","graphBox","React","Component","PropTypes","string","ChildrenType","GraphPropsType","isRequired","func","object","bool","styles","theme","border","color","primaryLight","text","backgroundColor","background","cursor","userSelect","fontSize","typography","textAlign","pointerEvents"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;IAEaA,I;;;;;;;;;;;;;;;kGAWC,UAAAC,CAAC,EAAI;AACf,wBAAoC,MAAKC,KAAzC;AAAA,UAAQC,UAAR,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CAACU,UAAN,CAAiBD,QAAjB,GAA4B,CAF5B;AAGV7B,MAAAA,OAAO,EAAE,YAHC;AAIV+B,MAAAA,SAAS,EAAE;AAJD,KAXW;AAiBvB9C,IAAAA,aAAa,EAAE;AACb+C,MAAAA,aAAa,EAAE;AADF;AAjBQ,GAAL;AAAA,CAApB;;eAsBe,wBAAWb,MAAX,EAAmBlD,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 } 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 graphProps: GraphPropsType.isRequired,\n onMouseMove: PropTypes.func,\n classes: PropTypes.object.isRequired,\n showTitle: 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 showTitle,\n title,\n rootRef\n } = this.props;\n const {\n size: { width = 500, height = 500 },\n domain,\n range\n } = graphProps;\n const topPadding = 50;\n const leftPadding = topPadding + 10; // left side requires an extra padding of 10\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 // 'languageCharacters'\n ];\n\n return (\n <div className={classes.root}>\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 <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(${leftPadding}, ${topPadding})`}\n >\n {children}\n </g>\n </svg>\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 svg: {},\n graphBox: {\n cursor: 'pointer',\n userSelect: 'none'\n },\n graphTitle: {\n color: color.text(),\n fontSize: theme.typography.fontSize + 2,\n padding: '8px 50px 0',\n textAlign: 'center'\n },\n disabledTitle: {\n pointerEvents: 'none'\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","on","mouseMove","bind","disabledTitle","children","classes","onChangeTitle","showLabels","showPixelGuides","showTitle","title","rootRef","size","width","height","domain","range","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","al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EAAE,MAJI;AAKfC,MAAAA,WAAW,EAAE;AALE,KArCM;AA4CvB9B,IAAAA,kBAAkB,EAAE;AAClBc,MAAAA,KAAK,EAAEA,gBAAMC,YAAN,EADW;AAElBS,MAAAA,SAAS,EAAE,OAFO;AAGlBpD,MAAAA,MAAM,EAAE,MAHU;AAIlBqD,MAAAA,aAAa,EAAE,MAJG;AAKlBJ,MAAAA,UAAU,EAAE,MALM;AAOlB,4BAAsB;AACpBU,QAAAA,YAAY,EAAE;AADM;AAPJ;AA5CG,GAAL;AAAA,CAApB;;eAyDe,wBAAWpB,MAAX,EAAmBlE,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 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 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 className={classes.sidePixelGuides} style={{ paddingTop: sideGridlinesPadding }}>\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 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 marginTop: '40px',\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.
|
|
6
|
+
"version": "2.4.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": "
|
|
41
|
+
"gitHead": "5cd198308a7395a8faa8d9c09ab548964d9d65bf",
|
|
42
42
|
"scripts": {}
|
|
43
43
|
}
|
package/src/root.jsx
CHANGED
|
@@ -4,7 +4,7 @@ import { withStyles } from '@material-ui/core/styles';
|
|
|
4
4
|
import { select, mouse } from 'd3-selection';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { GraphPropsType } from './types';
|
|
7
|
-
import { color } from '@pie-lib/render-ui';
|
|
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
10
|
|
|
@@ -12,10 +12,14 @@ export class Root extends React.Component {
|
|
|
12
12
|
static propTypes = {
|
|
13
13
|
title: PropTypes.string,
|
|
14
14
|
children: ChildrenType,
|
|
15
|
+
disabledTitle: PropTypes.bool,
|
|
15
16
|
graphProps: GraphPropsType.isRequired,
|
|
17
|
+
onChangeTitle: PropTypes.func,
|
|
16
18
|
onMouseMove: PropTypes.func,
|
|
17
19
|
classes: PropTypes.object.isRequired,
|
|
20
|
+
showLabels: PropTypes.bool,
|
|
18
21
|
showTitle: PropTypes.bool,
|
|
22
|
+
showPixelGuides: PropTypes.bool,
|
|
19
23
|
rootRef: PropTypes.func
|
|
20
24
|
};
|
|
21
25
|
|
|
@@ -56,6 +60,8 @@ export class Root extends React.Component {
|
|
|
56
60
|
children,
|
|
57
61
|
classes,
|
|
58
62
|
onChangeTitle,
|
|
63
|
+
showLabels,
|
|
64
|
+
showPixelGuides,
|
|
59
65
|
showTitle,
|
|
60
66
|
title,
|
|
61
67
|
rootRef
|
|
@@ -65,21 +71,39 @@ export class Root extends React.Component {
|
|
|
65
71
|
domain,
|
|
66
72
|
range
|
|
67
73
|
} = graphProps;
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const
|
|
74
|
+
|
|
75
|
+
const padding = showLabels ? 70 : 40;
|
|
76
|
+
const extraPadding = showLabels ? 16 : 40;
|
|
77
|
+
const finalWidth = width + padding * 2 + (domain.padding || 0) * 2 + extraPadding;
|
|
78
|
+
const finalHeight = height + padding * 2 + (range.padding || 0) * 2;
|
|
72
79
|
|
|
73
80
|
const activeTitlePlugins = [
|
|
74
81
|
'bold',
|
|
75
82
|
'italic',
|
|
76
83
|
'underline',
|
|
77
|
-
'strikethrough'
|
|
84
|
+
'strikethrough',
|
|
85
|
+
'math'
|
|
78
86
|
// 'languageCharacters'
|
|
79
87
|
];
|
|
80
88
|
|
|
89
|
+
const nbOfVerticalLines = parseInt(width / 100);
|
|
90
|
+
const nbOfHorizontalLines = parseInt(height / 100);
|
|
91
|
+
const sideGridlinesPadding = parseInt(height % 100);
|
|
92
|
+
|
|
81
93
|
return (
|
|
82
94
|
<div className={classes.root}>
|
|
95
|
+
{showPixelGuides && (
|
|
96
|
+
<div className={classes.topPixelGuides}>
|
|
97
|
+
{[...Array(nbOfVerticalLines + 1).keys()].map(value => (
|
|
98
|
+
<Readable false key={`top-guide-${value}`}>
|
|
99
|
+
<div className={classes.topPixelIndicator}>
|
|
100
|
+
<div>{value * 100}px</div>
|
|
101
|
+
<div>|</div>
|
|
102
|
+
</div>
|
|
103
|
+
</Readable>
|
|
104
|
+
))}
|
|
105
|
+
</div>
|
|
106
|
+
)}
|
|
83
107
|
{showTitle && (
|
|
84
108
|
<EditableHtml
|
|
85
109
|
className={cn(
|
|
@@ -96,20 +120,31 @@ export class Root extends React.Component {
|
|
|
96
120
|
activePlugins={activeTitlePlugins}
|
|
97
121
|
/>
|
|
98
122
|
)}
|
|
99
|
-
<
|
|
100
|
-
<
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
rootRef
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
123
|
+
<div className={classes.wrapper}>
|
|
124
|
+
<svg width={finalWidth} height={finalHeight} className={classes.svg}>
|
|
125
|
+
<g
|
|
126
|
+
ref={r => {
|
|
127
|
+
this.g = r;
|
|
128
|
+
if (rootRef) {
|
|
129
|
+
rootRef(r);
|
|
130
|
+
}
|
|
131
|
+
}}
|
|
132
|
+
className={classes.graphBox}
|
|
133
|
+
transform={`translate(${padding}, ${padding})`}
|
|
134
|
+
>
|
|
135
|
+
{children}
|
|
136
|
+
</g>
|
|
137
|
+
</svg>
|
|
138
|
+
{showPixelGuides && (
|
|
139
|
+
<div className={classes.sidePixelGuides} style={{ paddingTop: sideGridlinesPadding }}>
|
|
140
|
+
{[...Array(nbOfHorizontalLines + 1).keys()].reverse().map(value => (
|
|
141
|
+
<Readable false key={`top-guide-${value}`}>
|
|
142
|
+
<div className={classes.sidePixelIndicator}>━ {value * 100}px</div>
|
|
143
|
+
</Readable>
|
|
144
|
+
))}
|
|
145
|
+
</div>
|
|
146
|
+
)}
|
|
147
|
+
</div>
|
|
113
148
|
</div>
|
|
114
149
|
);
|
|
115
150
|
}
|
|
@@ -120,6 +155,9 @@ const styles = theme => ({
|
|
|
120
155
|
color: color.text(),
|
|
121
156
|
backgroundColor: color.background()
|
|
122
157
|
},
|
|
158
|
+
wrapper: {
|
|
159
|
+
display: 'flex'
|
|
160
|
+
},
|
|
123
161
|
svg: {},
|
|
124
162
|
graphBox: {
|
|
125
163
|
cursor: 'pointer',
|
|
@@ -128,11 +166,43 @@ const styles = theme => ({
|
|
|
128
166
|
graphTitle: {
|
|
129
167
|
color: color.text(),
|
|
130
168
|
fontSize: theme.typography.fontSize + 2,
|
|
131
|
-
padding: '
|
|
169
|
+
padding: '12px 4px 0',
|
|
132
170
|
textAlign: 'center'
|
|
133
171
|
},
|
|
134
172
|
disabledTitle: {
|
|
135
173
|
pointerEvents: 'none'
|
|
174
|
+
},
|
|
175
|
+
topPixelGuides: {
|
|
176
|
+
display: 'flex',
|
|
177
|
+
paddingTop: '6px',
|
|
178
|
+
marginLeft: '10px'
|
|
179
|
+
},
|
|
180
|
+
topPixelIndicator: {
|
|
181
|
+
color: color.primaryLight(),
|
|
182
|
+
display: 'flex',
|
|
183
|
+
flexDirection: 'column',
|
|
184
|
+
alignItems: 'center',
|
|
185
|
+
width: '100px',
|
|
186
|
+
pointerEvents: 'none',
|
|
187
|
+
userSelect: 'none'
|
|
188
|
+
},
|
|
189
|
+
sidePixelGuides: {
|
|
190
|
+
width: '70px',
|
|
191
|
+
display: 'flex',
|
|
192
|
+
flexDirection: 'column',
|
|
193
|
+
marginTop: '40px',
|
|
194
|
+
marginRight: '6px'
|
|
195
|
+
},
|
|
196
|
+
sidePixelIndicator: {
|
|
197
|
+
color: color.primaryLight(),
|
|
198
|
+
textAlign: 'right',
|
|
199
|
+
height: '20px',
|
|
200
|
+
pointerEvents: 'none',
|
|
201
|
+
userSelect: 'none',
|
|
202
|
+
|
|
203
|
+
'&:not(:last-child)': {
|
|
204
|
+
marginBottom: '80px'
|
|
205
|
+
}
|
|
136
206
|
}
|
|
137
207
|
});
|
|
138
208
|
|