@pie-lib/charting 7.0.4-next.31 → 7.0.4-next.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +17 -0
- package/CHANGELOG.md +1116 -0
- package/LICENSE.md +5 -0
- package/lib/actions-button.js +145 -0
- package/lib/actions-button.js.map +1 -0
- package/lib/axes.js +643 -0
- package/lib/axes.js.map +1 -0
- package/lib/bars/bar.js +58 -0
- package/lib/bars/bar.js.map +1 -0
- package/lib/bars/common/bars.js +277 -0
- package/lib/bars/common/bars.js.map +1 -0
- package/lib/bars/common/correct-check-icon.js +54 -0
- package/lib/bars/common/correct-check-icon.js.map +1 -0
- package/lib/bars/histogram.js +59 -0
- package/lib/bars/histogram.js.map +1 -0
- package/lib/chart-setup.js +382 -0
- package/lib/chart-setup.js.map +1 -0
- package/lib/chart-type.js +80 -0
- package/lib/chart-type.js.map +1 -0
- package/lib/chart-types.js +22 -0
- package/lib/chart-types.js.map +1 -0
- package/lib/chart.js +384 -0
- package/lib/chart.js.map +1 -0
- package/lib/common/correctness-indicators.js +156 -0
- package/lib/common/correctness-indicators.js.map +1 -0
- package/lib/common/drag-handle.js +160 -0
- package/lib/common/drag-handle.js.map +1 -0
- package/lib/common/drag-icon.js +52 -0
- package/lib/common/drag-icon.js.map +1 -0
- package/lib/common/styles.js +22 -0
- package/lib/common/styles.js.map +1 -0
- package/lib/grid.js +112 -0
- package/lib/grid.js.map +1 -0
- package/lib/index.js +42 -0
- package/lib/index.js.map +1 -0
- package/lib/key-legend.js +87 -0
- package/lib/key-legend.js.map +1 -0
- package/lib/line/common/drag-handle.js +146 -0
- package/lib/line/common/drag-handle.js.map +1 -0
- package/lib/line/common/line.js +214 -0
- package/lib/line/common/line.js.map +1 -0
- package/lib/line/line-cross.js +214 -0
- package/lib/line/line-cross.js.map +1 -0
- package/lib/line/line-dot.js +158 -0
- package/lib/line/line-dot.js.map +1 -0
- package/lib/mark-label.js +237 -0
- package/lib/mark-label.js.map +1 -0
- package/lib/plot/common/plot.js +349 -0
- package/lib/plot/common/plot.js.map +1 -0
- package/lib/plot/dot.js +110 -0
- package/lib/plot/dot.js.map +1 -0
- package/lib/plot/line.js +140 -0
- package/lib/plot/line.js.map +1 -0
- package/lib/tool-menu.js +106 -0
- package/lib/tool-menu.js.map +1 -0
- package/lib/utils.js +189 -0
- package/lib/utils.js.map +1 -0
- package/package.json +28 -39
- package/src/__tests__/actions-button.test.jsx +280 -0
- package/src/__tests__/axes.test.jsx +667 -0
- package/src/__tests__/chart-setup.test.jsx +532 -0
- package/src/__tests__/chart-type.test.jsx +23 -0
- package/src/__tests__/chart.test.jsx +86 -0
- package/src/__tests__/grid.test.jsx +37 -0
- package/src/__tests__/key-legend.test.jsx +223 -0
- package/src/__tests__/mark-label.test.jsx +33 -0
- package/src/__tests__/tool-menu.test.jsx +522 -0
- package/src/__tests__/utils.js +36 -0
- package/src/__tests__/utils.test.js +100 -0
- package/src/actions-button.jsx +115 -0
- package/src/axes.jsx +594 -0
- package/src/bars/__tests__/bar.test.jsx +45 -0
- package/src/bars/__tests__/histogram.test.jsx +45 -0
- package/src/bars/__tests__/utils.js +30 -0
- package/src/bars/bar.js +28 -0
- package/src/bars/common/__tests__/bars.test.jsx +68 -0
- package/src/bars/common/__tests__/utils.js +30 -0
- package/src/bars/common/bars.jsx +249 -0
- package/src/bars/common/correct-check-icon.jsx +25 -0
- package/src/bars/histogram.js +28 -0
- package/src/chart-setup.jsx +356 -0
- package/src/chart-type.js +59 -0
- package/src/chart-types.js +8 -0
- package/src/chart.jsx +357 -0
- package/src/common/__tests__/correctness-indicators.test.jsx +720 -0
- package/src/common/__tests__/drag-handle.test.jsx +58 -0
- package/src/common/__tests__/utils.js +30 -0
- package/src/common/correctness-indicators.jsx +128 -0
- package/src/common/drag-handle.jsx +125 -0
- package/src/common/drag-icon.jsx +36 -0
- package/src/common/styles.js +19 -0
- package/src/grid.jsx +80 -0
- package/src/index.js +7 -0
- package/src/key-legend.jsx +77 -0
- package/src/line/__tests__/line-cross.test.jsx +463 -0
- package/src/line/__tests__/line-dot.test.jsx +41 -0
- package/src/line/__tests__/utils.js +36 -0
- package/src/line/common/__tests__/drag-handle.test.jsx +62 -0
- package/src/line/common/__tests__/line.test.jsx +79 -0
- package/src/line/common/__tests__/utils.js +30 -0
- package/src/line/common/drag-handle.jsx +114 -0
- package/src/line/common/line.jsx +171 -0
- package/src/line/line-cross.js +144 -0
- package/src/line/line-dot.js +111 -0
- package/src/mark-label.jsx +238 -0
- package/src/plot/__tests__/dot.test.jsx +344 -0
- package/src/plot/__tests__/line.test.jsx +375 -0
- package/src/plot/__tests__/utils.js +30 -0
- package/src/plot/common/__tests__/plot.test.jsx +69 -0
- package/src/plot/common/__tests__/utils.js +30 -0
- package/src/plot/common/plot.jsx +358 -0
- package/src/plot/dot.js +74 -0
- package/src/plot/line.js +98 -0
- package/src/tool-menu.jsx +85 -0
- package/src/utils.js +201 -0
- package/dist/_virtual/_rolldown/runtime.js +0 -23
- package/dist/actions-button.d.ts +0 -26
- package/dist/actions-button.js +0 -84
- package/dist/autosize-input.d.ts +0 -10
- package/dist/autosize-input.js +0 -66
- package/dist/axes.d.ts +0 -84
- package/dist/axes.js +0 -376
- package/dist/bars/bar.d.ts +0 -47
- package/dist/bars/bar.js +0 -27
- package/dist/bars/common/bars.d.ts +0 -98
- package/dist/bars/common/bars.js +0 -174
- package/dist/bars/common/correct-check-icon.d.ts +0 -18
- package/dist/bars/common/correct-check-icon.js +0 -50
- package/dist/bars/histogram.d.ts +0 -47
- package/dist/bars/histogram.js +0 -28
- package/dist/chart-setup.d.ts +0 -29
- package/dist/chart-setup.js +0 -231
- package/dist/chart-type.d.ts +0 -32
- package/dist/chart-type.js +0 -68
- package/dist/chart-types.d.ts +0 -41
- package/dist/chart-types.js +0 -17
- package/dist/chart.d.ts +0 -88
- package/dist/chart.js +0 -250
- package/dist/common/correctness-indicators.d.ts +0 -70
- package/dist/common/correctness-indicators.js +0 -106
- package/dist/common/drag-handle.d.ts +0 -129
- package/dist/common/drag-handle.js +0 -120
- package/dist/common/drag-icon.d.ts +0 -23
- package/dist/common/drag-icon.js +0 -45
- package/dist/common/styles.d.ts +0 -23
- package/dist/common/styles.js +0 -17
- package/dist/grid.d.ts +0 -45
- package/dist/grid.js +0 -56
- package/dist/index.d.ts +0 -14
- package/dist/index.js +0 -6
- package/dist/key-legend.d.ts +0 -19
- package/dist/key-legend.js +0 -46
- package/dist/line/common/drag-handle.d.ts +0 -120
- package/dist/line/common/drag-handle.js +0 -92
- package/dist/line/common/line.d.ts +0 -96
- package/dist/line/common/line.js +0 -114
- package/dist/line/line-cross.d.ts +0 -47
- package/dist/line/line-cross.js +0 -133
- package/dist/line/line-dot.d.ts +0 -47
- package/dist/line/line-dot.js +0 -101
- package/dist/mark-label.d.ts +0 -55
- package/dist/mark-label.js +0 -138
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Axis.js +0 -101
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisBottom.js +0 -46
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisLeft.js +0 -47
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisRenderer.js +0 -63
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Ticks.js +0 -44
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/constants/orientation.js +0 -9
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/createPoint.js +0 -14
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getAxisRangePaddingConfig.js +0 -21
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getLabelTransform.js +0 -16
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getTickFormatter.js +0 -8
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getTickPosition.js +0 -15
- package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/GridColumns.js +0 -79
- package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/GridRows.js +0 -79
- package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/utils/getScaleBandwidth.js +0 -6
- package/dist/node_modules/.bun/@visx_group@3.12.0_f4eacebf2041cd4f/node_modules/@visx/group/esm/Group.js +0 -50
- package/dist/node_modules/.bun/@visx_point@3.12.0/node_modules/@visx/point/esm/Point.js +0 -18
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/align.js +0 -6
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/base.js +0 -6
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/clamp.js +0 -6
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/constant.js +0 -6
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/domain.js +0 -6
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/exponent.js +0 -6
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/interpolate.js +0 -10
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/nice.js +0 -37
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/padding.js +0 -6
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/range.js +0 -6
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/reverse.js +0 -9
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/round.js +0 -7
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/scaleOperator.js +0 -58
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/unknown.js +0 -6
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/operators/zero.js +0 -9
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/scales/band.js +0 -9
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/scales/point.js +0 -9
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/coerceNumber.js +0 -10
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/createColorInterpolator.js +0 -29
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/getTicks.js +0 -9
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/isUtcScale.js +0 -7
- package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/toString.js +0 -6
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/Bar.js +0 -29
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/Circle.js +0 -29
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/Line.js +0 -47
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/LinePath.js +0 -50
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/util/D3ShapeFactories.js +0 -9
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/util/setNumberOrNumberAccessor.js +0 -6
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/lib/shapes/Line.js +0 -53
- package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/Text.js +0 -57
- package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/hooks/useText.js +0 -91
- package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/util/getStringWidth.js +0 -21
- package/dist/node_modules/.bun/@visx_vendor@3.12.0/node_modules/@visx/vendor/esm/d3-interpolate.js +0 -8
- package/dist/node_modules/.bun/@visx_vendor@3.12.0/node_modules/@visx/vendor/esm/d3-scale.js +0 -8
- package/dist/node_modules/.bun/@visx_vendor@3.12.0/node_modules/@visx/vendor/esm/d3-time.js +0 -8
- package/dist/node_modules/.bun/balanced-match@0.4.2/node_modules/balanced-match/index.js +0 -32
- package/dist/node_modules/.bun/balanced-match@1.0.2/node_modules/balanced-match/index.js +0 -33
- package/dist/node_modules/.bun/classnames@2.5.1/node_modules/classnames/index.js +0 -32
- package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +0 -16
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_Hash.js +0 -21
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_ListCache.js +0 -21
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_Map.js +0 -10
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_MapCache.js +0 -21
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_Symbol.js +0 -9
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_assocIndexOf.js +0 -14
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_baseGetTag.js +0 -15
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_baseIsNative.js +0 -16
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_coreJsData.js +0 -9
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_freeGlobal.js +0 -8
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_getMapData.js +0 -14
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_getNative.js +0 -15
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_getRawTag.js +0 -19
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_getValue.js +0 -11
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashClear.js +0 -13
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashDelete.js +0 -12
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashGet.js +0 -18
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashHas.js +0 -14
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashSet.js +0 -14
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_isKeyable.js +0 -12
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_isMasked.js +0 -16
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheClear.js +0 -11
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheDelete.js +0 -14
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheGet.js +0 -14
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheHas.js +0 -13
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheSet.js +0 -14
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheClear.js +0 -19
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheDelete.js +0 -14
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheGet.js +0 -13
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheHas.js +0 -13
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheSet.js +0 -14
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_nativeCreate.js +0 -9
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_objectToString.js +0 -12
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_root.js +0 -10
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_toSource.js +0 -20
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/eq.js +0 -11
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/isFunction.js +0 -16
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/isObject.js +0 -12
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/memoize.js +0 -20
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/formula_evaluator.js +0 -37
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/lexer.js +0 -509
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/math_function.js +0 -108
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix.js +0 -31
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix_evaluator.js +0 -45
- package/dist/node_modules/.bun/reduce-css-calc@1.3.0/node_modules/reduce-css-calc/index.js +0 -49
- package/dist/node_modules/.bun/reduce-function-call@1.0.3/node_modules/reduce-function-call/index.js +0 -34
- package/dist/plot/common/plot.d.ts +0 -103
- package/dist/plot/common/plot.js +0 -227
- package/dist/plot/dot.d.ts +0 -47
- package/dist/plot/dot.js +0 -62
- package/dist/plot/line.d.ts +0 -47
- package/dist/plot/line.js +0 -84
- package/dist/tool-menu.d.ts +0 -31
- package/dist/utils.d.ts +0 -39
- package/dist/utils.js +0 -101
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Check from '@mui/icons-material/Check';
|
|
4
|
+
import { styled } from '@mui/material/styles';
|
|
5
|
+
import { Group } from '@visx/group';
|
|
6
|
+
import debug from 'debug';
|
|
7
|
+
|
|
8
|
+
import { types } from '@pie-lib/plot';
|
|
9
|
+
import DraggableHandle, { DragHandle } from '../../common/drag-handle';
|
|
10
|
+
import { color } from '@pie-lib/render-ui';
|
|
11
|
+
import { bandKey } from '../../utils';
|
|
12
|
+
import { correct, incorrect } from '../../common/styles';
|
|
13
|
+
|
|
14
|
+
const log = debug('pie-lib:chart:bars');
|
|
15
|
+
const ICON_SIZE = 16; // 10px icon + 2px padding on all sides + 1px border
|
|
16
|
+
|
|
17
|
+
export class RawPlot extends React.Component {
|
|
18
|
+
static propTypes = {
|
|
19
|
+
onChangeCategory: PropTypes.func,
|
|
20
|
+
value: PropTypes.number,
|
|
21
|
+
label: PropTypes.string,
|
|
22
|
+
xBand: PropTypes.func,
|
|
23
|
+
index: PropTypes.number.isRequired,
|
|
24
|
+
graphProps: types.GraphPropsType.isRequired,
|
|
25
|
+
CustomBarElement: PropTypes.func,
|
|
26
|
+
interactive: PropTypes.bool,
|
|
27
|
+
correctness: PropTypes.shape({
|
|
28
|
+
value: PropTypes.string,
|
|
29
|
+
label: PropTypes.string,
|
|
30
|
+
}),
|
|
31
|
+
defineChart: PropTypes.bool,
|
|
32
|
+
correctData: PropTypes.arrayOf(
|
|
33
|
+
PropTypes.shape({
|
|
34
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
35
|
+
label: PropTypes.string,
|
|
36
|
+
}),
|
|
37
|
+
),
|
|
38
|
+
className: PropTypes.string,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
constructor(props) {
|
|
42
|
+
super(props);
|
|
43
|
+
this.state = {
|
|
44
|
+
dragValue: undefined,
|
|
45
|
+
isHovered: false,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
handleMouseEnter = () => {
|
|
50
|
+
this.setState({ isHovered: true });
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
handleMouseLeave = () => {
|
|
54
|
+
this.setState({ isHovered: false });
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
setDragValue = (dragValue) => this.setState({ dragValue });
|
|
58
|
+
|
|
59
|
+
dragStop = () => {
|
|
60
|
+
const { label, onChangeCategory } = this.props;
|
|
61
|
+
const { dragValue } = this.state;
|
|
62
|
+
log('[dragStop]', dragValue);
|
|
63
|
+
|
|
64
|
+
if (dragValue !== undefined) {
|
|
65
|
+
onChangeCategory({ label, value: dragValue });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
this.setDragValue(undefined);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
dragValue = (existing, next) => {
|
|
72
|
+
log('[dragValue] next:', next);
|
|
73
|
+
|
|
74
|
+
this.setDragValue(next);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
renderCorrectnessIcon = (barX, barWidth, correctVal, correctness, scale, pointHeight, pointDiameter) => {
|
|
78
|
+
let iconY;
|
|
79
|
+
|
|
80
|
+
if (correctVal === 0) {
|
|
81
|
+
// if correct value is 0, position icon on the horizontal axis
|
|
82
|
+
iconY = scale.y(0) - ICON_SIZE / 2;
|
|
83
|
+
} else {
|
|
84
|
+
const shapeIndex = correctVal - 1; // the index of the shape representing the correct value
|
|
85
|
+
const shapeCenterY = scale.y(shapeIndex) - (pointHeight - pointDiameter) / 2 - pointDiameter / 2;
|
|
86
|
+
iconY = shapeCenterY - ICON_SIZE / 2; // center the icon
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<foreignObject x={barX + barWidth / 2 - ICON_SIZE / 2} y={iconY} width={ICON_SIZE} height={ICON_SIZE}>
|
|
91
|
+
<Check className="correctnessIcon correctIcon smallIcon" title={correctness.label} />
|
|
92
|
+
</foreignObject>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
render() {
|
|
97
|
+
const {
|
|
98
|
+
graphProps,
|
|
99
|
+
value,
|
|
100
|
+
label,
|
|
101
|
+
xBand,
|
|
102
|
+
index,
|
|
103
|
+
CustomBarElement,
|
|
104
|
+
interactive,
|
|
105
|
+
correctness,
|
|
106
|
+
defineChart,
|
|
107
|
+
correctData,
|
|
108
|
+
className,
|
|
109
|
+
} = this.props;
|
|
110
|
+
|
|
111
|
+
const { scale, range, size } = graphProps;
|
|
112
|
+
const { max } = range || {};
|
|
113
|
+
const { dragValue, isHovered } = this.state;
|
|
114
|
+
|
|
115
|
+
const v = Number.isFinite(dragValue) ? dragValue : value;
|
|
116
|
+
const barWidth = xBand.bandwidth();
|
|
117
|
+
const barHeight = scale.y(range.max - v);
|
|
118
|
+
const barX = xBand(bandKey({ label }, index));
|
|
119
|
+
|
|
120
|
+
log('label:', label, 'barX:', barX, 'v: ', v, 'barHeight:', barHeight, 'barWidth: ', barWidth);
|
|
121
|
+
|
|
122
|
+
const values = [];
|
|
123
|
+
|
|
124
|
+
for (let i = 0; i < v; i++) {
|
|
125
|
+
values.push(i);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const pointHeight = size.height / max;
|
|
129
|
+
const pointDiameter = (pointHeight > barWidth ? barWidth : pointHeight) * 0.8;
|
|
130
|
+
const Component = interactive ? DraggableHandle : DragHandle;
|
|
131
|
+
const allowRolloverEvent = interactive && !correctness;
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<React.Fragment>
|
|
135
|
+
<g
|
|
136
|
+
className={className}
|
|
137
|
+
onMouseEnter={this.handleMouseEnter}
|
|
138
|
+
onMouseLeave={this.handleMouseLeave}
|
|
139
|
+
onTouchStart={this.handleMouseEnter}
|
|
140
|
+
onTouchEnd={this.handleMouseLeave}
|
|
141
|
+
>
|
|
142
|
+
{isHovered && allowRolloverEvent && (
|
|
143
|
+
<rect
|
|
144
|
+
x={barX}
|
|
145
|
+
y={scale.y(v)}
|
|
146
|
+
width={barWidth}
|
|
147
|
+
height={values?.length ? pointHeight * values.length : 0}
|
|
148
|
+
stroke={color.defaults.BORDER_GRAY}
|
|
149
|
+
strokeWidth={'4px'}
|
|
150
|
+
fill={'transparent'}
|
|
151
|
+
/>
|
|
152
|
+
)}
|
|
153
|
+
{values.map((index) =>
|
|
154
|
+
CustomBarElement({
|
|
155
|
+
index,
|
|
156
|
+
pointDiameter,
|
|
157
|
+
barX,
|
|
158
|
+
barWidth,
|
|
159
|
+
pointHeight,
|
|
160
|
+
label,
|
|
161
|
+
value,
|
|
162
|
+
scale,
|
|
163
|
+
}),
|
|
164
|
+
)}
|
|
165
|
+
{correctness &&
|
|
166
|
+
correctness.value === 'incorrect' &&
|
|
167
|
+
(() => {
|
|
168
|
+
const correctVal = parseFloat(correctData[index] && correctData[index].value);
|
|
169
|
+
if (isNaN(correctVal)) return null;
|
|
170
|
+
const selectedVal = v;
|
|
171
|
+
|
|
172
|
+
// special case: if correct value is 0, only show the icon on the axis
|
|
173
|
+
if (correctVal === 0) {
|
|
174
|
+
return this.renderCorrectnessIcon(
|
|
175
|
+
barX,
|
|
176
|
+
barWidth,
|
|
177
|
+
correctVal,
|
|
178
|
+
correctness,
|
|
179
|
+
scale,
|
|
180
|
+
pointHeight,
|
|
181
|
+
pointDiameter,
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (selectedVal > correctVal) {
|
|
186
|
+
// selected is higher than correct: overlay the correct last segment
|
|
187
|
+
const overlayValues = [];
|
|
188
|
+
for (let i = 0; i < correctVal; i++) {
|
|
189
|
+
overlayValues.push(i);
|
|
190
|
+
}
|
|
191
|
+
const lastIndexOfOverlay = overlayValues.length - 1;
|
|
192
|
+
const lastOverlayValue = overlayValues[lastIndexOfOverlay];
|
|
193
|
+
const barX = xBand(bandKey({ label }, index));
|
|
194
|
+
const barWidth = xBand.bandwidth();
|
|
195
|
+
const pointHeight = size.height / max;
|
|
196
|
+
const pointDiameter = (pointHeight > barWidth ? barWidth : pointHeight) * 0.8;
|
|
197
|
+
return (
|
|
198
|
+
<>
|
|
199
|
+
<CustomBarElement
|
|
200
|
+
index={lastOverlayValue}
|
|
201
|
+
pointDiameter={pointDiameter + 10} // increase point diameter for dotted line
|
|
202
|
+
barX={barX}
|
|
203
|
+
barWidth={barWidth}
|
|
204
|
+
pointHeight={pointHeight}
|
|
205
|
+
label={label}
|
|
206
|
+
value={value}
|
|
207
|
+
scale={scale}
|
|
208
|
+
dottedOverline={true}
|
|
209
|
+
/>
|
|
210
|
+
{this.renderCorrectnessIcon(
|
|
211
|
+
barX,
|
|
212
|
+
barWidth,
|
|
213
|
+
correctVal,
|
|
214
|
+
correctness,
|
|
215
|
+
scale,
|
|
216
|
+
pointHeight,
|
|
217
|
+
pointDiameter,
|
|
218
|
+
)}
|
|
219
|
+
</>
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
// selected is lower than correct, render missing segment below the correct bar
|
|
223
|
+
const valuesToRender = [];
|
|
224
|
+
for (let i = selectedVal; i < correctVal; i++) {
|
|
225
|
+
valuesToRender.push(i);
|
|
226
|
+
}
|
|
227
|
+
return (
|
|
228
|
+
<>
|
|
229
|
+
{valuesToRender.map((idx) =>
|
|
230
|
+
CustomBarElement({
|
|
231
|
+
index: idx,
|
|
232
|
+
pointDiameter,
|
|
233
|
+
barX,
|
|
234
|
+
barWidth,
|
|
235
|
+
pointHeight,
|
|
236
|
+
label,
|
|
237
|
+
value,
|
|
238
|
+
scale,
|
|
239
|
+
dottedOverline: true,
|
|
240
|
+
}),
|
|
241
|
+
)}
|
|
242
|
+
{this.renderCorrectnessIcon(
|
|
243
|
+
barX,
|
|
244
|
+
barWidth,
|
|
245
|
+
correctVal,
|
|
246
|
+
correctness,
|
|
247
|
+
scale,
|
|
248
|
+
pointHeight,
|
|
249
|
+
pointDiameter,
|
|
250
|
+
)}
|
|
251
|
+
</>
|
|
252
|
+
);
|
|
253
|
+
})()}
|
|
254
|
+
<Component
|
|
255
|
+
x={barX}
|
|
256
|
+
y={v}
|
|
257
|
+
interactive={interactive}
|
|
258
|
+
width={barWidth}
|
|
259
|
+
onDrag={(v) => this.dragValue(value, v)}
|
|
260
|
+
onDragStop={this.dragStop}
|
|
261
|
+
graphProps={graphProps}
|
|
262
|
+
correctness={correctness}
|
|
263
|
+
isHovered={isHovered}
|
|
264
|
+
defineChart={defineChart}
|
|
265
|
+
color={color.primaryDark()}
|
|
266
|
+
isPlot
|
|
267
|
+
/>
|
|
268
|
+
</g>
|
|
269
|
+
</React.Fragment>
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const Bar = styled(RawPlot)(({ theme }) => ({
|
|
275
|
+
'& .dot': {
|
|
276
|
+
fill: color.visualElementsColors.PLOT_FILL_COLOR,
|
|
277
|
+
'&.correct': correct('stroke'),
|
|
278
|
+
'&.incorrect': incorrect('stroke'),
|
|
279
|
+
},
|
|
280
|
+
'& .dotColor': {
|
|
281
|
+
fill: color.visualElementsColors.PLOT_FILL_COLOR,
|
|
282
|
+
'&.correct': correct('fill'),
|
|
283
|
+
'&.incorrect': incorrect('fill'),
|
|
284
|
+
},
|
|
285
|
+
'& .line': {
|
|
286
|
+
stroke: color.visualElementsColors.PLOT_FILL_COLOR,
|
|
287
|
+
'&.correct': correct('stroke'),
|
|
288
|
+
'&.incorrect': incorrect('stroke'),
|
|
289
|
+
},
|
|
290
|
+
'& .correctIcon': {
|
|
291
|
+
backgroundColor: color.correct(),
|
|
292
|
+
},
|
|
293
|
+
'& .incorrectIcon': {
|
|
294
|
+
backgroundColor: color.incorrectWithIcon(),
|
|
295
|
+
},
|
|
296
|
+
'& .correctnessIcon': {
|
|
297
|
+
borderRadius: theme.spacing(2),
|
|
298
|
+
color: color.defaults.WHITE,
|
|
299
|
+
fontSize: '16px',
|
|
300
|
+
width: '16px',
|
|
301
|
+
height: '16px',
|
|
302
|
+
padding: '2px',
|
|
303
|
+
border: `1px solid ${color.defaults.WHITE}`,
|
|
304
|
+
stroke: 'initial',
|
|
305
|
+
boxSizing: 'unset', // to override the default border-box in IBX
|
|
306
|
+
display: 'block',
|
|
307
|
+
},
|
|
308
|
+
'& .smallIcon': {
|
|
309
|
+
fontSize: '10px',
|
|
310
|
+
width: '10px',
|
|
311
|
+
height: '10px',
|
|
312
|
+
},
|
|
313
|
+
}));
|
|
314
|
+
|
|
315
|
+
export class Plot extends React.Component {
|
|
316
|
+
static propTypes = {
|
|
317
|
+
data: PropTypes.array,
|
|
318
|
+
onChangeCategory: PropTypes.func,
|
|
319
|
+
xBand: PropTypes.func,
|
|
320
|
+
graphProps: types.GraphPropsType.isRequired,
|
|
321
|
+
defineChart: PropTypes.bool,
|
|
322
|
+
CustomBarElement: PropTypes.func,
|
|
323
|
+
correctData: PropTypes.arrayOf(
|
|
324
|
+
PropTypes.shape({
|
|
325
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
326
|
+
label: PropTypes.string,
|
|
327
|
+
}),
|
|
328
|
+
),
|
|
329
|
+
className: PropTypes.string,
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
render() {
|
|
333
|
+
const { data, graphProps, xBand, CustomBarElement, onChangeCategory, defineChart, correctData } = this.props;
|
|
334
|
+
|
|
335
|
+
return (
|
|
336
|
+
<Group>
|
|
337
|
+
{(data || []).map((d, index) => (
|
|
338
|
+
<Bar
|
|
339
|
+
value={d.value}
|
|
340
|
+
label={d.label}
|
|
341
|
+
interactive={defineChart || d.interactive}
|
|
342
|
+
defineChart={defineChart}
|
|
343
|
+
xBand={xBand}
|
|
344
|
+
index={index}
|
|
345
|
+
key={`bar-${d.label}-${d.value}-${index}`}
|
|
346
|
+
onChangeCategory={(category) => onChangeCategory(index, category)}
|
|
347
|
+
graphProps={graphProps}
|
|
348
|
+
CustomBarElement={CustomBarElement}
|
|
349
|
+
correctness={d.correctness}
|
|
350
|
+
correctData={correctData}
|
|
351
|
+
/>
|
|
352
|
+
))}
|
|
353
|
+
</Group>
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
export default Plot;
|
package/src/plot/dot.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Circle } from '@visx/shape';
|
|
4
|
+
|
|
5
|
+
import { types } from '@pie-lib/plot';
|
|
6
|
+
import { dataToXBand } from '../utils';
|
|
7
|
+
import Plot from './common/plot';
|
|
8
|
+
import { color } from '@pie-lib/render-ui';
|
|
9
|
+
import { styled } from '@mui/material/styles';
|
|
10
|
+
import { correct, incorrect } from '../common/styles';
|
|
11
|
+
|
|
12
|
+
const StyledCircle = styled(Circle)(() => ({
|
|
13
|
+
fill: color.visualElementsColors.PLOT_FILL_COLOR,
|
|
14
|
+
'&.correct': correct('stroke'),
|
|
15
|
+
'&.incorrect': incorrect('stroke'),
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
const CustomBarElement = (props) => {
|
|
19
|
+
const { index, pointDiameter, barX, barWidth, pointHeight, label, value, scale, dottedOverline } = props;
|
|
20
|
+
|
|
21
|
+
const r = pointDiameter / 2;
|
|
22
|
+
const cx = barX + (barWidth - pointDiameter) / 2 + r;
|
|
23
|
+
const cy = scale.y(index) - (pointHeight - pointDiameter) / 2 - r;
|
|
24
|
+
const EXTRA_PADDING = 2;
|
|
25
|
+
|
|
26
|
+
return dottedOverline ? (
|
|
27
|
+
<Circle
|
|
28
|
+
key={`point-${label}-${value}-${index}`}
|
|
29
|
+
cx={cx}
|
|
30
|
+
cy={cy}
|
|
31
|
+
r={r + EXTRA_PADDING}
|
|
32
|
+
strokeDasharray="4,4"
|
|
33
|
+
stroke={color.defaults.BORDER_GRAY}
|
|
34
|
+
fill="none"
|
|
35
|
+
/>
|
|
36
|
+
) : (
|
|
37
|
+
<StyledCircle key={`point-${label}-${value}-${index}`} cx={cx} cy={cy} r={r} />
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
CustomBarElement.propTypes = {
|
|
42
|
+
index: PropTypes.number,
|
|
43
|
+
pointDiameter: PropTypes.number,
|
|
44
|
+
barX: PropTypes.number,
|
|
45
|
+
barWidth: PropTypes.number,
|
|
46
|
+
pointHeight: PropTypes.number,
|
|
47
|
+
value: PropTypes.number,
|
|
48
|
+
label: PropTypes.string,
|
|
49
|
+
scale: PropTypes.object,
|
|
50
|
+
dottedOverline: PropTypes.bool,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export class DotPlot extends React.Component {
|
|
54
|
+
static propTypes = {
|
|
55
|
+
data: PropTypes.array,
|
|
56
|
+
onChange: PropTypes.func,
|
|
57
|
+
graphProps: types.GraphPropsType.isRequired,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
render() {
|
|
61
|
+
const props = this.props;
|
|
62
|
+
const { data, graphProps } = props;
|
|
63
|
+
const { scale = {}, size = {} } = graphProps || {};
|
|
64
|
+
const xBand = dataToXBand(scale.x, data, size.width, 'dotPlot');
|
|
65
|
+
|
|
66
|
+
return <Plot {...props} xBand={xBand} CustomBarElement={CustomBarElement} />;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default () => ({
|
|
71
|
+
type: 'dotPlot',
|
|
72
|
+
Component: DotPlot,
|
|
73
|
+
name: 'Dot Plot',
|
|
74
|
+
});
|
package/src/plot/line.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { LinePath } from '@visx/shape';
|
|
4
|
+
import { Group } from '@visx/group';
|
|
5
|
+
import { styled } from '@mui/material/styles';
|
|
6
|
+
|
|
7
|
+
import { types } from '@pie-lib/plot';
|
|
8
|
+
import { dataToXBand } from '../utils';
|
|
9
|
+
import { color } from '@pie-lib/render-ui';
|
|
10
|
+
import Plot from './common/plot';
|
|
11
|
+
import { correct, incorrect } from '../common/styles';
|
|
12
|
+
|
|
13
|
+
const StyledLinePath = styled(LinePath)(() => ({
|
|
14
|
+
stroke: color.visualElementsColors.PLOT_FILL_COLOR,
|
|
15
|
+
'&.correct': correct('stroke'),
|
|
16
|
+
'&.incorrect': incorrect('stroke'),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
const CustomBarElement = (props) => {
|
|
20
|
+
const { index, pointDiameter, barX, barWidth, pointHeight, label, value, scale, dottedOverline } = props;
|
|
21
|
+
|
|
22
|
+
const x = barX + (barWidth - pointDiameter) / 2;
|
|
23
|
+
const y = scale.y(index) - (pointHeight - pointDiameter) / 2;
|
|
24
|
+
const EXTRA_PADDING = 2;
|
|
25
|
+
|
|
26
|
+
return dottedOverline ? (
|
|
27
|
+
<rect
|
|
28
|
+
key={`point-${label}-${value}-${index}`}
|
|
29
|
+
x={x - EXTRA_PADDING}
|
|
30
|
+
y={y - pointDiameter - EXTRA_PADDING}
|
|
31
|
+
width={pointDiameter + EXTRA_PADDING * 2}
|
|
32
|
+
height={pointDiameter + EXTRA_PADDING * 2}
|
|
33
|
+
strokeDasharray="4,4"
|
|
34
|
+
stroke={color.defaults.BORDER_GRAY}
|
|
35
|
+
fill="none"
|
|
36
|
+
/>
|
|
37
|
+
) : (
|
|
38
|
+
<Group>
|
|
39
|
+
<StyledLinePath
|
|
40
|
+
data={[
|
|
41
|
+
{ x, y },
|
|
42
|
+
{ x: x + pointDiameter, y: y - pointDiameter },
|
|
43
|
+
]}
|
|
44
|
+
key={`point-${label}-${value}-${index}-1`}
|
|
45
|
+
className={'line'}
|
|
46
|
+
x={(d) => d.x}
|
|
47
|
+
y={(d) => d.y}
|
|
48
|
+
strokeWidth={pointDiameter / 5}
|
|
49
|
+
/>
|
|
50
|
+
<StyledLinePath
|
|
51
|
+
data={[
|
|
52
|
+
{ x, y: y - pointDiameter },
|
|
53
|
+
{ x: x + pointDiameter, y },
|
|
54
|
+
]}
|
|
55
|
+
key={`point-${label}-${value}-${index}-2`}
|
|
56
|
+
x={(d) => d.x}
|
|
57
|
+
y={(d) => d.y}
|
|
58
|
+
strokeWidth={pointDiameter / 5}
|
|
59
|
+
className={'line'}
|
|
60
|
+
/>
|
|
61
|
+
</Group>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
CustomBarElement.propTypes = {
|
|
66
|
+
index: PropTypes.number,
|
|
67
|
+
pointDiameter: PropTypes.number,
|
|
68
|
+
barX: PropTypes.number,
|
|
69
|
+
barWidth: PropTypes.number,
|
|
70
|
+
pointHeight: PropTypes.number,
|
|
71
|
+
value: PropTypes.number,
|
|
72
|
+
label: PropTypes.string,
|
|
73
|
+
scale: PropTypes.object,
|
|
74
|
+
dottedOverline: PropTypes.bool,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export class LinePlot extends React.Component {
|
|
78
|
+
static propTypes = {
|
|
79
|
+
data: PropTypes.array,
|
|
80
|
+
onChange: PropTypes.func,
|
|
81
|
+
graphProps: types.GraphPropsType.isRequired,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
render() {
|
|
85
|
+
const props = this.props;
|
|
86
|
+
const { data, graphProps } = props;
|
|
87
|
+
const { scale = {}, size = {} } = graphProps || {};
|
|
88
|
+
const xBand = dataToXBand(scale.x, data, size.width, 'linePlot');
|
|
89
|
+
|
|
90
|
+
return <Plot {...props} xBand={xBand} CustomBarElement={CustomBarElement} />;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export default () => ({
|
|
95
|
+
type: 'linePlot',
|
|
96
|
+
Component: LinePlot,
|
|
97
|
+
name: 'Line Plot',
|
|
98
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { color } from '@pie-lib/render-ui';
|
|
4
|
+
|
|
5
|
+
import { styled } from '@mui/material/styles';
|
|
6
|
+
import Button from '@mui/material/Button';
|
|
7
|
+
import Translator from '@pie-lib/translator';
|
|
8
|
+
|
|
9
|
+
const { translator } = Translator;
|
|
10
|
+
|
|
11
|
+
const StyledMiniButton = styled(Button)(({ theme, selected, disabled }) => ({
|
|
12
|
+
color: color.text(),
|
|
13
|
+
border: `1px solid ${color.secondary()}`,
|
|
14
|
+
fontSize: theme.typography.fontSize,
|
|
15
|
+
...(selected && {
|
|
16
|
+
backgroundColor: color.background(),
|
|
17
|
+
'& span': {
|
|
18
|
+
color: color.primaryDark(),
|
|
19
|
+
},
|
|
20
|
+
}),
|
|
21
|
+
...(!selected &&
|
|
22
|
+
!disabled && {
|
|
23
|
+
'& span': {
|
|
24
|
+
color: color.primary(),
|
|
25
|
+
},
|
|
26
|
+
backgroundColor: color.background(),
|
|
27
|
+
}),
|
|
28
|
+
...(disabled && {
|
|
29
|
+
'& span': {
|
|
30
|
+
color: color.primary(),
|
|
31
|
+
},
|
|
32
|
+
backgroundColor: color.disabled(),
|
|
33
|
+
}),
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
export const MiniButton = (props) => {
|
|
37
|
+
const { disabled, selected, value, onClick } = props;
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<StyledMiniButton
|
|
41
|
+
size="small"
|
|
42
|
+
disabled={disabled}
|
|
43
|
+
selected={selected}
|
|
44
|
+
color={selected ? 'secondary' : 'default'}
|
|
45
|
+
value={value}
|
|
46
|
+
key={value}
|
|
47
|
+
variant="outlined"
|
|
48
|
+
onClick={onClick}
|
|
49
|
+
>
|
|
50
|
+
{value}
|
|
51
|
+
</StyledMiniButton>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
MiniButton.propTypes = {
|
|
55
|
+
disabled: PropTypes.bool,
|
|
56
|
+
className: PropTypes.string,
|
|
57
|
+
selected: PropTypes.bool,
|
|
58
|
+
value: PropTypes.string,
|
|
59
|
+
onClick: PropTypes.func,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export class ToolMenu extends React.Component {
|
|
63
|
+
static propTypes = {
|
|
64
|
+
className: PropTypes.string,
|
|
65
|
+
addCategory: PropTypes.func,
|
|
66
|
+
disabled: PropTypes.bool,
|
|
67
|
+
language: PropTypes.string,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
static defaultProps = {};
|
|
71
|
+
|
|
72
|
+
render() {
|
|
73
|
+
const { className, disabled, addCategory, language } = this.props;
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<div className={className}>
|
|
77
|
+
{!disabled && (
|
|
78
|
+
<MiniButton value={translator.t('charting.addCategory', { lng: language })} onClick={addCategory} />
|
|
79
|
+
)}
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export default ToolMenu;
|