@pie-lib/charting 7.0.4-next.3 → 7.0.4-next.30
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/dist/_virtual/_rolldown/runtime.js +23 -0
- package/dist/actions-button.d.ts +26 -0
- package/dist/actions-button.js +84 -0
- package/dist/autosize-input.d.ts +10 -0
- package/dist/autosize-input.js +66 -0
- package/dist/axes.d.ts +84 -0
- package/dist/axes.js +376 -0
- package/dist/bars/bar.d.ts +47 -0
- package/dist/bars/bar.js +27 -0
- package/dist/bars/common/bars.d.ts +98 -0
- package/dist/bars/common/bars.js +174 -0
- package/dist/bars/common/correct-check-icon.d.ts +18 -0
- package/dist/bars/common/correct-check-icon.js +50 -0
- package/dist/bars/histogram.d.ts +47 -0
- package/dist/bars/histogram.js +28 -0
- package/dist/chart-setup.d.ts +29 -0
- package/dist/chart-setup.js +231 -0
- package/dist/chart-type.d.ts +32 -0
- package/dist/chart-type.js +68 -0
- package/dist/chart-types.d.ts +41 -0
- package/dist/chart-types.js +17 -0
- package/dist/chart.d.ts +88 -0
- package/dist/chart.js +250 -0
- package/dist/common/correctness-indicators.d.ts +70 -0
- package/dist/common/correctness-indicators.js +106 -0
- package/dist/common/drag-handle.d.ts +129 -0
- package/dist/common/drag-handle.js +120 -0
- package/dist/common/drag-icon.d.ts +23 -0
- package/dist/common/drag-icon.js +45 -0
- package/dist/common/styles.d.ts +23 -0
- package/dist/common/styles.js +17 -0
- package/dist/grid.d.ts +45 -0
- package/dist/grid.js +56 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +6 -0
- package/dist/key-legend.d.ts +19 -0
- package/dist/key-legend.js +46 -0
- package/dist/line/common/drag-handle.d.ts +120 -0
- package/dist/line/common/drag-handle.js +92 -0
- package/dist/line/common/line.d.ts +96 -0
- package/dist/line/common/line.js +114 -0
- package/dist/line/line-cross.d.ts +47 -0
- package/dist/line/line-cross.js +133 -0
- package/dist/line/line-dot.d.ts +47 -0
- package/dist/line/line-dot.js +101 -0
- package/dist/mark-label.d.ts +55 -0
- package/dist/mark-label.js +138 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Axis.js +101 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisBottom.js +46 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisLeft.js +47 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisRenderer.js +63 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Ticks.js +44 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/constants/orientation.js +9 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/createPoint.js +14 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getAxisRangePaddingConfig.js +21 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getLabelTransform.js +16 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getTickFormatter.js +8 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getTickPosition.js +15 -0
- package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/GridColumns.js +79 -0
- package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/GridRows.js +79 -0
- package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/utils/getScaleBandwidth.js +6 -0
- package/dist/node_modules/.bun/@visx_group@3.12.0_f4eacebf2041cd4f/node_modules/@visx/group/esm/Group.js +50 -0
- package/dist/node_modules/.bun/@visx_point@3.12.0/node_modules/@visx/point/esm/Point.js +18 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/align.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/base.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/clamp.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/constant.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/domain.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/exponent.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/interpolate.js +10 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/nice.js +37 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/padding.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/range.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/reverse.js +9 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/round.js +7 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/scaleOperator.js +58 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/unknown.js +6 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/zero.js +9 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/scales/band.js +9 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/scales/point.js +9 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/coerceNumber.js +10 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/createColorInterpolator.js +29 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/getTicks.js +9 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/isUtcScale.js +7 -0
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/toString.js +6 -0
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/Bar.js +29 -0
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/Circle.js +29 -0
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/Line.js +47 -0
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/LinePath.js +50 -0
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/util/D3ShapeFactories.js +9 -0
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/util/setNumberOrNumberAccessor.js +6 -0
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/lib/shapes/Line.js +53 -0
- package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/Text.js +57 -0
- package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/hooks/useText.js +91 -0
- package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/util/getStringWidth.js +21 -0
- package/dist/node_modules/.bun/@visx_vendor@3.12.0/node_modules/@visx/vendor/esm/d3-interpolate.js +8 -0
- package/dist/node_modules/.bun/@visx_vendor@3.12.0/node_modules/@visx/vendor/esm/d3-scale.js +8 -0
- package/dist/node_modules/.bun/@visx_vendor@3.12.0/node_modules/@visx/vendor/esm/d3-time.js +8 -0
- package/dist/node_modules/.bun/balanced-match@0.4.2/node_modules/balanced-match/index.js +32 -0
- package/dist/node_modules/.bun/balanced-match@1.0.2/node_modules/balanced-match/index.js +33 -0
- package/dist/node_modules/.bun/classnames@2.5.1/node_modules/classnames/index.js +32 -0
- package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +16 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_Hash.js +21 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_ListCache.js +21 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_Map.js +10 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_MapCache.js +21 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_Symbol.js +9 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_assocIndexOf.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_baseGetTag.js +15 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_baseIsNative.js +16 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_coreJsData.js +9 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_freeGlobal.js +8 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getMapData.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getNative.js +15 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getRawTag.js +19 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getValue.js +11 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashClear.js +13 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashDelete.js +12 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashGet.js +18 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashHas.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashSet.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_isKeyable.js +12 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_isMasked.js +16 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheClear.js +11 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheDelete.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheGet.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheHas.js +13 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheSet.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheClear.js +19 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheDelete.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheGet.js +13 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheHas.js +13 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheSet.js +14 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_nativeCreate.js +9 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_objectToString.js +12 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_root.js +10 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_toSource.js +20 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/eq.js +11 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/isFunction.js +16 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/isObject.js +12 -0
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/memoize.js +20 -0
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/formula_evaluator.js +37 -0
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/lexer.js +509 -0
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/math_function.js +108 -0
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix.js +31 -0
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix_evaluator.js +45 -0
- package/dist/node_modules/.bun/reduce-css-calc@1.3.0/node_modules/reduce-css-calc/index.js +49 -0
- package/dist/node_modules/.bun/reduce-function-call@1.0.3/node_modules/reduce-function-call/index.js +34 -0
- package/dist/plot/common/plot.d.ts +103 -0
- package/dist/plot/common/plot.js +227 -0
- package/dist/plot/dot.d.ts +47 -0
- package/dist/plot/dot.js +62 -0
- package/dist/plot/line.d.ts +47 -0
- package/dist/plot/line.js +84 -0
- package/dist/tool-menu.d.ts +31 -0
- package/dist/utils.d.ts +39 -0
- package/dist/utils.js +101 -0
- package/package.json +39 -28
- package/CHANGELOG.json +0 -17
- package/CHANGELOG.md +0 -1116
- package/LICENSE.md +0 -5
- package/lib/actions-button.js +0 -145
- package/lib/actions-button.js.map +0 -1
- package/lib/axes.js +0 -643
- package/lib/axes.js.map +0 -1
- package/lib/bars/bar.js +0 -58
- package/lib/bars/bar.js.map +0 -1
- package/lib/bars/common/bars.js +0 -277
- package/lib/bars/common/bars.js.map +0 -1
- package/lib/bars/common/correct-check-icon.js +0 -54
- package/lib/bars/common/correct-check-icon.js.map +0 -1
- package/lib/bars/histogram.js +0 -59
- package/lib/bars/histogram.js.map +0 -1
- package/lib/chart-setup.js +0 -382
- package/lib/chart-setup.js.map +0 -1
- package/lib/chart-type.js +0 -80
- package/lib/chart-type.js.map +0 -1
- package/lib/chart-types.js +0 -22
- package/lib/chart-types.js.map +0 -1
- package/lib/chart.js +0 -384
- package/lib/chart.js.map +0 -1
- package/lib/common/correctness-indicators.js +0 -156
- package/lib/common/correctness-indicators.js.map +0 -1
- package/lib/common/drag-handle.js +0 -160
- package/lib/common/drag-handle.js.map +0 -1
- package/lib/common/drag-icon.js +0 -52
- package/lib/common/drag-icon.js.map +0 -1
- package/lib/common/styles.js +0 -22
- package/lib/common/styles.js.map +0 -1
- package/lib/grid.js +0 -112
- package/lib/grid.js.map +0 -1
- package/lib/index.js +0 -42
- package/lib/index.js.map +0 -1
- package/lib/key-legend.js +0 -87
- package/lib/key-legend.js.map +0 -1
- package/lib/line/common/drag-handle.js +0 -146
- package/lib/line/common/drag-handle.js.map +0 -1
- package/lib/line/common/line.js +0 -214
- package/lib/line/common/line.js.map +0 -1
- package/lib/line/line-cross.js +0 -214
- package/lib/line/line-cross.js.map +0 -1
- package/lib/line/line-dot.js +0 -158
- package/lib/line/line-dot.js.map +0 -1
- package/lib/mark-label.js +0 -237
- package/lib/mark-label.js.map +0 -1
- package/lib/plot/common/plot.js +0 -349
- package/lib/plot/common/plot.js.map +0 -1
- package/lib/plot/dot.js +0 -110
- package/lib/plot/dot.js.map +0 -1
- package/lib/plot/line.js +0 -140
- package/lib/plot/line.js.map +0 -1
- package/lib/tool-menu.js +0 -106
- package/lib/tool-menu.js.map +0 -1
- package/lib/utils.js +0 -189
- package/lib/utils.js.map +0 -1
- package/src/__tests__/actions-button.test.jsx +0 -280
- package/src/__tests__/axes.test.jsx +0 -667
- package/src/__tests__/chart-setup.test.jsx +0 -532
- package/src/__tests__/chart-type.test.jsx +0 -23
- package/src/__tests__/chart.test.jsx +0 -86
- package/src/__tests__/grid.test.jsx +0 -37
- package/src/__tests__/key-legend.test.jsx +0 -223
- package/src/__tests__/mark-label.test.jsx +0 -33
- package/src/__tests__/tool-menu.test.jsx +0 -522
- package/src/__tests__/utils.js +0 -36
- package/src/__tests__/utils.test.js +0 -100
- package/src/actions-button.jsx +0 -115
- package/src/axes.jsx +0 -594
- package/src/bars/__tests__/bar.test.jsx +0 -45
- package/src/bars/__tests__/histogram.test.jsx +0 -45
- package/src/bars/__tests__/utils.js +0 -30
- package/src/bars/bar.js +0 -28
- package/src/bars/common/__tests__/bars.test.jsx +0 -68
- package/src/bars/common/__tests__/utils.js +0 -30
- package/src/bars/common/bars.jsx +0 -249
- package/src/bars/common/correct-check-icon.jsx +0 -25
- package/src/bars/histogram.js +0 -28
- package/src/chart-setup.jsx +0 -356
- package/src/chart-type.js +0 -59
- package/src/chart-types.js +0 -8
- package/src/chart.jsx +0 -357
- package/src/common/__tests__/correctness-indicators.test.jsx +0 -720
- package/src/common/__tests__/drag-handle.test.jsx +0 -58
- package/src/common/__tests__/utils.js +0 -30
- package/src/common/correctness-indicators.jsx +0 -128
- package/src/common/drag-handle.jsx +0 -125
- package/src/common/drag-icon.jsx +0 -36
- package/src/common/styles.js +0 -19
- package/src/grid.jsx +0 -80
- package/src/index.js +0 -7
- package/src/key-legend.jsx +0 -77
- package/src/line/__tests__/line-cross.test.jsx +0 -463
- package/src/line/__tests__/line-dot.test.jsx +0 -41
- package/src/line/__tests__/utils.js +0 -36
- package/src/line/common/__tests__/drag-handle.test.jsx +0 -62
- package/src/line/common/__tests__/line.test.jsx +0 -79
- package/src/line/common/__tests__/utils.js +0 -30
- package/src/line/common/drag-handle.jsx +0 -114
- package/src/line/common/line.jsx +0 -171
- package/src/line/line-cross.js +0 -144
- package/src/line/line-dot.js +0 -111
- package/src/mark-label.jsx +0 -238
- package/src/plot/__tests__/dot.test.jsx +0 -344
- package/src/plot/__tests__/line.test.jsx +0 -375
- package/src/plot/__tests__/utils.js +0 -30
- package/src/plot/common/__tests__/plot.test.jsx +0 -69
- package/src/plot/common/__tests__/utils.js +0 -30
- package/src/plot/common/plot.jsx +0 -358
- package/src/plot/dot.js +0 -74
- package/src/plot/line.js +0 -98
- package/src/tool-menu.jsx +0 -85
- package/src/utils.js +0 -201
package/src/actions-button.jsx
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { styled } from '@mui/material/styles';
|
|
4
|
-
import Button from '@mui/material/Button';
|
|
5
|
-
import Popover from '@mui/material/Popover';
|
|
6
|
-
import Paper from '@mui/material/Paper';
|
|
7
|
-
|
|
8
|
-
import { color } from '@pie-lib/render-ui';
|
|
9
|
-
import Translator from '@pie-lib/translator';
|
|
10
|
-
|
|
11
|
-
const { translator } = Translator;
|
|
12
|
-
|
|
13
|
-
const StyledActions = styled('div')(() => ({
|
|
14
|
-
alignSelf: 'flex-end',
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
const StyledTrigger = styled('div')(({ theme }) => ({
|
|
18
|
-
cursor: 'pointer',
|
|
19
|
-
fontSize: theme.typography.fontSize,
|
|
20
|
-
color: color.tertiary(),
|
|
21
|
-
padding: theme.spacing(1),
|
|
22
|
-
}));
|
|
23
|
-
|
|
24
|
-
const StyledActionsPaper = styled(Paper)(({ theme }) => ({
|
|
25
|
-
padding: theme.spacing(1),
|
|
26
|
-
display: 'flex',
|
|
27
|
-
flexDirection: 'column',
|
|
28
|
-
gap: theme.spacing(1),
|
|
29
|
-
'& button': {
|
|
30
|
-
textTransform: 'none',
|
|
31
|
-
fontSize: theme.typography.fontSize,
|
|
32
|
-
color: color.text(),
|
|
33
|
-
justifyContent: 'flex-start',
|
|
34
|
-
},
|
|
35
|
-
}));
|
|
36
|
-
|
|
37
|
-
export class ActionsButton extends React.Component {
|
|
38
|
-
constructor(props) {
|
|
39
|
-
super(props);
|
|
40
|
-
this.state = {
|
|
41
|
-
actionsAnchorEl: null,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
componentWillUnmount() {
|
|
46
|
-
this.setState({ actionsAnchorEl: null });
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
static propTypes = {
|
|
50
|
-
addCategory: PropTypes.func.isRequired,
|
|
51
|
-
deleteCategory: PropTypes.func.isRequired,
|
|
52
|
-
language: PropTypes.string,
|
|
53
|
-
categories: PropTypes.array,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
handleActionsClick = (event) => {
|
|
57
|
-
this.setState({ actionsAnchorEl: event.currentTarget });
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
handleActionsClose = () => {
|
|
61
|
-
this.setState({ actionsAnchorEl: null });
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
handleAddCategory = () => {
|
|
65
|
-
const { addCategory } = this.props;
|
|
66
|
-
addCategory();
|
|
67
|
-
this.handleActionsClose();
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
handleDeleteCategory = (index) => {
|
|
71
|
-
const { deleteCategory } = this.props;
|
|
72
|
-
deleteCategory(index);
|
|
73
|
-
this.handleActionsClose();
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
render() {
|
|
77
|
-
const { categories, language } = this.props;
|
|
78
|
-
const { actionsAnchorEl } = this.state;
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<StyledActions>
|
|
82
|
-
<StyledTrigger role="button" tabIndex={0} onClick={this.handleActionsClick}>
|
|
83
|
-
Actions
|
|
84
|
-
</StyledTrigger>
|
|
85
|
-
<Popover
|
|
86
|
-
key={`actions-popover-${Math.random()}`}
|
|
87
|
-
open={Boolean(actionsAnchorEl)}
|
|
88
|
-
anchorEl={actionsAnchorEl}
|
|
89
|
-
onClose={this.handleActionsClose}
|
|
90
|
-
anchorOrigin={{ vertical: 'bottom', horizontal: 'left' }}
|
|
91
|
-
transformOrigin={{ vertical: 'top', horizontal: 'left' }}
|
|
92
|
-
>
|
|
93
|
-
<StyledActionsPaper>
|
|
94
|
-
<Button onClick={() => this.handleAddCategory()}>
|
|
95
|
-
+ {translator.t('charting.add', { lng: language })}
|
|
96
|
-
</Button>
|
|
97
|
-
{categories.length > 0 &&
|
|
98
|
-
categories.map(
|
|
99
|
-
(category, index) =>
|
|
100
|
-
category.deletable &&
|
|
101
|
-
!category.correctness && (
|
|
102
|
-
<Button key={index} onClick={() => this.handleDeleteCategory(index)}>
|
|
103
|
-
{`${translator.t('charting.delete', { lng: language })} <${category.label ||
|
|
104
|
-
translator.t('charting.newLabel', { lng: language })}>`}
|
|
105
|
-
</Button>
|
|
106
|
-
),
|
|
107
|
-
)}
|
|
108
|
-
</StyledActionsPaper>
|
|
109
|
-
</Popover>
|
|
110
|
-
</StyledActions>
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export default ActionsButton;
|
package/src/axes.jsx
DELETED
|
@@ -1,594 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { styled } from '@mui/material/styles';
|
|
4
|
-
import { AxisBottom, AxisLeft } from '@visx/axis';
|
|
5
|
-
import Checkbox from '@mui/material/Checkbox';
|
|
6
|
-
|
|
7
|
-
import { types } from '@pie-lib/plot';
|
|
8
|
-
import { color } from '@pie-lib/render-ui';
|
|
9
|
-
import { AlertDialog } from '@pie-lib/config-ui';
|
|
10
|
-
import { renderMath } from '@pie-lib/math-rendering';
|
|
11
|
-
|
|
12
|
-
import { TickCorrectnessIndicator } from './common/correctness-indicators';
|
|
13
|
-
import { bandKey, getRotateAngle, getTickValues } from './utils';
|
|
14
|
-
import MarkLabel from './mark-label';
|
|
15
|
-
|
|
16
|
-
// one document-level MutationObserver shared across all
|
|
17
|
-
// RawChartAxes instances so that no chart misses a MathJax render batch
|
|
18
|
-
const _mathCallbacks = new Set();
|
|
19
|
-
let _docObserver = null;
|
|
20
|
-
|
|
21
|
-
function registerMathCallback(cb) {
|
|
22
|
-
_mathCallbacks.add(cb);
|
|
23
|
-
|
|
24
|
-
if (!_docObserver && typeof document !== 'undefined') {
|
|
25
|
-
_docObserver = new MutationObserver(() => {
|
|
26
|
-
_mathCallbacks.forEach((fn) => fn());
|
|
27
|
-
});
|
|
28
|
-
_docObserver.observe(document.body, { childList: true, subtree: true });
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function unregisterMathCallback(cb) {
|
|
33
|
-
_mathCallbacks.delete(cb);
|
|
34
|
-
|
|
35
|
-
if (_mathCallbacks.size === 0 && _docObserver) {
|
|
36
|
-
_docObserver.disconnect();
|
|
37
|
-
_docObserver = null;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const StyledErrorText = styled('text')(({ theme }) => ({
|
|
42
|
-
fontSize: theme.typography.fontSize - 2,
|
|
43
|
-
fill: theme.palette.error.main,
|
|
44
|
-
}));
|
|
45
|
-
|
|
46
|
-
const StyledCheckbox = styled(Checkbox)(() => ({
|
|
47
|
-
color: `${color.tertiary()} !important`,
|
|
48
|
-
}));
|
|
49
|
-
|
|
50
|
-
const StyledAxesGroup = styled('g')(({ theme }) => ({
|
|
51
|
-
'& .vx-axis-line': {
|
|
52
|
-
stroke: color.visualElementsColors.AXIS_LINE_COLOR,
|
|
53
|
-
strokeWidth: 2,
|
|
54
|
-
},
|
|
55
|
-
'& .vx-axis-tick': {
|
|
56
|
-
fill: color.visualElementsColors.AXIS_TICK_COLOR,
|
|
57
|
-
'& line': {
|
|
58
|
-
stroke: color.visualElementsColors.AXIS_TICK_COLOR,
|
|
59
|
-
strokeWidth: 2,
|
|
60
|
-
},
|
|
61
|
-
fontFamily: theme.typography.body1?.fontFamily,
|
|
62
|
-
fontSize: theme.typography.fontSize,
|
|
63
|
-
textAnchor: 'middle',
|
|
64
|
-
},
|
|
65
|
-
}));
|
|
66
|
-
|
|
67
|
-
const correctnessIconStyles = (theme) => ({
|
|
68
|
-
borderRadius: theme.spacing(2),
|
|
69
|
-
color: color.defaults.WHITE,
|
|
70
|
-
fontSize: '16px',
|
|
71
|
-
width: '16px',
|
|
72
|
-
height: '16px',
|
|
73
|
-
padding: '2px',
|
|
74
|
-
border: `1px solid ${color.defaults.WHITE}`,
|
|
75
|
-
boxSizing: 'unset', // to override the default border-box in IBX
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
const incorrectIconStyles = {
|
|
79
|
-
backgroundColor: color.incorrectWithIcon(),
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const correctIconStyles = {
|
|
83
|
-
backgroundColor: color.correct(),
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export class TickComponent extends React.Component {
|
|
87
|
-
static propTypes = {
|
|
88
|
-
defineChart: PropTypes.bool,
|
|
89
|
-
error: PropTypes.any,
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
constructor(props) {
|
|
93
|
-
super(props);
|
|
94
|
-
this.state = {
|
|
95
|
-
dialog: {
|
|
96
|
-
open: false,
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
componentDidUpdate(prevProps) {
|
|
102
|
-
if (this.props.autoFocus && !prevProps.autoFocus) {
|
|
103
|
-
this.props.onAutoFocusUsed();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
handleAlertDialog = (open, callback) =>
|
|
108
|
-
this.setState(
|
|
109
|
-
{
|
|
110
|
-
dialog: { open },
|
|
111
|
-
},
|
|
112
|
-
callback,
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
changeCategory = (index, newLabel) => {
|
|
116
|
-
const { categories, onChangeCategory } = this.props;
|
|
117
|
-
const category = categories[index];
|
|
118
|
-
|
|
119
|
-
onChangeCategory(index, { ...category, label: newLabel });
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
changeInteractive = (index, value) => {
|
|
123
|
-
const { categories, onChangeCategory } = this.props;
|
|
124
|
-
const category = categories[index];
|
|
125
|
-
|
|
126
|
-
if (!value) {
|
|
127
|
-
this.setState({
|
|
128
|
-
dialog: {
|
|
129
|
-
open: true,
|
|
130
|
-
title: 'Warning',
|
|
131
|
-
text: 'This will remove the correct answer value that has been defined for this category.',
|
|
132
|
-
onConfirm: () =>
|
|
133
|
-
this.handleAlertDialog(false, onChangeCategory(index, { ...category, interactive: !category.interactive })),
|
|
134
|
-
onClose: () => this.handleAlertDialog(false),
|
|
135
|
-
},
|
|
136
|
-
});
|
|
137
|
-
} else {
|
|
138
|
-
onChangeCategory(index, { ...category, interactive: !category.interactive });
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
changeEditable = (index, value) => {
|
|
143
|
-
const { categories, onChangeCategory } = this.props;
|
|
144
|
-
const category = categories[index];
|
|
145
|
-
|
|
146
|
-
if (!value) {
|
|
147
|
-
this.setState({
|
|
148
|
-
dialog: {
|
|
149
|
-
open: true,
|
|
150
|
-
title: 'Warning',
|
|
151
|
-
text: 'This will remove the correct answer category name that has been defined for this category.',
|
|
152
|
-
onConfirm: () =>
|
|
153
|
-
this.handleAlertDialog(
|
|
154
|
-
false,
|
|
155
|
-
onChangeCategory(index, { ...category, editable: !category.editable || false }),
|
|
156
|
-
),
|
|
157
|
-
onClose: () => this.handleAlertDialog(false),
|
|
158
|
-
},
|
|
159
|
-
});
|
|
160
|
-
} else {
|
|
161
|
-
onChangeCategory(index, { ...category, editable: !category.editable || false });
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
splitText = (text, maxChar) => {
|
|
166
|
-
let chunks = [];
|
|
167
|
-
while ((text || '').length > 0) {
|
|
168
|
-
let indexToSplit;
|
|
169
|
-
if (text.length > maxChar) {
|
|
170
|
-
indexToSplit = text.lastIndexOf(' ', maxChar);
|
|
171
|
-
if (indexToSplit === -1) {
|
|
172
|
-
indexToSplit = maxChar;
|
|
173
|
-
}
|
|
174
|
-
} else {
|
|
175
|
-
indexToSplit = text.length;
|
|
176
|
-
}
|
|
177
|
-
chunks.push(text.substring(0, indexToSplit));
|
|
178
|
-
text = text.substring(indexToSplit).trim();
|
|
179
|
-
}
|
|
180
|
-
return chunks;
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
render() {
|
|
184
|
-
const {
|
|
185
|
-
categories,
|
|
186
|
-
xBand,
|
|
187
|
-
bandWidth,
|
|
188
|
-
barWidth,
|
|
189
|
-
rotate,
|
|
190
|
-
top,
|
|
191
|
-
graphProps,
|
|
192
|
-
defineChart,
|
|
193
|
-
chartingOptions,
|
|
194
|
-
x,
|
|
195
|
-
y,
|
|
196
|
-
formattedValue,
|
|
197
|
-
changeInteractiveEnabled,
|
|
198
|
-
changeEditableEnabled,
|
|
199
|
-
error,
|
|
200
|
-
autoFocus,
|
|
201
|
-
hiddenLabelRef,
|
|
202
|
-
showCorrectness,
|
|
203
|
-
} = this.props;
|
|
204
|
-
|
|
205
|
-
if (!formattedValue) {
|
|
206
|
-
return null;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// Create classes object for TickCorrectnessIndicator compatibility
|
|
210
|
-
const classes = {
|
|
211
|
-
correctnessIcon: correctnessIconStyles,
|
|
212
|
-
incorrectIcon: incorrectIconStyles,
|
|
213
|
-
correctIcon: correctIconStyles,
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
const { dialog } = this.state;
|
|
217
|
-
const { changeEditable, changeInteractive } = chartingOptions || {};
|
|
218
|
-
const index = parseInt(formattedValue.split('-')[0], 10);
|
|
219
|
-
const category = categories[index];
|
|
220
|
-
const { editable, interactive, label, correctness } = category || {};
|
|
221
|
-
const barX = xBand(bandKey({ label }, index));
|
|
222
|
-
const longestCategory = (categories || []).reduce(
|
|
223
|
-
(a, b) => {
|
|
224
|
-
const lengthA = a && a.label ? a.label.length : 0;
|
|
225
|
-
const lengthB = b && b.label ? b.label.length : 0;
|
|
226
|
-
|
|
227
|
-
return lengthA > lengthB ? a : b;
|
|
228
|
-
},
|
|
229
|
-
{ label: '' },
|
|
230
|
-
);
|
|
231
|
-
const distinctMessages = error ? [...new Set(Object.values(error))].join(' ') : '';
|
|
232
|
-
|
|
233
|
-
return (
|
|
234
|
-
<g>
|
|
235
|
-
<foreignObject
|
|
236
|
-
x={bandWidth ? barX : x - barWidth / 2}
|
|
237
|
-
y={18}
|
|
238
|
-
width={barWidth}
|
|
239
|
-
height={4}
|
|
240
|
-
style={{ pointerEvents: 'none', overflow: 'visible' }}
|
|
241
|
-
>
|
|
242
|
-
{index === 0 && (
|
|
243
|
-
<MarkLabel
|
|
244
|
-
isHiddenLabel={true}
|
|
245
|
-
inputRef={hiddenLabelRef}
|
|
246
|
-
disabled={true}
|
|
247
|
-
mark={longestCategory}
|
|
248
|
-
graphProps={graphProps}
|
|
249
|
-
barWidth={barWidth}
|
|
250
|
-
/>
|
|
251
|
-
)}
|
|
252
|
-
|
|
253
|
-
<MarkLabel
|
|
254
|
-
autoFocus={defineChart && autoFocus}
|
|
255
|
-
inputRef={(r) => (this.input = r)}
|
|
256
|
-
disabled={!defineChart && !editable}
|
|
257
|
-
mark={category}
|
|
258
|
-
graphProps={graphProps}
|
|
259
|
-
onChange={(newLabel) => this.changeCategory(index, newLabel)}
|
|
260
|
-
barWidth={barWidth}
|
|
261
|
-
rotate={rotate}
|
|
262
|
-
correctness={correctness}
|
|
263
|
-
error={error && error[index]}
|
|
264
|
-
limitCharacters
|
|
265
|
-
correctnessIndicator={
|
|
266
|
-
showCorrectness &&
|
|
267
|
-
correctness && (
|
|
268
|
-
<TickCorrectnessIndicator correctness={correctness} interactive={interactive} classes={classes} />
|
|
269
|
-
)
|
|
270
|
-
}
|
|
271
|
-
/>
|
|
272
|
-
</foreignObject>
|
|
273
|
-
|
|
274
|
-
{error && index === 0 && (
|
|
275
|
-
<StyledErrorText y={y + 23} height={6} textAnchor="start">
|
|
276
|
-
{distinctMessages}
|
|
277
|
-
</StyledErrorText>
|
|
278
|
-
)}
|
|
279
|
-
|
|
280
|
-
{defineChart && index === 0 && (
|
|
281
|
-
<svg
|
|
282
|
-
x={-55}
|
|
283
|
-
style={{
|
|
284
|
-
overflow: 'visible',
|
|
285
|
-
}}
|
|
286
|
-
>
|
|
287
|
-
{changeInteractiveEnabled && (
|
|
288
|
-
<text
|
|
289
|
-
y={y + 90 + top}
|
|
290
|
-
width={barWidth}
|
|
291
|
-
height={4}
|
|
292
|
-
style={{
|
|
293
|
-
position: 'absolute',
|
|
294
|
-
pointerEvents: 'none',
|
|
295
|
-
wordBreak: 'break-word',
|
|
296
|
-
maxWidth: barWidth,
|
|
297
|
-
display: 'inline-block',
|
|
298
|
-
}}
|
|
299
|
-
>
|
|
300
|
-
{this.splitText(changeInteractive?.authoringLabel, 20).map((word, index) => (
|
|
301
|
-
<tspan key={index} x="0" dy={`${index > 0 ? '1.2em' : '.6em'}`}>
|
|
302
|
-
{word}
|
|
303
|
-
</tspan>
|
|
304
|
-
))}
|
|
305
|
-
</text>
|
|
306
|
-
)}
|
|
307
|
-
|
|
308
|
-
{changeEditableEnabled && (
|
|
309
|
-
<text
|
|
310
|
-
y={y + 145 + top}
|
|
311
|
-
width={barWidth}
|
|
312
|
-
height={4}
|
|
313
|
-
style={{
|
|
314
|
-
position: 'absolute',
|
|
315
|
-
pointerEvents: 'none',
|
|
316
|
-
wordBreak: 'break-word',
|
|
317
|
-
maxWidth: barWidth,
|
|
318
|
-
display: 'inline-block',
|
|
319
|
-
}}
|
|
320
|
-
>
|
|
321
|
-
{this.splitText(changeEditable?.authoringLabel, 20).map((word, index) => (
|
|
322
|
-
<tspan key={index} x="0" dy={`${index > 0 ? '1.2em' : '.6em'}`}>
|
|
323
|
-
{word}
|
|
324
|
-
</tspan>
|
|
325
|
-
))}
|
|
326
|
-
</text>
|
|
327
|
-
)}
|
|
328
|
-
</svg>
|
|
329
|
-
)}
|
|
330
|
-
|
|
331
|
-
{defineChart && changeInteractiveEnabled && (
|
|
332
|
-
<foreignObject
|
|
333
|
-
x={x - 24}
|
|
334
|
-
y={y + 80 + top}
|
|
335
|
-
width={barWidth}
|
|
336
|
-
height={4}
|
|
337
|
-
style={{ pointerEvents: 'visible', overflow: 'visible' }}
|
|
338
|
-
>
|
|
339
|
-
<StyledCheckbox
|
|
340
|
-
style={{ position: 'fixed' }}
|
|
341
|
-
checked={interactive}
|
|
342
|
-
onChange={(e) => this.changeInteractive(index, e.target.checked)}
|
|
343
|
-
/>
|
|
344
|
-
</foreignObject>
|
|
345
|
-
)}
|
|
346
|
-
|
|
347
|
-
{defineChart && changeEditableEnabled && (
|
|
348
|
-
<foreignObject
|
|
349
|
-
x={x - 24}
|
|
350
|
-
y={y + 130 + top}
|
|
351
|
-
width={barWidth}
|
|
352
|
-
height={4}
|
|
353
|
-
style={{ pointerEvents: 'visible', overflow: 'visible' }}
|
|
354
|
-
>
|
|
355
|
-
<StyledCheckbox
|
|
356
|
-
style={{ position: 'fixed' }}
|
|
357
|
-
checked={editable}
|
|
358
|
-
onChange={(e) => this.changeEditable(index, e.target.checked)}
|
|
359
|
-
/>
|
|
360
|
-
</foreignObject>
|
|
361
|
-
)}
|
|
362
|
-
|
|
363
|
-
<foreignObject
|
|
364
|
-
x={x - 24}
|
|
365
|
-
y={y + 100 + top}
|
|
366
|
-
width={barWidth}
|
|
367
|
-
height={4}
|
|
368
|
-
style={{ pointerEvents: 'visible', overflow: 'visible' }}
|
|
369
|
-
>
|
|
370
|
-
<AlertDialog
|
|
371
|
-
open={dialog.open}
|
|
372
|
-
title={dialog.title}
|
|
373
|
-
text={dialog.text}
|
|
374
|
-
onClose={dialog.onClose}
|
|
375
|
-
onConfirm={dialog.onConfirm}
|
|
376
|
-
/>
|
|
377
|
-
</foreignObject>
|
|
378
|
-
</g>
|
|
379
|
-
);
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
TickComponent.propTypes = {
|
|
384
|
-
categories: PropTypes.array,
|
|
385
|
-
xBand: PropTypes.func,
|
|
386
|
-
bandWidth: PropTypes.number,
|
|
387
|
-
barWidth: PropTypes.number,
|
|
388
|
-
rotate: PropTypes.number,
|
|
389
|
-
top: PropTypes.number,
|
|
390
|
-
x: PropTypes.number,
|
|
391
|
-
y: PropTypes.number,
|
|
392
|
-
graphProps: PropTypes.object,
|
|
393
|
-
formattedValue: PropTypes.string,
|
|
394
|
-
onChangeCategory: PropTypes.func,
|
|
395
|
-
onChange: PropTypes.func,
|
|
396
|
-
error: PropTypes.object,
|
|
397
|
-
defineChart: PropTypes.bool,
|
|
398
|
-
chartingOptions: PropTypes.object,
|
|
399
|
-
changeInteractiveEnabled: PropTypes.bool,
|
|
400
|
-
changeEditableEnabled: PropTypes.bool,
|
|
401
|
-
autoFocus: PropTypes.bool,
|
|
402
|
-
onAutoFocusUsed: PropTypes.func,
|
|
403
|
-
showCorrectness: PropTypes.bool,
|
|
404
|
-
hiddenLabelRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.instanceOf(Element) })]),
|
|
405
|
-
};
|
|
406
|
-
|
|
407
|
-
export class RawChartAxes extends React.Component {
|
|
408
|
-
static propTypes = {
|
|
409
|
-
bottomScale: PropTypes.func,
|
|
410
|
-
categories: PropTypes.array,
|
|
411
|
-
defineChart: PropTypes.bool,
|
|
412
|
-
error: PropTypes.any,
|
|
413
|
-
graphProps: types.GraphPropsType.isRequired,
|
|
414
|
-
xBand: PropTypes.func,
|
|
415
|
-
leftAxis: PropTypes.bool,
|
|
416
|
-
onChange: PropTypes.func,
|
|
417
|
-
onChangeCategory: PropTypes.func,
|
|
418
|
-
top: PropTypes.number,
|
|
419
|
-
theme: PropTypes.object,
|
|
420
|
-
chartingOptions: PropTypes.object,
|
|
421
|
-
changeInteractiveEnabled: PropTypes.bool,
|
|
422
|
-
changeEditableEnabled: PropTypes.bool,
|
|
423
|
-
autoFocus: PropTypes.bool,
|
|
424
|
-
onAutoFocusUsed: PropTypes.func,
|
|
425
|
-
showCorrectness: PropTypes.bool,
|
|
426
|
-
hiddenLabelRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({ current: PropTypes.instanceOf(Element) })]),
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
state = { height: 0, width: 0 };
|
|
430
|
-
|
|
431
|
-
measureHiddenLabel = () => {
|
|
432
|
-
if (!this.hiddenLabelRef) return;
|
|
433
|
-
|
|
434
|
-
const mjx = this.hiddenLabelRef.querySelector('mjx-container');
|
|
435
|
-
const input = this.hiddenLabelRef.querySelector('input');
|
|
436
|
-
const target = mjx || input || this.hiddenLabelRef;
|
|
437
|
-
const rect = target.getBoundingClientRect();
|
|
438
|
-
const height = Math.floor(rect.height);
|
|
439
|
-
const width = Math.floor(rect.width);
|
|
440
|
-
|
|
441
|
-
if (height !== this.state.height || width !== this.state.width) {
|
|
442
|
-
this.setState({ height, width });
|
|
443
|
-
}
|
|
444
|
-
};
|
|
445
|
-
|
|
446
|
-
// called by the document-level observer on every DOM mutation.
|
|
447
|
-
// only re-measures once mjx-container is present in our hidden label.
|
|
448
|
-
_onDocMutation = () => {
|
|
449
|
-
if (!this.hiddenLabelRef) return;
|
|
450
|
-
if (this.hiddenLabelRef.querySelector('mjx-container')) {
|
|
451
|
-
this.measureHiddenLabel();
|
|
452
|
-
}
|
|
453
|
-
};
|
|
454
|
-
|
|
455
|
-
observeHiddenLabel = (el) => {
|
|
456
|
-
if (!el) return;
|
|
457
|
-
|
|
458
|
-
const containsLatex = el.querySelector('[data-latex], [data-raw]');
|
|
459
|
-
|
|
460
|
-
if (containsLatex) {
|
|
461
|
-
renderMath(el);
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
if (el.querySelector('mjx-container') || !containsLatex) {
|
|
465
|
-
this.measureHiddenLabel();
|
|
466
|
-
}
|
|
467
|
-
// always register: if mjx-container isn't there yet, the doc observer will
|
|
468
|
-
// call _onDocMutation when MathJax finishes rendering any element on the page.
|
|
469
|
-
registerMathCallback(this._onDocMutation);
|
|
470
|
-
};
|
|
471
|
-
|
|
472
|
-
setHiddenLabelRef = (ref) => {
|
|
473
|
-
if (ref && ref !== this.hiddenLabelRef) {
|
|
474
|
-
this.hiddenLabelRef = ref;
|
|
475
|
-
this.observeHiddenLabel(ref);
|
|
476
|
-
}
|
|
477
|
-
};
|
|
478
|
-
|
|
479
|
-
componentDidMount() {
|
|
480
|
-
if (this.hiddenLabelRef) {
|
|
481
|
-
this.observeHiddenLabel(this.hiddenLabelRef);
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
componentWillUnmount() {
|
|
486
|
-
unregisterMathCallback(this._onDocMutation);
|
|
487
|
-
if (this._updateTimer) {
|
|
488
|
-
clearTimeout(this._updateTimer);
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
componentDidUpdate(prevProps) {
|
|
493
|
-
if (prevProps.categories !== this.props.categories) {
|
|
494
|
-
if (this._updateTimer) clearTimeout(this._updateTimer);
|
|
495
|
-
this._updateTimer = setTimeout(() => this.measureHiddenLabel(), 50);
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
render() {
|
|
500
|
-
const {
|
|
501
|
-
graphProps,
|
|
502
|
-
xBand,
|
|
503
|
-
leftAxis,
|
|
504
|
-
onChange,
|
|
505
|
-
onChangeCategory,
|
|
506
|
-
categories = [],
|
|
507
|
-
top,
|
|
508
|
-
defineChart,
|
|
509
|
-
chartingOptions,
|
|
510
|
-
changeInteractiveEnabled,
|
|
511
|
-
changeEditableEnabled,
|
|
512
|
-
theme,
|
|
513
|
-
autoFocus,
|
|
514
|
-
onAutoFocusUsed,
|
|
515
|
-
error,
|
|
516
|
-
showCorrectness,
|
|
517
|
-
} = this.props;
|
|
518
|
-
|
|
519
|
-
const { scale = {}, range = {}, domain = {}, size = {} } = graphProps || {};
|
|
520
|
-
const { height, width } = this.state;
|
|
521
|
-
|
|
522
|
-
const bottomScale = xBand && typeof xBand.rangeRound === 'function' && xBand.rangeRound([0, size.width]);
|
|
523
|
-
|
|
524
|
-
const bandWidth = xBand && typeof xBand.bandwidth === 'function' && xBand.bandwidth();
|
|
525
|
-
// for chartType "line", bandWidth will be 0, so we have to calculate it
|
|
526
|
-
const barWidth = bandWidth || (scale.x && scale.x(domain.max) / categories.length);
|
|
527
|
-
|
|
528
|
-
const rowTickValues = getTickValues({ ...range, step: range.labelStep });
|
|
529
|
-
const fontSize = theme && theme.typography ? theme.typography.fontSize : 14;
|
|
530
|
-
// this mostly applies for labels that are not editable
|
|
531
|
-
const rotateBecauseOfHeight = getRotateAngle(fontSize, height);
|
|
532
|
-
// this applies for labels that are editable
|
|
533
|
-
const rotateBecauseOfWidth = width > barWidth ? 25 : 0;
|
|
534
|
-
|
|
535
|
-
const getTickLabelProps = (value) => ({
|
|
536
|
-
dy: 4,
|
|
537
|
-
dx: -10 - (value.toLocaleString().length || 1) * 5,
|
|
538
|
-
});
|
|
539
|
-
|
|
540
|
-
const getTickComponent = (props) => {
|
|
541
|
-
const properties = {
|
|
542
|
-
hiddenLabelRef: this.setHiddenLabelRef,
|
|
543
|
-
categories,
|
|
544
|
-
xBand,
|
|
545
|
-
bandWidth,
|
|
546
|
-
barWidth,
|
|
547
|
-
rotate: rotateBecauseOfHeight || rotateBecauseOfWidth,
|
|
548
|
-
top,
|
|
549
|
-
defineChart,
|
|
550
|
-
chartingOptions,
|
|
551
|
-
autoFocus,
|
|
552
|
-
onAutoFocusUsed,
|
|
553
|
-
error,
|
|
554
|
-
onChangeCategory,
|
|
555
|
-
changeInteractiveEnabled,
|
|
556
|
-
changeEditableEnabled,
|
|
557
|
-
onChange,
|
|
558
|
-
graphProps,
|
|
559
|
-
x: props.x,
|
|
560
|
-
y: props.y,
|
|
561
|
-
formattedValue: props.formattedValue,
|
|
562
|
-
showCorrectness,
|
|
563
|
-
};
|
|
564
|
-
|
|
565
|
-
return <TickComponent {...properties} />;
|
|
566
|
-
};
|
|
567
|
-
|
|
568
|
-
return (
|
|
569
|
-
<StyledAxesGroup>
|
|
570
|
-
{leftAxis && (
|
|
571
|
-
<AxisLeft
|
|
572
|
-
scale={scale.y}
|
|
573
|
-
tickLength={10}
|
|
574
|
-
tickFormat={(value) => value}
|
|
575
|
-
tickValues={rowTickValues}
|
|
576
|
-
tickLabelProps={getTickLabelProps}
|
|
577
|
-
/>
|
|
578
|
-
)}
|
|
579
|
-
<AxisBottom
|
|
580
|
-
scale={bottomScale}
|
|
581
|
-
labelProps={{ y: 60 + top }}
|
|
582
|
-
top={scale.y && scale.y(range.min)}
|
|
583
|
-
textLabelProps={() => ({ textAnchor: 'middle' })}
|
|
584
|
-
tickFormat={(count) => count}
|
|
585
|
-
tickComponent={getTickComponent}
|
|
586
|
-
autoFocus={autoFocus}
|
|
587
|
-
onAutoFocusUsed={onAutoFocusUsed}
|
|
588
|
-
/>
|
|
589
|
-
</StyledAxesGroup>
|
|
590
|
-
);
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
export default RawChartAxes;
|