@pie-lib/plot 2.13.0 → 2.15.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 +6 -10
- package/lib/draggable.js +65 -0
- package/lib/draggable.js.map +1 -0
- package/lib/graph-props.js +53 -0
- package/lib/graph-props.js.map +1 -0
- package/lib/grid-draggable.js +381 -0
- package/lib/grid-draggable.js.map +1 -0
- package/lib/index.js +59 -0
- package/lib/index.js.map +1 -0
- package/lib/label.js +176 -0
- package/lib/label.js.map +1 -0
- package/lib/root.js +422 -0
- package/lib/root.js.map +1 -0
- package/lib/trig.js +196 -0
- package/lib/trig.js.map +1 -0
- package/lib/types.js +68 -0
- package/lib/types.js.map +1 -0
- package/lib/utils.js +232 -0
- package/lib/utils.js.map +1 -0
- package/package.json +4 -4
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;AACA;;;;AACA;;;;AACA","sourcesContent":["import Root from './root';\nimport Draggable from './draggable';\nimport { gridDraggable } from './grid-draggable';\nimport * as utils from './utils';\nimport * as trig from './trig';\nimport * as types from './types';\nimport { create as createGraphProps } from './graph-props';\n\nexport { Root, Draggable, gridDraggable, utils, trig, types, createGraphProps };\n"],"file":"index.js"}
|
package/lib/label.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
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
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
27
|
+
|
|
28
|
+
var _utils = require("./utils");
|
|
29
|
+
|
|
30
|
+
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); }
|
|
31
|
+
|
|
32
|
+
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; }
|
|
33
|
+
|
|
34
|
+
var LabelComponent = function LabelComponent(props) {
|
|
35
|
+
var _cn;
|
|
36
|
+
|
|
37
|
+
var classes = props.classes,
|
|
38
|
+
disabledLabel = props.disabledLabel,
|
|
39
|
+
graphHeight = props.graphHeight,
|
|
40
|
+
graphWidth = props.graphWidth,
|
|
41
|
+
isChartBottomLabel = props.isChartBottomLabel,
|
|
42
|
+
isDefineChartBottomLabel = props.isDefineChartBottomLabel,
|
|
43
|
+
isChartLeftLabel = props.isChartLeftLabel,
|
|
44
|
+
isDefineChartLeftLabel = props.isDefineChartLeftLabel,
|
|
45
|
+
placeholder = props.placeholder,
|
|
46
|
+
text = props.text,
|
|
47
|
+
side = props.side,
|
|
48
|
+
onChange = props.onChange,
|
|
49
|
+
_props$mathMlOptions = props.mathMlOptions,
|
|
50
|
+
mathMlOptions = _props$mathMlOptions === void 0 ? {} : _props$mathMlOptions,
|
|
51
|
+
charactersLimit = props.charactersLimit,
|
|
52
|
+
titleHeight = props.titleHeight;
|
|
53
|
+
|
|
54
|
+
var _useState = (0, _react.useState)(false),
|
|
55
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
56
|
+
rotatedToHorizontal = _useState2[0],
|
|
57
|
+
setRotatedToHorizontal = _useState2[1];
|
|
58
|
+
|
|
59
|
+
var activePlugins = ['bold', 'italic', 'underline', 'strikethrough', 'math' // 'languageCharacters'
|
|
60
|
+
];
|
|
61
|
+
var isChart = isChartBottomLabel || isChartLeftLabel || isDefineChartBottomLabel || isDefineChartLeftLabel;
|
|
62
|
+
var chartValue = side === 'left' && isDefineChartLeftLabel && graphHeight - 220;
|
|
63
|
+
var defaultStyle = {
|
|
64
|
+
width: chartValue || (side === 'left' || side === 'right' ? graphHeight - 8 : graphWidth - 8),
|
|
65
|
+
top: chartValue || isChartLeftLabel && "".concat(graphHeight - 70, "px") || side === 'left' && "".concat(graphHeight - 8, "px") || isChartBottomLabel && "".concat(graphHeight - 60 + titleHeight, "px") || side === 'bottom' && "".concat(graphHeight - 120 + titleHeight, "px") || 0,
|
|
66
|
+
left: side === 'right' && "".concat(graphWidth - 8, "px") || (isDefineChartLeftLabel || isDefineChartBottomLabel) && '40px' || isChartBottomLabel && '-10px' || 0
|
|
67
|
+
};
|
|
68
|
+
var rotatedStyle = {
|
|
69
|
+
width: graphWidth - 8,
|
|
70
|
+
top: side === 'right' && "".concat(graphHeight - 22, "px") || 0,
|
|
71
|
+
left: 0
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
var rotateLabel = function rotateLabel() {
|
|
75
|
+
return !disabledLabel && (side === 'left' || side === 'right') && setRotatedToHorizontal(true);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return /*#__PURE__*/_react["default"].createElement(_renderUi.Readable, {
|
|
79
|
+
"false": true
|
|
80
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
81
|
+
className: (0, _classnames["default"])(isChart ? classes.chartLabel : 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), (0, _defineProperty2["default"])(_cn, classes.displayNone, disabledLabel && !isChart && (0, _utils.isEmptyString)((0, _utils.extractTextFromHTML)(text))), _cn)),
|
|
82
|
+
style: rotatedToHorizontal ? rotatedStyle : defaultStyle,
|
|
83
|
+
onClick: rotateLabel
|
|
84
|
+
}, disabledLabel ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
85
|
+
className: classes.disabledLabel,
|
|
86
|
+
dangerouslySetInnerHTML: {
|
|
87
|
+
__html: text || ''
|
|
88
|
+
}
|
|
89
|
+
}) : /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
|
|
90
|
+
markup: text || '',
|
|
91
|
+
onChange: onChange,
|
|
92
|
+
placeholder: !disabledLabel && placeholder,
|
|
93
|
+
toolbarOpts: {
|
|
94
|
+
position: side === 'bottom' ? 'top' : 'bottom',
|
|
95
|
+
noPadding: true,
|
|
96
|
+
noBorder: true
|
|
97
|
+
},
|
|
98
|
+
disableScrollbar: true,
|
|
99
|
+
activePlugins: activePlugins,
|
|
100
|
+
onDone: function onDone() {
|
|
101
|
+
return setRotatedToHorizontal(false);
|
|
102
|
+
},
|
|
103
|
+
mathMlOptions: mathMlOptions,
|
|
104
|
+
charactersLimit: charactersLimit
|
|
105
|
+
})));
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
LabelComponent.propTypes = {
|
|
109
|
+
classes: _propTypes["default"].object,
|
|
110
|
+
disabledLabel: _propTypes["default"].bool,
|
|
111
|
+
graphHeight: _propTypes["default"].number,
|
|
112
|
+
graphWidth: _propTypes["default"].number,
|
|
113
|
+
isChartBottomLabel: _propTypes["default"].bool,
|
|
114
|
+
isDefineChartBottomLabel: _propTypes["default"].bool,
|
|
115
|
+
isChartLeftLabel: _propTypes["default"].bool,
|
|
116
|
+
isDefineChartLeftLabel: _propTypes["default"].bool,
|
|
117
|
+
placeholder: _propTypes["default"].string,
|
|
118
|
+
text: _propTypes["default"].string,
|
|
119
|
+
side: _propTypes["default"].string,
|
|
120
|
+
onChange: _propTypes["default"].func,
|
|
121
|
+
mathMlOptions: _propTypes["default"].object,
|
|
122
|
+
charactersLimit: _propTypes["default"].number,
|
|
123
|
+
titleHeight: _propTypes["default"].number
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
var _default = (0, _styles.withStyles)(function (theme) {
|
|
127
|
+
return {
|
|
128
|
+
label: {
|
|
129
|
+
fill: _renderUi.color.secondary()
|
|
130
|
+
},
|
|
131
|
+
axisLabel: {
|
|
132
|
+
fontSize: theme.typography.fontSize - 2,
|
|
133
|
+
textAlign: 'center',
|
|
134
|
+
margin: theme.spacing.unit / 2,
|
|
135
|
+
padding: "".concat(theme.spacing.unit / 2, "px 0")
|
|
136
|
+
},
|
|
137
|
+
chartLabel: {
|
|
138
|
+
fontSize: theme.typography.fontSize + 2,
|
|
139
|
+
textAlign: 'center',
|
|
140
|
+
margin: theme.spacing.unit / 2,
|
|
141
|
+
padding: "".concat(theme.spacing.unit / 2, "px 0")
|
|
142
|
+
},
|
|
143
|
+
disabledLabel: {
|
|
144
|
+
pointerEvents: 'none',
|
|
145
|
+
width: '100%'
|
|
146
|
+
},
|
|
147
|
+
editLabel: {
|
|
148
|
+
position: 'absolute',
|
|
149
|
+
backgroundColor: 'white',
|
|
150
|
+
borderRadius: '4px',
|
|
151
|
+
boxShadow: '0px 5px 8px rgba(0, 0, 0, 0.15)',
|
|
152
|
+
zIndex: 10
|
|
153
|
+
},
|
|
154
|
+
rotateLeftLabel: {
|
|
155
|
+
'-webkit-transform': 'rotate(-90deg)',
|
|
156
|
+
transformOrigin: '0 0',
|
|
157
|
+
transformStyle: 'preserve-3d',
|
|
158
|
+
position: 'absolute'
|
|
159
|
+
},
|
|
160
|
+
rotateRightLabel: {
|
|
161
|
+
'-webkit-transform': 'rotate(90deg)',
|
|
162
|
+
transformOrigin: '0 0',
|
|
163
|
+
transformStyle: 'preserve-3d',
|
|
164
|
+
position: 'absolute'
|
|
165
|
+
},
|
|
166
|
+
customBottom: {
|
|
167
|
+
position: 'absolute'
|
|
168
|
+
},
|
|
169
|
+
displayNone: {
|
|
170
|
+
display: 'none'
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
})(LabelComponent);
|
|
174
|
+
|
|
175
|
+
exports["default"] = _default;
|
|
176
|
+
//# sourceMappingURL=label.js.map
|
package/lib/label.js.map
ADDED
|
@@ -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","mathMlOptions","charactersLimit","titleHeight","rotatedToHorizontal","setRotatedToHorizontal","activePlugins","isChart","chartValue","defaultStyle","width","top","left","rotatedStyle","rotateLabel","chartLabel","axisLabel","rotateLeftLabel","rotateRightLabel","editLabel","customBottom","displayNone","__html","position","noPadding","noBorder","propTypes","PropTypes","object","bool","number","string","func","theme","label","fill","color","secondary","fontSize","typography","textAlign","margin","spacing","unit","padding","pointerEvents","backgroundColor","borderRadius","boxShadow","zIndex","transformOrigin","transformStyle","display"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AACA,IAAMA,cAAc,GAAG,SAAjBA,cAAiB,CAACC,KAAD,EAAW;AAAA;;AAChC,MACEC,OADF,GAgBID,KAhBJ,CACEC,OADF;AAAA,MAEEC,aAFF,GAgBIF,KAhBJ,CAEEE,aAFF;AAAA,MAGEC,WAHF,GAgBIH,KAhBJ,CAGEG,WAHF;AAAA,MAIEC,UAJF,GAgBIJ,KAhBJ,CAIEI,UAJF;AAAA,MAKEC,kBALF,GAgBIL,KAhBJ,CAKEK,kBALF;AAAA,MAMEC,wBANF,GAgBIN,KAhBJ,CAMEM,wBANF;AAAA,MAOEC,gBAPF,GAgBIP,KAhBJ,CAOEO,gBAPF;AAAA,MAQEC,sBARF,GAgBIR,KAhBJ,CAQEQ,sBARF;AAAA,MASEC,WATF,GAgBIT,KAhBJ,CASES,WATF;AAAA,MAUEC,IAVF,GAgBIV,KAhBJ,CAUEU,IAVF;AAAA,MAWEC,IAXF,GAgBIX,KAhBJ,CAWEW,IAXF;AAAA,MAYEC,QAZF,GAgBIZ,KAhBJ,CAYEY,QAZF;AAAA,6BAgBIZ,KAhBJ,CAaEa,aAbF;AAAA,MAaEA,aAbF,qCAakB,EAblB;AAAA,MAcEC,eAdF,GAgBId,KAhBJ,CAcEc,eAdF;AAAA,MAeEC,WAfF,GAgBIf,KAhBJ,CAeEe,WAfF;;AAiBA,kBAAsD,qBAAS,KAAT,CAAtD;AAAA;AAAA,MAAOC,mBAAP;AAAA,MAA4BC,sBAA5B;;AACA,MAAMC,aAAa,GAAG,CACpB,MADoB,EAEpB,QAFoB,EAGpB,WA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AAAA,UAAU,EAAE;AACVuB,MAAAA,QAAQ,EAAEL,KAAK,CAACM,UAAN,CAAiBD,QAAjB,GAA4B,CAD5B;AAEVE,MAAAA,SAAS,EAAE,QAFD;AAGVC,MAAAA,MAAM,EAAER,KAAK,CAACS,OAAN,CAAcC,IAAd,GAAqB,CAHnB;AAIVC,MAAAA,OAAO,YAAKX,KAAK,CAACS,OAAN,CAAcC,IAAd,GAAqB,CAA1B;AAJG,KAVwB;AAgBpCrD,IAAAA,aAAa,EAAE;AACbuD,MAAAA,aAAa,EAAE,MADF;AAEbnC,MAAAA,KAAK,EAAE;AAFM,KAhBqB;AAoBpCS,IAAAA,SAAS,EAAE;AACTI,MAAAA,QAAQ,EAAE,UADD;AAETuB,MAAAA,eAAe,EAAE,OAFR;AAGTC,MAAAA,YAAY,EAAE,KAHL;AAITC,MAAAA,SAAS,EAAE,iCAJF;AAKTC,MAAAA,MAAM,EAAE;AALC,KApByB;AA2BpChC,IAAAA,eAAe,EAAE;AACf,2BAAqB,gBADN;AAEfiC,MAAAA,eAAe,EAAE,KAFF;AAGfC,MAAAA,cAAc,EAAE,aAHD;AAIf5B,MAAAA,QAAQ,EAAE;AAJK,KA3BmB;AAiCpCL,IAAAA,gBAAgB,EAAE;AAChB,2BAAqB,eADL;AAEhBgC,MAAAA,eAAe,EAAE,KAFD;AAGhBC,MAAAA,cAAc,EAAE,aAHA;AAIhB5B,MAAAA,QAAQ,EAAE;AAJM,KAjCkB;AAuCpCH,IAAAA,YAAY,EAAE;AACZG,MAAAA,QAAQ,EAAE;AADE,KAvCsB;AA0CpCF,IAAAA,WAAW,EAAE;AACX+B,MAAAA,OAAO,EAAE;AADE;AA1CuB,GAAZ;AAAA,CAAX,EA6CXjE,cA7CW,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';\nimport PropTypes from 'prop-types';\nimport { extractTextFromHTML, isEmptyString } from './utils';\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 mathMlOptions = {},\n charactersLimit,\n titleHeight,\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 isChart = isChartBottomLabel || isChartLeftLabel || isDefineChartBottomLabel || isDefineChartLeftLabel;\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 - 60 + titleHeight}px`) ||\n (side === 'bottom' && `${graphHeight - 120 + titleHeight}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 = () => !disabledLabel && (side === 'left' || side === 'right') && setRotatedToHorizontal(true);\n\n return (\n <Readable false>\n <div\n className={cn(isChart ? classes.chartLabel : classes.axisLabel, {\n [classes.rotateLeftLabel]: side === 'left' && !rotatedToHorizontal,\n [classes.rotateRightLabel]: side === 'right' && !rotatedToHorizontal,\n [classes.editLabel]: rotatedToHorizontal,\n [classes.customBottom]: isChartBottomLabel || isDefineChartBottomLabel,\n [classes.displayNone]: disabledLabel && !isChart && isEmptyString(extractTextFromHTML(text)),\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 noPadding: true,\n noBorder: true,\n }}\n disableScrollbar\n activePlugins={activePlugins}\n onDone={() => setRotatedToHorizontal(false)}\n mathMlOptions={mathMlOptions}\n charactersLimit={charactersLimit}\n />\n )}\n </div>\n </Readable>\n );\n};\nLabelComponent.propTypes = {\n classes: PropTypes.object,\n disabledLabel: PropTypes.bool,\n graphHeight: PropTypes.number,\n graphWidth: PropTypes.number,\n isChartBottomLabel: PropTypes.bool,\n isDefineChartBottomLabel: PropTypes.bool,\n isChartLeftLabel: PropTypes.bool,\n isDefineChartLeftLabel: PropTypes.bool,\n placeholder: PropTypes.string,\n text: PropTypes.string,\n side: PropTypes.string,\n onChange: PropTypes.func,\n mathMlOptions: PropTypes.object,\n charactersLimit: PropTypes.number,\n titleHeight: PropTypes.number,\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: theme.spacing.unit / 2,\n padding: `${theme.spacing.unit / 2}px 0`,\n },\n chartLabel: {\n fontSize: theme.typography.fontSize + 2,\n textAlign: 'center',\n margin: theme.spacing.unit / 2,\n padding: `${theme.spacing.unit / 2}px 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 '-webkit-transform': 'rotate(-90deg)',\n transformOrigin: '0 0',\n transformStyle: 'preserve-3d',\n position: 'absolute',\n },\n rotateRightLabel: {\n '-webkit-transform': 'rotate(90deg)',\n transformOrigin: '0 0',\n transformStyle: 'preserve-3d',\n position: 'absolute',\n },\n customBottom: {\n position: 'absolute',\n },\n displayNone: {\n display: 'none',\n },\n}))(LabelComponent);\n"],"file":"label.js"}
|
package/lib/root.js
ADDED
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = exports.Root = void 0;
|
|
9
|
+
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
+
|
|
18
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
+
|
|
20
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
|
+
|
|
22
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
|
+
|
|
24
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
+
|
|
26
|
+
var _react = _interopRequireDefault(require("react"));
|
|
27
|
+
|
|
28
|
+
var _types = require("./types");
|
|
29
|
+
|
|
30
|
+
var _styles = require("@material-ui/core/styles");
|
|
31
|
+
|
|
32
|
+
var _d3Selection = require("d3-selection");
|
|
33
|
+
|
|
34
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
35
|
+
|
|
36
|
+
var _renderUi = require("@pie-lib/render-ui");
|
|
37
|
+
|
|
38
|
+
var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
|
|
39
|
+
|
|
40
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
41
|
+
|
|
42
|
+
var _label = _interopRequireDefault(require("./label"));
|
|
43
|
+
|
|
44
|
+
var _utils = require("./utils");
|
|
45
|
+
|
|
46
|
+
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; }
|
|
47
|
+
|
|
48
|
+
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; }
|
|
49
|
+
|
|
50
|
+
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); }; }
|
|
51
|
+
|
|
52
|
+
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; } }
|
|
53
|
+
|
|
54
|
+
var Root = /*#__PURE__*/function (_React$Component) {
|
|
55
|
+
(0, _inherits2["default"])(Root, _React$Component);
|
|
56
|
+
|
|
57
|
+
var _super = _createSuper(Root);
|
|
58
|
+
|
|
59
|
+
function Root(props) {
|
|
60
|
+
var _this;
|
|
61
|
+
|
|
62
|
+
(0, _classCallCheck2["default"])(this, Root);
|
|
63
|
+
_this = _super.call(this, props);
|
|
64
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "mouseMove", function (g) {
|
|
65
|
+
var _this$props = _this.props,
|
|
66
|
+
graphProps = _this$props.graphProps,
|
|
67
|
+
onMouseMove = _this$props.onMouseMove;
|
|
68
|
+
|
|
69
|
+
if (!onMouseMove) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
var scale = graphProps.scale,
|
|
74
|
+
snap = graphProps.snap;
|
|
75
|
+
var coords = (0, _d3Selection.mouse)(g._groups[0][0]);
|
|
76
|
+
var x = scale.x.invert(coords[0]);
|
|
77
|
+
var y = scale.y.invert(coords[1]);
|
|
78
|
+
var snapped = {
|
|
79
|
+
x: snap.x(x),
|
|
80
|
+
y: snap.y(y)
|
|
81
|
+
};
|
|
82
|
+
onMouseMove(snapped);
|
|
83
|
+
});
|
|
84
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChangeLabel", function (newValue, side) {
|
|
85
|
+
var _this$props2 = _this.props,
|
|
86
|
+
labels = _this$props2.labels,
|
|
87
|
+
onChangeLabels = _this$props2.onChangeLabels,
|
|
88
|
+
isChart = _this$props2.isChart;
|
|
89
|
+
|
|
90
|
+
if (!onChangeLabels) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (isChart) {
|
|
95
|
+
if (side === 'left') {
|
|
96
|
+
onChangeLabels('range', newValue);
|
|
97
|
+
} else {
|
|
98
|
+
onChangeLabels('domain', newValue);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
onChangeLabels(_objectSpread(_objectSpread({}, labels), {}, (0, _defineProperty2["default"])({}, side, newValue)));
|
|
105
|
+
});
|
|
106
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "measureTitleHeight", function () {
|
|
107
|
+
var titleElement = document.getElementById('editable-title');
|
|
108
|
+
|
|
109
|
+
if (titleElement) {
|
|
110
|
+
var titleHeight = titleElement.clientHeight;
|
|
111
|
+
|
|
112
|
+
_this.setState({
|
|
113
|
+
titleHeight: titleHeight,
|
|
114
|
+
prevTitle: _this.props.title
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleKeyDown", function () {
|
|
119
|
+
setTimeout(_this.measureTitleHeight, 0);
|
|
120
|
+
});
|
|
121
|
+
_this.state = {
|
|
122
|
+
titleHeight: 0
|
|
123
|
+
};
|
|
124
|
+
return _this;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
(0, _createClass2["default"])(Root, [{
|
|
128
|
+
key: "componentDidMount",
|
|
129
|
+
value: function componentDidMount() {
|
|
130
|
+
var g = (0, _d3Selection.select)(this.g);
|
|
131
|
+
g.on('mousemove', this.mouseMove.bind(this, g));
|
|
132
|
+
this.measureTitleHeight();
|
|
133
|
+
}
|
|
134
|
+
}, {
|
|
135
|
+
key: "componentWillUnmount",
|
|
136
|
+
value: function componentWillUnmount() {
|
|
137
|
+
var g = (0, _d3Selection.select)(this.g);
|
|
138
|
+
g.on('mousemove', null);
|
|
139
|
+
}
|
|
140
|
+
}, {
|
|
141
|
+
key: "componentDidUpdate",
|
|
142
|
+
value: function componentDidUpdate(prevProps) {
|
|
143
|
+
if (prevProps.title !== this.props.title) {
|
|
144
|
+
this.measureTitleHeight();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}, {
|
|
148
|
+
key: "render",
|
|
149
|
+
value: function render() {
|
|
150
|
+
var _this2 = this;
|
|
151
|
+
|
|
152
|
+
var _this$props3 = this.props,
|
|
153
|
+
disabledTitle = _this$props3.disabledTitle,
|
|
154
|
+
disabledLabels = _this$props3.disabledLabels,
|
|
155
|
+
labels = _this$props3.labels,
|
|
156
|
+
labelsPlaceholders = _this$props3.labelsPlaceholders,
|
|
157
|
+
titlePlaceholder = _this$props3.titlePlaceholder,
|
|
158
|
+
graphProps = _this$props3.graphProps,
|
|
159
|
+
children = _this$props3.children,
|
|
160
|
+
classes = _this$props3.classes,
|
|
161
|
+
defineChart = _this$props3.defineChart,
|
|
162
|
+
onChangeTitle = _this$props3.onChangeTitle,
|
|
163
|
+
isChart = _this$props3.isChart,
|
|
164
|
+
showLabels = _this$props3.showLabels,
|
|
165
|
+
showPixelGuides = _this$props3.showPixelGuides,
|
|
166
|
+
showTitle = _this$props3.showTitle,
|
|
167
|
+
title = _this$props3.title,
|
|
168
|
+
rootRef = _this$props3.rootRef,
|
|
169
|
+
_this$props3$mathMlOp = _this$props3.mathMlOptions,
|
|
170
|
+
mathMlOptions = _this$props3$mathMlOp === void 0 ? {} : _this$props3$mathMlOp,
|
|
171
|
+
labelsCharactersLimit = _this$props3.labelsCharactersLimit;
|
|
172
|
+
var _graphProps$size = graphProps.size,
|
|
173
|
+
_graphProps$size$widt = _graphProps$size.width,
|
|
174
|
+
width = _graphProps$size$widt === void 0 ? 500 : _graphProps$size$widt,
|
|
175
|
+
_graphProps$size$heig = _graphProps$size.height,
|
|
176
|
+
height = _graphProps$size$heig === void 0 ? 500 : _graphProps$size$heig,
|
|
177
|
+
domain = graphProps.domain,
|
|
178
|
+
range = graphProps.range;
|
|
179
|
+
var topPadding = 40;
|
|
180
|
+
var leftPadding = (0, _utils.isEmptyString)((0, _utils.extractTextFromHTML)(labels === null || labels === void 0 ? void 0 : labels.left)) && (0, _utils.isEmptyObject)(labelsPlaceholders) ? 48 : 70;
|
|
181
|
+
var rightPadding = (0, _utils.isEmptyString)((0, _utils.extractTextFromHTML)(labels === null || labels === void 0 ? void 0 : labels.right)) && (0, _utils.isEmptyObject)(labelsPlaceholders) ? 48 : 70;
|
|
182
|
+
var finalWidth = width + leftPadding + rightPadding + (domain.padding || 0) * 2;
|
|
183
|
+
var finalHeight = height + topPadding * 2 + (range.padding || 0) * 2;
|
|
184
|
+
var activeTitlePlugins = ['bold', 'italic', 'underline', 'superscript', 'subscript', 'strikethrough', 'math' // 'languageCharacters'
|
|
185
|
+
];
|
|
186
|
+
var actualHeight = defineChart && showPixelGuides ? height - 160 : height;
|
|
187
|
+
var nbOfVerticalLines = parseInt(width / 100);
|
|
188
|
+
var nbOfHorizontalLines = parseInt(actualHeight / 100);
|
|
189
|
+
var sideGridlinesPadding = parseInt(actualHeight % 100);
|
|
190
|
+
var titleHeight = this.state.titleHeight;
|
|
191
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
192
|
+
className: classes.root
|
|
193
|
+
}, showPixelGuides && /*#__PURE__*/_react["default"].createElement("div", {
|
|
194
|
+
className: classes.topPixelGuides,
|
|
195
|
+
style: {
|
|
196
|
+
marginLeft: isChart ? 80 : showLabels ? 30 : 10
|
|
197
|
+
}
|
|
198
|
+
}, (0, _toConsumableArray2["default"])(Array(nbOfVerticalLines + 1).keys()).map(function (value) {
|
|
199
|
+
return /*#__PURE__*/_react["default"].createElement(_renderUi.Readable, {
|
|
200
|
+
"false": true,
|
|
201
|
+
key: "top-guide-".concat(value)
|
|
202
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
203
|
+
className: classes.topPixelIndicator
|
|
204
|
+
}, /*#__PURE__*/_react["default"].createElement("div", null, value * 100, "px"), /*#__PURE__*/_react["default"].createElement("div", null, "|")));
|
|
205
|
+
})), showTitle && (disabledTitle ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
206
|
+
id: "editable-title",
|
|
207
|
+
style: _objectSpread(_objectSpread({}, isChart && {
|
|
208
|
+
width: finalWidth
|
|
209
|
+
}), (0, _utils.isEmptyString)((0, _utils.extractTextFromHTML)(title)) && {
|
|
210
|
+
display: 'none'
|
|
211
|
+
}),
|
|
212
|
+
className: (0, _classnames["default"])(isChart ? classes.chartTitle : classes.graphTitle, classes.disabledTitle),
|
|
213
|
+
dangerouslySetInnerHTML: {
|
|
214
|
+
__html: title || ''
|
|
215
|
+
}
|
|
216
|
+
}) : /*#__PURE__*/_react["default"].createElement("div", {
|
|
217
|
+
id: "editable-title"
|
|
218
|
+
}, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
|
|
219
|
+
style: isChart && {
|
|
220
|
+
width: finalWidth
|
|
221
|
+
},
|
|
222
|
+
className: (0, _classnames["default"])((0, _defineProperty2["default"])({}, classes.rightMargin, showPixelGuides), isChart ? classes.chartTitle : classes.graphTitle),
|
|
223
|
+
markup: title || '',
|
|
224
|
+
onChange: onChangeTitle,
|
|
225
|
+
placeholder: defineChart && titlePlaceholder || !disabledTitle && 'Click here to add a title for this graph',
|
|
226
|
+
toolbarOpts: {
|
|
227
|
+
noPadding: true,
|
|
228
|
+
noBorder: true
|
|
229
|
+
},
|
|
230
|
+
activePlugins: activeTitlePlugins,
|
|
231
|
+
disableScrollbar: true,
|
|
232
|
+
onKeyDown: this.handleKeyDown
|
|
233
|
+
}))), showLabels && !isChart && /*#__PURE__*/_react["default"].createElement(_label["default"], {
|
|
234
|
+
side: "top",
|
|
235
|
+
text: labels.top,
|
|
236
|
+
disabledLabel: disabledLabels,
|
|
237
|
+
placeholder: labelsPlaceholders === null || labelsPlaceholders === void 0 ? void 0 : labelsPlaceholders.top,
|
|
238
|
+
graphHeight: finalHeight,
|
|
239
|
+
graphWidth: finalWidth,
|
|
240
|
+
onChange: function onChange(value) {
|
|
241
|
+
return _this2.onChangeLabel(value, 'top');
|
|
242
|
+
},
|
|
243
|
+
mathMlOptions: mathMlOptions,
|
|
244
|
+
charactersLimit: labelsCharactersLimit
|
|
245
|
+
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
246
|
+
className: classes.wrapper
|
|
247
|
+
}, showLabels && /*#__PURE__*/_react["default"].createElement(_label["default"], {
|
|
248
|
+
side: "left",
|
|
249
|
+
text: labels.left,
|
|
250
|
+
disabledLabel: disabledLabels,
|
|
251
|
+
placeholder: labelsPlaceholders === null || labelsPlaceholders === void 0 ? void 0 : labelsPlaceholders.left,
|
|
252
|
+
graphHeight: finalHeight,
|
|
253
|
+
graphWidth: finalWidth,
|
|
254
|
+
isChartLeftLabel: isChart && !defineChart,
|
|
255
|
+
isDefineChartLeftLabel: isChart && defineChart,
|
|
256
|
+
onChange: function onChange(value) {
|
|
257
|
+
return _this2.onChangeLabel(value, 'left');
|
|
258
|
+
},
|
|
259
|
+
mathMlOptions: mathMlOptions,
|
|
260
|
+
charactersLimit: labelsCharactersLimit
|
|
261
|
+
}), /*#__PURE__*/_react["default"].createElement("svg", {
|
|
262
|
+
width: finalWidth,
|
|
263
|
+
height: finalHeight,
|
|
264
|
+
className: defineChart ? classes.defineChart : classes.chart
|
|
265
|
+
}, /*#__PURE__*/_react["default"].createElement("g", {
|
|
266
|
+
ref: function ref(r) {
|
|
267
|
+
_this2.g = r;
|
|
268
|
+
|
|
269
|
+
if (rootRef) {
|
|
270
|
+
rootRef(r);
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
className: classes.graphBox,
|
|
274
|
+
transform: "translate(".concat(leftPadding + (domain.padding || 0), ", ").concat(topPadding + (range.padding || 0), ")")
|
|
275
|
+
}, children)), showLabels && !isChart && /*#__PURE__*/_react["default"].createElement(_label["default"], {
|
|
276
|
+
side: "right",
|
|
277
|
+
text: labels.right,
|
|
278
|
+
disabledLabel: disabledLabels,
|
|
279
|
+
placeholder: labelsPlaceholders === null || labelsPlaceholders === void 0 ? void 0 : labelsPlaceholders.right,
|
|
280
|
+
graphHeight: finalHeight,
|
|
281
|
+
graphWidth: finalWidth,
|
|
282
|
+
onChange: function onChange(value) {
|
|
283
|
+
return _this2.onChangeLabel(value, 'right');
|
|
284
|
+
},
|
|
285
|
+
mathMlOptions: mathMlOptions,
|
|
286
|
+
charactersLimit: labelsCharactersLimit
|
|
287
|
+
}), showPixelGuides && /*#__PURE__*/_react["default"].createElement("div", {
|
|
288
|
+
className: classes.sidePixelGuides,
|
|
289
|
+
style: {
|
|
290
|
+
paddingTop: sideGridlinesPadding,
|
|
291
|
+
marginTop: 31
|
|
292
|
+
}
|
|
293
|
+
}, (0, _toConsumableArray2["default"])(Array(nbOfHorizontalLines + 1).keys()).reverse().map(function (value) {
|
|
294
|
+
return /*#__PURE__*/_react["default"].createElement(_renderUi.Readable, {
|
|
295
|
+
"false": true,
|
|
296
|
+
key: "top-guide-".concat(value)
|
|
297
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
298
|
+
className: classes.sidePixelIndicator
|
|
299
|
+
}, "\u2501 ", value * 100, "px"));
|
|
300
|
+
}))), showLabels && /*#__PURE__*/_react["default"].createElement(_label["default"], {
|
|
301
|
+
side: "bottom",
|
|
302
|
+
text: labels.bottom,
|
|
303
|
+
disabledLabel: disabledLabels,
|
|
304
|
+
placeholder: labelsPlaceholders === null || labelsPlaceholders === void 0 ? void 0 : labelsPlaceholders.bottom,
|
|
305
|
+
graphHeight: finalHeight,
|
|
306
|
+
graphWidth: finalWidth,
|
|
307
|
+
titleHeight: titleHeight,
|
|
308
|
+
isChartBottomLabel: isChart && !defineChart,
|
|
309
|
+
isDefineChartBottomLabel: isChart && defineChart,
|
|
310
|
+
onChange: function onChange(value) {
|
|
311
|
+
return _this2.onChangeLabel(value, 'bottom');
|
|
312
|
+
},
|
|
313
|
+
mathMlOptions: mathMlOptions,
|
|
314
|
+
charactersLimit: labelsCharactersLimit
|
|
315
|
+
}));
|
|
316
|
+
}
|
|
317
|
+
}]);
|
|
318
|
+
return Root;
|
|
319
|
+
}(_react["default"].Component); // use default color theme style to avoid color contrast issues
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
exports.Root = Root;
|
|
323
|
+
(0, _defineProperty2["default"])(Root, "propTypes", {
|
|
324
|
+
title: _propTypes["default"].string,
|
|
325
|
+
children: _types.ChildrenType,
|
|
326
|
+
defineChart: _propTypes["default"].bool,
|
|
327
|
+
disabledLabels: _propTypes["default"].bool,
|
|
328
|
+
disabledTitle: _propTypes["default"].bool,
|
|
329
|
+
graphProps: _types.GraphPropsType.isRequired,
|
|
330
|
+
isChart: _propTypes["default"].bool,
|
|
331
|
+
labels: _propTypes["default"].object,
|
|
332
|
+
labelsPlaceholders: _propTypes["default"].object,
|
|
333
|
+
onChangeTitle: _propTypes["default"].func,
|
|
334
|
+
onMouseMove: _propTypes["default"].func,
|
|
335
|
+
classes: _propTypes["default"].object.isRequired,
|
|
336
|
+
showLabels: _propTypes["default"].bool,
|
|
337
|
+
showTitle: _propTypes["default"].bool,
|
|
338
|
+
showPixelGuides: _propTypes["default"].bool,
|
|
339
|
+
rootRef: _propTypes["default"].func,
|
|
340
|
+
onChangeLabels: _propTypes["default"].func,
|
|
341
|
+
titlePlaceholder: _propTypes["default"].string,
|
|
342
|
+
mathMlOptions: _propTypes["default"].object,
|
|
343
|
+
labelsCharactersLimit: _propTypes["default"].number
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
var styles = function styles(theme) {
|
|
347
|
+
return {
|
|
348
|
+
root: {
|
|
349
|
+
border: "solid 1px ".concat(_renderUi.color.primaryLight()),
|
|
350
|
+
color: _renderUi.color.defaults.TEXT,
|
|
351
|
+
backgroundColor: theme.palette.common.white,
|
|
352
|
+
touchAction: 'none',
|
|
353
|
+
position: 'relative'
|
|
354
|
+
},
|
|
355
|
+
wrapper: {
|
|
356
|
+
display: 'flex',
|
|
357
|
+
position: 'relative'
|
|
358
|
+
},
|
|
359
|
+
svg: {},
|
|
360
|
+
defineChart: {
|
|
361
|
+
paddingLeft: '50px',
|
|
362
|
+
overflow: 'visible'
|
|
363
|
+
},
|
|
364
|
+
chart: {
|
|
365
|
+
overflow: 'visible'
|
|
366
|
+
},
|
|
367
|
+
graphBox: {
|
|
368
|
+
cursor: 'pointer',
|
|
369
|
+
userSelect: 'none'
|
|
370
|
+
},
|
|
371
|
+
graphTitle: {
|
|
372
|
+
color: _renderUi.color.defaults.TEXT,
|
|
373
|
+
fontSize: theme.typography.fontSize + 2,
|
|
374
|
+
padding: "".concat(theme.spacing.unit * 1.5, "px ").concat(theme.spacing.unit / 2, "px 0"),
|
|
375
|
+
textAlign: 'center'
|
|
376
|
+
},
|
|
377
|
+
chartTitle: {
|
|
378
|
+
color: _renderUi.color.defaults.TEXT,
|
|
379
|
+
fontSize: theme.typography.fontSize + 4,
|
|
380
|
+
padding: "".concat(theme.spacing.unit * 1.5, "px ").concat(theme.spacing.unit / 2, "px 0"),
|
|
381
|
+
textAlign: 'center'
|
|
382
|
+
},
|
|
383
|
+
disabledTitle: {
|
|
384
|
+
pointerEvents: 'none'
|
|
385
|
+
},
|
|
386
|
+
rightMargin: {
|
|
387
|
+
marginRight: '74px'
|
|
388
|
+
},
|
|
389
|
+
topPixelGuides: {
|
|
390
|
+
display: 'flex',
|
|
391
|
+
paddingTop: '6px'
|
|
392
|
+
},
|
|
393
|
+
topPixelIndicator: {
|
|
394
|
+
display: 'flex',
|
|
395
|
+
flexDirection: 'column',
|
|
396
|
+
alignItems: 'center',
|
|
397
|
+
width: '100px',
|
|
398
|
+
pointerEvents: 'none',
|
|
399
|
+
userSelect: 'none'
|
|
400
|
+
},
|
|
401
|
+
sidePixelGuides: {
|
|
402
|
+
width: '70px',
|
|
403
|
+
display: 'flex',
|
|
404
|
+
flexDirection: 'column',
|
|
405
|
+
marginRight: '6px'
|
|
406
|
+
},
|
|
407
|
+
sidePixelIndicator: {
|
|
408
|
+
textAlign: 'right',
|
|
409
|
+
height: '20px',
|
|
410
|
+
pointerEvents: 'none',
|
|
411
|
+
userSelect: 'none',
|
|
412
|
+
'&:not(:last-child)': {
|
|
413
|
+
marginBottom: '80px'
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
var _default = (0, _styles.withStyles)(styles)(Root);
|
|
420
|
+
|
|
421
|
+
exports["default"] = _default;
|
|
422
|
+
//# sourceMappingURL=root.js.map
|