@pie-lib/plot 2.1.10-next.624 → 2.1.10-next.661

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/label.js CHANGED
@@ -34,6 +34,8 @@ var LabelComponent = function LabelComponent(props) {
34
34
  disabledLabel = props.disabledLabel,
35
35
  graphHeight = props.graphHeight,
36
36
  graphWidth = props.graphWidth,
37
+ isChartBottomLabel = props.isChartBottomLabel,
38
+ isChartLeftLabel = props.isChartLeftLabel,
37
39
  placeholder = props.placeholder,
38
40
  text = props.text,
39
41
  side = props.side,
@@ -46,10 +48,11 @@ var LabelComponent = function LabelComponent(props) {
46
48
 
47
49
  var activePlugins = ['bold', 'italic', 'underline', 'strikethrough', 'math' // 'languageCharacters'
48
50
  ];
51
+ var chartValue = side === 'left' && isChartLeftLabel && graphHeight - 148;
49
52
  var defaultStyle = {
50
- width: side === 'left' || side === 'right' ? graphHeight - 8 : graphWidth - 8,
51
- top: side === 'left' && "".concat(graphHeight - 8, "px") || 0,
52
- left: side === 'right' && "".concat(graphWidth - 8, "px") || 0
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
53
56
  };
54
57
  var rotatedStyle = {
55
58
  width: graphWidth - 8,
@@ -64,7 +67,7 @@ var LabelComponent = function LabelComponent(props) {
64
67
  return /*#__PURE__*/_react["default"].createElement(_renderUi.Readable, {
65
68
  "false": true
66
69
  }, /*#__PURE__*/_react["default"].createElement("div", {
67
- 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), _cn)),
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)),
68
71
  style: rotatedToHorizontal ? rotatedStyle : defaultStyle,
69
72
  onClick: rotateLabel
70
73
  }, disabledLabel ? /*#__PURE__*/_react["default"].createElement("div", {
@@ -120,6 +123,9 @@ var _default = (0, _styles.withStyles)(function (theme) {
120
123
  transformOrigin: '0 0',
121
124
  transformStyle: 'preserve-3d',
122
125
  position: 'absolute'
126
+ },
127
+ customBottom: {
128
+ position: 'absolute'
123
129
  }
124
130
  };
125
131
  })(LabelComponent);
package/lib/label.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"label.js","names":["LabelComponent","props","classes","disabledLabel","graphHeight","graphWidth","placeholder","text","side","onChange","useState","rotatedToHorizontal","setRotatedToHorizontal","activePlugins","defaultStyle","width","top","left","rotatedStyle","rotateLabel","cn","axisLabel","rotateLeftLabel","rotateRightLabel","editLabel","__html","position","noBorder","withStyles","theme","label","fill","color","secondary","fontSize","typography","textAlign","margin","padding","pointerEvents","backgroundColor","borderRadius","boxShadow","zIndex","rotate","transformOrigin","transformStyle"],"sources":["../src/label.jsx"],"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 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 defaultStyle = {\n width: side === 'left' || side === 'right' ? graphHeight - 8 : graphWidth - 8,\n top: (side === 'left' && `${graphHeight - 8}px`) || 0,\n left: (side === 'right' && `${graphWidth - 8}px`) || 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 })}\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 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',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,EAAEL,KAAK,CAACM,UAAN,CAAiBD,QAAjB,GAA4B,CAD7B;MAETE,SAAS,EAAE,QAFF;MAGTC,MAAM,EAAE,KAHC;MAITC,OAAO,EAAE;IAJA,CAJuB;IAUlCnC,aAAa,EAAE;MACboC,aAAa,EAAE,MADF;MAEbxB,KAAK,EAAE;IAFM,CAVmB;IAclCS,SAAS,EAAE;MACTE,QAAQ,EAAE,UADD;MAETc,eAAe,EAAE,OAFR;MAGTC,YAAY,EAAE,KAHL;MAITC,SAAS,EAAE,iCAJF;MAKTC,MAAM,EAAE;IALC,CAduB;IAqBlCrB,eAAe,EAAE;MACfsB,MAAM,EAAE,QADO;MAEfC,eAAe,EAAE,KAFF;MAGfC,cAAc,EAAE,aAHD;MAIfpB,QAAQ,EAAE;IAJK,CArBiB;IA2BlCH,gBAAgB,EAAE;MAChBqB,MAAM,EAAE,OADQ;MAEhBC,eAAe,EAAE,KAFD;MAGhBC,cAAc,EAAE,aAHA;MAIhBpB,QAAQ,EAAE;IAJM;EA3BgB,CAAL;AAAA,CAAhB,EAiCX1B,cAjCW,C"}
1
+ {"version":3,"file":"label.js","names":["LabelComponent","props","classes","disabledLabel","graphHeight","graphWidth","isChartBottomLabel","isChartLeftLabel","placeholder","text","side","onChange","useState","rotatedToHorizontal","setRotatedToHorizontal","activePlugins","chartValue","defaultStyle","width","top","left","rotatedStyle","rotateLabel","cn","axisLabel","rotateLeftLabel","rotateRightLabel","editLabel","customBottom","__html","position","noBorder","withStyles","theme","label","fill","color","secondary","fontSize","typography","textAlign","margin","padding","pointerEvents","backgroundColor","borderRadius","boxShadow","zIndex","rotate","transformOrigin","transformStyle"],"sources":["../src/label.jsx"],"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 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"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,cAAc,GAAG,SAAjBA,cAAiB,CAAAC,KAAK,EAAI;EAAA;;EAC9B,IACEC,OADF,GAWID,KAXJ,CACEC,OADF;EAAA,IAEEC,aAFF,GAWIF,KAXJ,CAEEE,aAFF;EAAA,IAGEC,WAHF,GAWIH,KAXJ,CAGEG,WAHF;EAAA,IAIEC,UAJF,GAWIJ,KAXJ,CAIEI,UAJF;EAAA,IAKEC,kBALF,GAWIL,KAXJ,CAKEK,kBALF;EAAA,IAMEC,gBANF,GAWIN,KAXJ,CAMEM,gBANF;EAAA,IAOEC,WAPF,GAWIP,KAXJ,CAOEO,WAPF;EAAA,IAQEC,IARF,GAWIR,KAXJ,CAQEQ,IARF;EAAA,IASEC,IATF,GAWIT,KAXJ,CASES,IATF;EAAA,IAUEC,QAVF,GAWIV,KAXJ,CAUEU,QAVF;;EAYA,gBAAsD,IAAAC,eAAA,EAAS,KAAT,CAAtD;EAAA;EAAA,IAAOC,mBAAP;EAAA,IAA4BC,sBAA5B;;EACA,IAAMC,aAAa,GAAG,CACpB,MADoB,EAEpB,QAFoB,EAGpB,WAHoB,EAIpB,eAJoB,EAKpB,MALoB,CAMpB;EANoB,CAAtB;EASA,IAAMC,UAAU,GAAGN,IAAI,KAAK,MAAT,IAAmBH,gBAAnB,IAAuCH,WAAW,GAAG,GAAxE;EACA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E,KAFD;MAGhBC,cAAc,EAAE,aAHA;MAIhBpB,QAAQ,EAAE;IAJM,CA3BgB;IAiClCF,YAAY,EAAE;MACZE,QAAQ,EAAE;IADE;EAjCoB,CAAL;AAAA,CAAhB,EAoCX9B,cApCW,C"}
package/lib/root.js CHANGED
@@ -87,7 +87,19 @@ var Root = /*#__PURE__*/function (_React$Component) {
87
87
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChangeLabel", function (newValue, side) {
88
88
  var _this$props2 = _this.props,
89
89
  labels = _this$props2.labels,
90
- onChangeLabels = _this$props2.onChangeLabels;
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
+
91
103
  onChangeLabels(_objectSpread(_objectSpread({}, labels), {}, (0, _defineProperty2["default"])({}, side, newValue)));
92
104
  });
93
105
  return _this;
@@ -115,11 +127,13 @@ var Root = /*#__PURE__*/function (_React$Component) {
115
127
  disabledLabels = _this$props3.disabledLabels,
116
128
  labels = _this$props3.labels,
117
129
  labelsPlaceholders = _this$props3.labelsPlaceholders,
130
+ titlePlaceholder = _this$props3.titlePlaceholder,
118
131
  graphProps = _this$props3.graphProps,
119
132
  children = _this$props3.children,
120
133
  classes = _this$props3.classes,
134
+ defineChart = _this$props3.defineChart,
121
135
  onChangeTitle = _this$props3.onChangeTitle,
122
- thisIsChart = _this$props3.thisIsChart,
136
+ isChart = _this$props3.isChart,
123
137
  showLabels = _this$props3.showLabels,
124
138
  showPixelGuides = _this$props3.showPixelGuides,
125
139
  showTitle = _this$props3.showTitle,
@@ -138,7 +152,7 @@ var Root = /*#__PURE__*/function (_React$Component) {
138
152
  var finalHeight = height + topPadding * 2 + (range.padding || 0) * 2;
139
153
  var activeTitlePlugins = ['bold', 'italic', 'underline', 'strikethrough', 'math' // 'languageCharacters'
140
154
  ];
141
- var actualHeight = thisIsChart && showPixelGuides ? height - 80 : height;
155
+ var actualHeight = defineChart && showPixelGuides ? height - 150 : height;
142
156
  var nbOfVerticalLines = parseInt(width / 100);
143
157
  var nbOfHorizontalLines = parseInt(actualHeight / 100);
144
158
  var sideGridlinesPadding = parseInt(actualHeight % 100);
@@ -147,7 +161,7 @@ var Root = /*#__PURE__*/function (_React$Component) {
147
161
  }, showPixelGuides && /*#__PURE__*/_react["default"].createElement("div", {
148
162
  className: classes.topPixelGuides,
149
163
  style: {
150
- marginLeft: thisIsChart ? 10 : showLabels ? 30 : 10
164
+ marginLeft: isChart ? 60 : showLabels ? 30 : 10
151
165
  }
152
166
  }, (0, _toConsumableArray2["default"])(Array(nbOfVerticalLines + 1).keys()).map(function (value) {
153
167
  return /*#__PURE__*/_react["default"].createElement(_renderUi.Readable, {
@@ -165,16 +179,16 @@ var Root = /*#__PURE__*/function (_React$Component) {
165
179
  className: (0, _classnames["default"])((0, _defineProperty2["default"])({}, classes.rightMargin, showPixelGuides), classes.graphTitle),
166
180
  markup: title || '',
167
181
  onChange: onChangeTitle,
168
- 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',
169
183
  toolbarOpts: {
170
184
  noBorder: true
171
185
  },
172
186
  activePlugins: activeTitlePlugins
173
- })), showLabels && /*#__PURE__*/_react["default"].createElement(_label["default"], {
187
+ })), showLabels && !isChart && /*#__PURE__*/_react["default"].createElement(_label["default"], {
174
188
  side: "top",
175
189
  text: labels.top,
176
190
  disabledLabel: disabledLabels,
177
- placeholder: labelsPlaceholders.top,
191
+ placeholder: labelsPlaceholders === null || labelsPlaceholders === void 0 ? void 0 : labelsPlaceholders.top,
178
192
  graphHeight: finalHeight,
179
193
  graphWidth: finalWidth,
180
194
  onChange: function onChange(value) {
@@ -186,16 +200,17 @@ var Root = /*#__PURE__*/function (_React$Component) {
186
200
  side: "left",
187
201
  text: labels.left,
188
202
  disabledLabel: disabledLabels,
189
- placeholder: labelsPlaceholders.left,
203
+ placeholder: labelsPlaceholders === null || labelsPlaceholders === void 0 ? void 0 : labelsPlaceholders.left,
190
204
  graphHeight: finalHeight,
191
205
  graphWidth: finalWidth,
206
+ isChartLeftLabel: isChart && defineChart,
192
207
  onChange: function onChange(value) {
193
208
  return _this2.onChangeLabel(value, 'left');
194
209
  }
195
210
  }), /*#__PURE__*/_react["default"].createElement("svg", {
196
211
  width: finalWidth,
197
212
  height: finalHeight,
198
- className: classes.svg
213
+ className: defineChart ? classes.defineChart : classes.chart
199
214
  }, /*#__PURE__*/_react["default"].createElement("g", {
200
215
  ref: function ref(r) {
201
216
  _this2.g = r;
@@ -206,11 +221,11 @@ var Root = /*#__PURE__*/function (_React$Component) {
206
221
  },
207
222
  className: classes.graphBox,
208
223
  transform: "translate(".concat(leftPadding, ", ").concat(topPadding, ")")
209
- }, children)), showLabels && /*#__PURE__*/_react["default"].createElement(_label["default"], {
224
+ }, children)), showLabels && !isChart && /*#__PURE__*/_react["default"].createElement(_label["default"], {
210
225
  side: "right",
211
226
  text: labels.right,
212
227
  disabledLabel: disabledLabels,
213
- placeholder: labelsPlaceholders.right,
228
+ placeholder: labelsPlaceholders === null || labelsPlaceholders === void 0 ? void 0 : labelsPlaceholders.right,
214
229
  graphHeight: finalHeight,
215
230
  graphWidth: finalWidth,
216
231
  onChange: function onChange(value) {
@@ -220,7 +235,7 @@ var Root = /*#__PURE__*/function (_React$Component) {
220
235
  className: classes.sidePixelGuides,
221
236
  style: {
222
237
  paddingTop: sideGridlinesPadding,
223
- marginTop: thisIsChart ? 25 : 31
238
+ marginTop: defineChart ? 25 : 31
224
239
  }
225
240
  }, (0, _toConsumableArray2["default"])(Array(nbOfHorizontalLines + 1).keys()).reverse().map(function (value) {
226
241
  return /*#__PURE__*/_react["default"].createElement(_renderUi.Readable, {
@@ -233,9 +248,10 @@ var Root = /*#__PURE__*/function (_React$Component) {
233
248
  side: "bottom",
234
249
  text: labels.bottom,
235
250
  disabledLabel: disabledLabels,
236
- placeholder: labelsPlaceholders.bottom,
251
+ placeholder: labelsPlaceholders === null || labelsPlaceholders === void 0 ? void 0 : labelsPlaceholders.bottom,
237
252
  graphHeight: finalHeight,
238
253
  graphWidth: finalWidth,
254
+ isChartBottomLabel: isChart && defineChart,
239
255
  onChange: function onChange(value) {
240
256
  return _this2.onChangeLabel(value, 'bottom');
241
257
  }
@@ -265,13 +281,22 @@ var styles = function styles(theme) {
265
281
  root: {
266
282
  border: "solid 1px ".concat(_renderUi.color.primaryLight()),
267
283
  color: _renderUi.color.text(),
268
- backgroundColor: _renderUi.color.background()
284
+ backgroundColor: _renderUi.color.background(),
285
+ touchAction: 'none',
286
+ position: 'relative'
269
287
  },
270
288
  wrapper: {
271
289
  display: 'flex',
272
290
  position: 'relative'
273
291
  },
274
292
  svg: {},
293
+ defineChart: {
294
+ paddingLeft: '50px',
295
+ overflow: 'visible'
296
+ },
297
+ chart: {
298
+ overflow: 'visible'
299
+ },
275
300
  graphBox: {
276
301
  cursor: 'pointer',
277
302
  userSelect: 'none'
package/lib/root.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"root.js","names":["Root","g","props","graphProps","onMouseMove","scale","snap","coords","mouse","_groups","x","invert","y","snapped","newValue","side","labels","onChangeLabels","select","on","mouseMove","bind","disabledTitle","disabledLabels","labelsPlaceholders","children","classes","onChangeTitle","thisIsChart","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","cn","graphTitle","__html","rightMargin","noBorder","top","onChangeLabel","wrapper","left","svg","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","display","position","cursor","userSelect","fontSize","typography","textAlign","pointerEvents","marginRight","flexDirection","alignItems","marginBottom","withStyles"],"sources":["../src/root.jsx"],"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 } = this.props;\n\n onChangeLabels({\n ...labels,\n [side]: newValue\n });\n };\n\n render() {\n const {\n disabledTitle,\n disabledLabels,\n labels,\n labelsPlaceholders,\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 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 = 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\n className={classes.topPixelGuides}\n style={{ marginLeft: thisIsChart ? 10 : 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={!disabledTitle && 'Click here to add a title for this graph'}\n toolbarOpts={{ noBorder: true }}\n activePlugins={activeTitlePlugins}\n />\n ))}\n {showLabels && (\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 onChange={value => this.onChangeLabel(value, 'left')}\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 {showLabels && (\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: thisIsChart ? 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 onChange={value => this.onChangeLabel(value, 'bottom')}\n />\n )}\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 position: 'relative'\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 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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;;IAEaA,I;;;;;;;;;;;;;;;kGAeC,UAAAC,CAAC,EAAI;MACf,kBAAoC,MAAKC,KAAzC;MAAA,IAAQC,UAAR,eAAQA,UAAR;MAAA,IAAoBC,WAApB,eAAoBA,WAApB;;MAEA,IAAI,CAACA,WAAL,EAAkB;QAChB;MACD;;MAED,IAAQC,KAAR,GAAwBF,UAAxB,CAAQE,KAAR;MAAA,IAAeC,IAAf,GAAwBH,UAAxB,CAAeG,IAAf;MACA,IAAMC,MAAM,GAAG,IAAAC,kBAAA,EAAMP,CAAC,CAACQ,OAAF,CAAU,CAAV,EAAa,CAAb,CAAN,CAAf;MACA,IAAMC,CAAC,GAAGL,KAAK,CAACK,CAAN,CAAQC,MAAR,CAAeJ,MAAM,CAAC,CAAD,CAArB,CAAV;MACA,IAAMK,CAAC,GAAGP,KAAK,CAACO,CAAN,CAAQD,MAAR,CAAeJ,MAAM,CAAC,CAAD,CAArB,CAAV;MAEA,IAAMM,OAAO,GAAG;QACdH,CAAC,EAAEJ,IAAI,CAACI,CAAL,CAAOA,CAAP,CADW;QAEdE,CAAC,EAAEN,IAAI,CAACM,CAAL,CAAOA,CAAP;MAFW,CAAhB;MAKAR,WAAW,CAACS,OAAD,CAAX;IACD,C;sGAYe,UAACC,QAAD,EAAWC,IAAX,EAAoB;MAClC,mBAAmC,MAAKb,KAAxC;MAAA,IAAQc,MAAR,gBAAQA,MAAR;MAAA,IAAgBC,cAAhB,gBAAgBA,cAAhB;MAEAA,cAAc,iCACTD,MADS,4CAEXD,IAFW,EAEJD,QAFI,GAAd;IAID,C;;;;;;WAjBD,6BAAoB;M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EADG;MAEVO,QAAQ,EAAEX,KAAK,CAACY,UAAN,CAAiBD,QAAjB,GAA4B,CAF5B;MAGVzD,OAAO,EAAE,YAHC;MAIV2D,SAAS,EAAE;IAJD,CAfW;IAqBvB/E,aAAa,EAAE;MACbgF,aAAa,EAAE;IADF,CArBQ;IAwBvBzC,WAAW,EAAE;MACX0C,WAAW,EAAE;IADF,CAxBU;IA2BvBpD,cAAc,EAAE;MACd4C,OAAO,EAAE,MADK;MAEdvB,UAAU,EAAE;IAFE,CA3BO;IA+BvBf,iBAAiB,EAAE;MACjBiC,KAAK,EAAEA,eAAA,CAAMC,YAAN,EADU;MAEjBI,OAAO,EAAE,MAFQ;MAGjBS,aAAa,EAAE,QAHE;MAIjBC,UAAU,EAAE,QAJK;MAKjBtE,KAAK,EAAE,OALU;MAMjBmE,aAAa,EAAE,MANE;MAOjBJ,UAAU,EAAE;IAPK,CA/BI;IAwCvB3B,eAAe,EAAE;MACfpC,KAAK,EAAE,MADQ;MAEf4D,OAAO,EAAE,MAFM;MAGfS,aAAa,EAAE,QAHA;MAIfD,WAAW,EAAE;IAJE,CAxCM;IA8CvB5B,kBAAkB,EAAE;MAClBe,KAAK,EAAEA,eAAA,CAAMC,YAAN,EADW;MAElBU,SAAS,EAAE,OAFO;MAGlBjE,MAAM,EAAE,MAHU;MAIlBkE,aAAa,EAAE,MAJG;MAKlBJ,UAAU,EAAE,MALM;MAOlB,sBAAsB;QACpBQ,YAAY,EAAE;MADM;IAPJ;EA9CG,CAAL;AAAA,CAApB;;eA2De,IAAAC,kBAAA,EAAWpB,MAAX,EAAmBvF,IAAnB,C"}
1
+ {"version":3,"file":"root.js","names":["Root","g","props","graphProps","onMouseMove","scale","snap","coords","mouse","_groups","x","invert","y","snapped","newValue","side","labels","onChangeLabels","isChart","select","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","cn","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","withStyles"],"sources":["../src/root.jsx"],"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 />\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;;IAEaA,I;;;;;;;;;;;;;;;kGAeC,UAAAC,CAAC,EAAI;MACf,kBAAoC,MAAKC,KAAzC;MAAA,IAAQC,UAAR,eAAQA,UAAR;MAAA,IAAoBC,WAApB,eAAoBA,WAApB;;MAEA,IAAI,CAACA,WAAL,EAAkB;QAChB;MACD;;MAED,IAAQC,KAAR,GAAwBF,UAAxB,CAAQE,KAAR;MAAA,IAAeC,IAAf,GAAwBH,UAAxB,CAAeG,IAAf;MACA,IAAMC,MAAM,GAAG,IAAAC,kBAAA,EAAMP,CAAC,CAACQ,OAAF,CAAU,CAAV,EAAa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  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "2.1.10-next.624+902972ab",
6
+ "version": "2.1.10-next.661+24b1f730",
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": "902972ab86b0fcd40ddd0e7c809efe9922605668",
41
+ "gitHead": "24b1f73049d7c2f386cc7d3d198c036ab6c7dadf",
42
42
  "scripts": {}
43
43
  }
package/src/label.jsx CHANGED
@@ -10,6 +10,8 @@ const LabelComponent = props => {
10
10
  disabledLabel,
11
11
  graphHeight,
12
12
  graphWidth,
13
+ isChartBottomLabel,
14
+ isChartLeftLabel,
13
15
  placeholder,
14
16
  text,
15
17
  side,
@@ -25,10 +27,18 @@ const LabelComponent = props => {
25
27
  // 'languageCharacters'
26
28
  ];
27
29
 
30
+ const chartValue = side === 'left' && isChartLeftLabel && graphHeight - 148;
28
31
  const defaultStyle = {
29
- width: side === 'left' || side === 'right' ? graphHeight - 8 : graphWidth - 8,
30
- top: (side === 'left' && `${graphHeight - 8}px`) || 0,
31
- left: (side === 'right' && `${graphWidth - 8}px`) || 0
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
32
42
  };
33
43
 
34
44
  const rotatedStyle = {
@@ -46,7 +56,8 @@ const LabelComponent = props => {
46
56
  className={cn(classes.axisLabel, {
47
57
  [classes.rotateLeftLabel]: side === 'left' && !rotatedToHorizontal,
48
58
  [classes.rotateRightLabel]: side === 'right' && !rotatedToHorizontal,
49
- [classes.editLabel]: rotatedToHorizontal
59
+ [classes.editLabel]: rotatedToHorizontal,
60
+ [classes.customBottom]: isChartBottomLabel
50
61
  })}
51
62
  style={rotatedToHorizontal ? rotatedStyle : defaultStyle}
52
63
  onClick={rotateLabel}
@@ -103,5 +114,8 @@ export default withStyles(theme => ({
103
114
  transformOrigin: '0 0',
104
115
  transformStyle: 'preserve-3d',
105
116
  position: 'absolute'
117
+ },
118
+ customBottom: {
119
+ position: 'absolute'
106
120
  }
107
121
  }))(LabelComponent);
package/src/root.jsx CHANGED
@@ -55,7 +55,17 @@ export class Root extends React.Component {
55
55
  }
56
56
 
57
57
  onChangeLabel = (newValue, side) => {
58
- const { labels, onChangeLabels } = this.props;
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
+ }
59
69
 
60
70
  onChangeLabels({
61
71
  ...labels,
@@ -69,11 +79,13 @@ export class Root extends React.Component {
69
79
  disabledLabels,
70
80
  labels,
71
81
  labelsPlaceholders,
82
+ titlePlaceholder,
72
83
  graphProps,
73
84
  children,
74
85
  classes,
86
+ defineChart,
75
87
  onChangeTitle,
76
- thisIsChart,
88
+ isChart,
77
89
  showLabels,
78
90
  showPixelGuides,
79
91
  showTitle,
@@ -100,7 +112,7 @@ export class Root extends React.Component {
100
112
  // 'languageCharacters'
101
113
  ];
102
114
 
103
- const actualHeight = thisIsChart && showPixelGuides ? height - 80 : height;
115
+ const actualHeight = defineChart && showPixelGuides ? height - 150 : height;
104
116
  const nbOfVerticalLines = parseInt(width / 100);
105
117
  const nbOfHorizontalLines = parseInt(actualHeight / 100);
106
118
  const sideGridlinesPadding = parseInt(actualHeight % 100);
@@ -110,7 +122,7 @@ export class Root extends React.Component {
110
122
  {showPixelGuides && (
111
123
  <div
112
124
  className={classes.topPixelGuides}
113
- style={{ marginLeft: thisIsChart ? 10 : showLabels ? 30 : 10 }}
125
+ style={{ marginLeft: isChart ? 60 : showLabels ? 30 : 10 }}
114
126
  >
115
127
  {[...Array(nbOfVerticalLines + 1).keys()].map(value => (
116
128
  <Readable false key={`top-guide-${value}`}>
@@ -133,17 +145,20 @@ export class Root extends React.Component {
133
145
  className={cn({ [classes.rightMargin]: showPixelGuides }, classes.graphTitle)}
134
146
  markup={title || ''}
135
147
  onChange={onChangeTitle}
136
- placeholder={!disabledTitle && 'Click here to add a title for this graph'}
148
+ placeholder={
149
+ (defineChart && titlePlaceholder) ||
150
+ (!disabledTitle && 'Click here to add a title for this graph')
151
+ }
137
152
  toolbarOpts={{ noBorder: true }}
138
153
  activePlugins={activeTitlePlugins}
139
154
  />
140
155
  ))}
141
- {showLabels && (
156
+ {showLabels && !isChart && (
142
157
  <Label
143
158
  side="top"
144
159
  text={labels.top}
145
160
  disabledLabel={disabledLabels}
146
- placeholder={labelsPlaceholders.top}
161
+ placeholder={labelsPlaceholders?.top}
147
162
  graphHeight={finalHeight}
148
163
  graphWidth={finalWidth}
149
164
  onChange={value => this.onChangeLabel(value, 'top')}
@@ -155,13 +170,18 @@ export class Root extends React.Component {
155
170
  side="left"
156
171
  text={labels.left}
157
172
  disabledLabel={disabledLabels}
158
- placeholder={labelsPlaceholders.left}
173
+ placeholder={labelsPlaceholders?.left}
159
174
  graphHeight={finalHeight}
160
175
  graphWidth={finalWidth}
176
+ isChartLeftLabel={isChart && defineChart}
161
177
  onChange={value => this.onChangeLabel(value, 'left')}
162
178
  />
163
179
  )}
164
- <svg width={finalWidth} height={finalHeight} className={classes.svg}>
180
+ <svg
181
+ width={finalWidth}
182
+ height={finalHeight}
183
+ className={defineChart ? classes.defineChart : classes.chart}
184
+ >
165
185
  <g
166
186
  ref={r => {
167
187
  this.g = r;
@@ -175,12 +195,12 @@ export class Root extends React.Component {
175
195
  {children}
176
196
  </g>
177
197
  </svg>
178
- {showLabels && (
198
+ {showLabels && !isChart && (
179
199
  <Label
180
200
  side="right"
181
201
  text={labels.right}
182
202
  disabledLabel={disabledLabels}
183
- placeholder={labelsPlaceholders.right}
203
+ placeholder={labelsPlaceholders?.right}
184
204
  graphHeight={finalHeight}
185
205
  graphWidth={finalWidth}
186
206
  onChange={value => this.onChangeLabel(value, 'right')}
@@ -191,7 +211,7 @@ export class Root extends React.Component {
191
211
  className={classes.sidePixelGuides}
192
212
  style={{
193
213
  paddingTop: sideGridlinesPadding,
194
- marginTop: thisIsChart ? 25 : 31
214
+ marginTop: defineChart ? 25 : 31
195
215
  }}
196
216
  >
197
217
  {[...Array(nbOfHorizontalLines + 1).keys()].reverse().map(value => (
@@ -207,9 +227,10 @@ export class Root extends React.Component {
207
227
  side="bottom"
208
228
  text={labels.bottom}
209
229
  disabledLabel={disabledLabels}
210
- placeholder={labelsPlaceholders.bottom}
230
+ placeholder={labelsPlaceholders?.bottom}
211
231
  graphHeight={finalHeight}
212
232
  graphWidth={finalWidth}
233
+ isChartBottomLabel={isChart && defineChart}
213
234
  onChange={value => this.onChangeLabel(value, 'bottom')}
214
235
  />
215
236
  )}
@@ -217,17 +238,27 @@ export class Root extends React.Component {
217
238
  );
218
239
  }
219
240
  }
241
+
220
242
  const styles = theme => ({
221
243
  root: {
222
244
  border: `solid 1px ${color.primaryLight()}`,
223
245
  color: color.text(),
224
- backgroundColor: color.background()
246
+ backgroundColor: color.background(),
247
+ touchAction: 'none',
248
+ position: 'relative'
225
249
  },
226
250
  wrapper: {
227
251
  display: 'flex',
228
252
  position: 'relative'
229
253
  },
230
254
  svg: {},
255
+ defineChart: {
256
+ paddingLeft: '50px',
257
+ overflow: 'visible'
258
+ },
259
+ chart: {
260
+ overflow: 'visible'
261
+ },
231
262
  graphBox: {
232
263
  cursor: 'pointer',
233
264
  userSelect: 'none'