@pie-lib/charting 7.0.4-next.30 → 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.18.1/node_modules/lodash/_Hash.js +0 -21
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_ListCache.js +0 -21
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_Map.js +0 -10
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_MapCache.js +0 -21
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_Symbol.js +0 -9
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_assocIndexOf.js +0 -14
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_baseGetTag.js +0 -15
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_baseIsNative.js +0 -16
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_coreJsData.js +0 -9
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_freeGlobal.js +0 -8
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getMapData.js +0 -14
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getNative.js +0 -15
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getRawTag.js +0 -19
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getValue.js +0 -11
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashClear.js +0 -13
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashDelete.js +0 -12
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashGet.js +0 -18
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashHas.js +0 -14
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashSet.js +0 -14
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_isKeyable.js +0 -12
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_isMasked.js +0 -16
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheClear.js +0 -11
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheDelete.js +0 -14
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheGet.js +0 -14
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheHas.js +0 -13
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheSet.js +0 -14
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheClear.js +0 -19
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheDelete.js +0 -14
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheGet.js +0 -13
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheHas.js +0 -13
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheSet.js +0 -14
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_nativeCreate.js +0 -9
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_objectToString.js +0 -12
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_root.js +0 -10
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_toSource.js +0 -20
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/eq.js +0 -11
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/isFunction.js +0 -16
- package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/isObject.js +0 -12
- package/dist/node_modules/.bun/lodash@4.18.1/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,375 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@pie-lib/test-utils';
|
|
3
|
+
import { createTheme, ThemeProvider } from '@mui/material/styles';
|
|
4
|
+
import Line, { LinePlot } from '../line';
|
|
5
|
+
import { graphProps } from './utils';
|
|
6
|
+
|
|
7
|
+
jest.mock('@mui/icons-material/Check', () => {
|
|
8
|
+
return function Check(props) {
|
|
9
|
+
return <div data-testid="check-icon" {...props} />;
|
|
10
|
+
};
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
jest.mock('@visx/shape', () => ({
|
|
14
|
+
LinePath: ({ data, x, y, ...rest }) => (
|
|
15
|
+
<path d={data.map((d, i) => `${i === 0 ? 'M' : 'L'}${x(d)},${y(d)}`).join(' ')} {...rest} />
|
|
16
|
+
),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
jest.mock('@visx/group', () => ({
|
|
20
|
+
Group: ({ children }) => <g className="visx-group">{children}</g>,
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
let theme;
|
|
24
|
+
|
|
25
|
+
beforeAll(() => {
|
|
26
|
+
theme = createTheme();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe('LinePlot', () => {
|
|
30
|
+
const renderComponent = (extras) => {
|
|
31
|
+
const defaults = {
|
|
32
|
+
classes: {},
|
|
33
|
+
className: 'className',
|
|
34
|
+
graphProps: graphProps(),
|
|
35
|
+
xBand: () => {
|
|
36
|
+
return {
|
|
37
|
+
bandwidth: () => {},
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
const props = { ...defaults, ...extras };
|
|
42
|
+
return render(
|
|
43
|
+
<ThemeProvider theme={theme}>
|
|
44
|
+
<svg>
|
|
45
|
+
<LinePlot {...props} />
|
|
46
|
+
</svg>
|
|
47
|
+
</ThemeProvider>,
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
describe('rendering', () => {
|
|
52
|
+
it('renders line plot', () => {
|
|
53
|
+
const { container } = renderComponent();
|
|
54
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('renders without graphProps', () => {
|
|
58
|
+
const { container } = renderComponent({ graphProps: undefined });
|
|
59
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('renders with data array', () => {
|
|
63
|
+
const data = [
|
|
64
|
+
{ value: 1, label: 'A' },
|
|
65
|
+
{ value: 2, label: 'B' },
|
|
66
|
+
{ value: 3, label: 'C' },
|
|
67
|
+
];
|
|
68
|
+
const { container } = renderComponent({ data });
|
|
69
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('renders with empty data array', () => {
|
|
73
|
+
const { container } = renderComponent({ data: [] });
|
|
74
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('renders with null data', () => {
|
|
78
|
+
const { container } = renderComponent({ data: null });
|
|
79
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('renders with undefined data', () => {
|
|
83
|
+
const { container } = renderComponent({ data: undefined });
|
|
84
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('renders with custom className', () => {
|
|
88
|
+
const { container } = renderComponent({ className: 'custom-line-plot' });
|
|
89
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('renders with onChange handler', () => {
|
|
93
|
+
const onChange = jest.fn();
|
|
94
|
+
const { container } = renderComponent({ onChange });
|
|
95
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('renders in defineChart mode', () => {
|
|
99
|
+
const { container } = renderComponent({ defineChart: true });
|
|
100
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('renders with correctData', () => {
|
|
104
|
+
const data = [{ value: 2, label: 'A' }];
|
|
105
|
+
const correctData = [{ value: 3, label: 'A' }];
|
|
106
|
+
const { container } = renderComponent({ data, correctData });
|
|
107
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe('graphProps handling', () => {
|
|
112
|
+
it('handles graphProps with missing scale', () => {
|
|
113
|
+
const props = graphProps();
|
|
114
|
+
delete props.scale;
|
|
115
|
+
const { container } = renderComponent({ graphProps: props });
|
|
116
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('handles graphProps with missing size', () => {
|
|
120
|
+
const props = graphProps();
|
|
121
|
+
delete props.size;
|
|
122
|
+
const { container } = renderComponent({ graphProps: props });
|
|
123
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('handles graphProps with empty scale object', () => {
|
|
127
|
+
const props = graphProps();
|
|
128
|
+
props.scale = {};
|
|
129
|
+
const { container } = renderComponent({ graphProps: props });
|
|
130
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('handles graphProps with empty size object', () => {
|
|
134
|
+
const props = graphProps();
|
|
135
|
+
props.size = {};
|
|
136
|
+
const { container } = renderComponent({ graphProps: props });
|
|
137
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
describe('data variations', () => {
|
|
142
|
+
it('renders with single data point', () => {
|
|
143
|
+
const data = [{ value: 1, label: 'A' }];
|
|
144
|
+
const { container } = renderComponent({ data });
|
|
145
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('renders with multiple data points', () => {
|
|
149
|
+
const data = [
|
|
150
|
+
{ value: 1, label: 'A' },
|
|
151
|
+
{ value: 2, label: 'B' },
|
|
152
|
+
{ value: 3, label: 'C' },
|
|
153
|
+
{ value: 4, label: 'D' },
|
|
154
|
+
];
|
|
155
|
+
const { container } = renderComponent({ data });
|
|
156
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('renders with zero values', () => {
|
|
160
|
+
const data = [
|
|
161
|
+
{ value: 0, label: 'A' },
|
|
162
|
+
{ value: 0, label: 'B' },
|
|
163
|
+
];
|
|
164
|
+
const { container } = renderComponent({ data });
|
|
165
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it('renders with mixed values', () => {
|
|
169
|
+
const data = [
|
|
170
|
+
{ value: 0, label: 'A' },
|
|
171
|
+
{ value: 5, label: 'B' },
|
|
172
|
+
{ value: 1, label: 'C' },
|
|
173
|
+
];
|
|
174
|
+
const { container } = renderComponent({ data });
|
|
175
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('renders with large values', () => {
|
|
179
|
+
const data = [
|
|
180
|
+
{ value: 100, label: 'A' },
|
|
181
|
+
{ value: 200, label: 'B' },
|
|
182
|
+
];
|
|
183
|
+
const { container } = renderComponent({ data });
|
|
184
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it('renders with correctness data', () => {
|
|
188
|
+
const data = [
|
|
189
|
+
{ value: 2, label: 'A', correctness: { value: 'correct', label: 'Correct' } },
|
|
190
|
+
{ value: 3, label: 'B', correctness: { value: 'correct', label: 'Correct' } },
|
|
191
|
+
];
|
|
192
|
+
const { container } = renderComponent({ data });
|
|
193
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it('renders with incorrect correctness and correctData', () => {
|
|
197
|
+
const data = [
|
|
198
|
+
{ value: 2, label: 'A', correctness: { value: 'incorrect', label: 'Incorrect' } },
|
|
199
|
+
{ value: 3, label: 'B', correctness: { value: 'incorrect', label: 'Incorrect' } },
|
|
200
|
+
];
|
|
201
|
+
const correctData = [
|
|
202
|
+
{ value: 3, label: 'A' },
|
|
203
|
+
{ value: 4, label: 'B' },
|
|
204
|
+
];
|
|
205
|
+
const { container } = renderComponent({ data, correctData });
|
|
206
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it('renders with interactive data points', () => {
|
|
210
|
+
const data = [
|
|
211
|
+
{ value: 2, label: 'A', interactive: true },
|
|
212
|
+
{ value: 3, label: 'B', interactive: false },
|
|
213
|
+
];
|
|
214
|
+
const { container } = renderComponent({ data });
|
|
215
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
describe('callbacks', () => {
|
|
220
|
+
it('passes onChange handler to Plot component', () => {
|
|
221
|
+
const onChange = jest.fn();
|
|
222
|
+
const data = [{ value: 1, label: 'A' }];
|
|
223
|
+
const { container } = renderComponent({ data, onChange });
|
|
224
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it('handles onChangeCategory callback', () => {
|
|
228
|
+
const onChangeCategory = jest.fn();
|
|
229
|
+
const data = [{ value: 1, label: 'A' }];
|
|
230
|
+
const { container } = renderComponent({ data, onChangeCategory });
|
|
231
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
describe('component', () => {
|
|
236
|
+
it('returns correct chart object', () => {
|
|
237
|
+
const chart = Line();
|
|
238
|
+
|
|
239
|
+
expect(chart).toEqual({
|
|
240
|
+
type: 'linePlot',
|
|
241
|
+
Component: LinePlot,
|
|
242
|
+
name: 'Line Plot',
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it('returns object with Component that can be rendered', () => {
|
|
247
|
+
const chart = Line();
|
|
248
|
+
const { Component } = chart;
|
|
249
|
+
|
|
250
|
+
const { container } = render(<Component graphProps={graphProps()} />);
|
|
251
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
describe('CustomBarElement (Line)', () => {
|
|
257
|
+
const renderLinePlot = (props) =>
|
|
258
|
+
render(
|
|
259
|
+
<ThemeProvider theme={theme}>
|
|
260
|
+
<svg>
|
|
261
|
+
<LinePlot {...props} />
|
|
262
|
+
</svg>
|
|
263
|
+
</ThemeProvider>,
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
it('renders line elements', () => {
|
|
267
|
+
const data = [{ value: 1, label: 'A' }];
|
|
268
|
+
const { container } = renderLinePlot({
|
|
269
|
+
data,
|
|
270
|
+
graphProps: graphProps(),
|
|
271
|
+
});
|
|
272
|
+
expect(container).toBeInTheDocument();
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
it('renders with dottedOverline prop', () => {
|
|
276
|
+
const data = [{ value: 2, label: 'A', correctness: { value: 'incorrect' } }];
|
|
277
|
+
const correctData = [{ value: 3, label: 'A' }];
|
|
278
|
+
const { container } = renderLinePlot({
|
|
279
|
+
data,
|
|
280
|
+
graphProps: graphProps(),
|
|
281
|
+
correctData,
|
|
282
|
+
});
|
|
283
|
+
expect(container).toBeInTheDocument();
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it('renders without dottedOverline prop', () => {
|
|
287
|
+
const data = [{ value: 2, label: 'A' }];
|
|
288
|
+
const { container } = renderLinePlot({
|
|
289
|
+
data,
|
|
290
|
+
graphProps: graphProps(),
|
|
291
|
+
});
|
|
292
|
+
expect(container).toBeInTheDocument();
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
it('renders two LinePath elements for X shape when not dotted', () => {
|
|
296
|
+
const data = [{ value: 3, label: 'A' }];
|
|
297
|
+
const { container } = renderLinePlot({
|
|
298
|
+
data,
|
|
299
|
+
graphProps: graphProps(),
|
|
300
|
+
});
|
|
301
|
+
expect(container).toBeInTheDocument();
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
it('renders rect with dashed stroke when dottedOverline is true', () => {
|
|
305
|
+
const data = [{ value: 2, label: 'A', correctness: { value: 'incorrect' } }];
|
|
306
|
+
const correctData = [{ value: 3, label: 'A' }];
|
|
307
|
+
const { container } = renderLinePlot({
|
|
308
|
+
data,
|
|
309
|
+
graphProps: graphProps(),
|
|
310
|
+
correctData,
|
|
311
|
+
});
|
|
312
|
+
expect(container).toBeInTheDocument();
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it('calculates correct line positions', () => {
|
|
316
|
+
const data = [{ value: 2, label: 'A' }];
|
|
317
|
+
const { container } = renderLinePlot({
|
|
318
|
+
data,
|
|
319
|
+
graphProps: graphProps(),
|
|
320
|
+
});
|
|
321
|
+
expect(container).toBeInTheDocument();
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
it('handles zero pointDiameter', () => {
|
|
325
|
+
const props = graphProps();
|
|
326
|
+
props.size = { width: 0, height: 0 };
|
|
327
|
+
const data = [{ value: 1, label: 'A' }];
|
|
328
|
+
const { container } = renderLinePlot({
|
|
329
|
+
data,
|
|
330
|
+
graphProps: props,
|
|
331
|
+
});
|
|
332
|
+
expect(container).toBeInTheDocument();
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
it('handles large pointDiameter values', () => {
|
|
336
|
+
const props = graphProps();
|
|
337
|
+
props.size = { width: 1000, height: 1000 };
|
|
338
|
+
const data = [{ value: 1, label: 'A' }];
|
|
339
|
+
const { container } = renderLinePlot({
|
|
340
|
+
data,
|
|
341
|
+
graphProps: props,
|
|
342
|
+
});
|
|
343
|
+
expect(container).toBeInTheDocument();
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
it('applies correct strokeWidth based on pointDiameter', () => {
|
|
347
|
+
const data = [{ value: 2, label: 'A' }];
|
|
348
|
+
const { container } = renderLinePlot({
|
|
349
|
+
data,
|
|
350
|
+
graphProps: graphProps(),
|
|
351
|
+
});
|
|
352
|
+
// strokeWidth should be pointDiameter / 5
|
|
353
|
+
expect(container).toBeInTheDocument();
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
it('renders Group component wrapping LinePaths', () => {
|
|
357
|
+
const data = [{ value: 1, label: 'A' }];
|
|
358
|
+
const { container } = renderLinePlot({
|
|
359
|
+
data,
|
|
360
|
+
graphProps: graphProps(),
|
|
361
|
+
});
|
|
362
|
+
expect(container).toBeInTheDocument();
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
it('handles rect with extra padding when dotted', () => {
|
|
366
|
+
const data = [{ value: 2, label: 'A', correctness: { value: 'incorrect' } }];
|
|
367
|
+
const correctData = [{ value: 3, label: 'A' }];
|
|
368
|
+
const { container } = renderLinePlot({
|
|
369
|
+
data,
|
|
370
|
+
graphProps: graphProps(),
|
|
371
|
+
correctData,
|
|
372
|
+
});
|
|
373
|
+
expect(container).toBeInTheDocument();
|
|
374
|
+
});
|
|
375
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const scaleMock = () => {
|
|
2
|
+
const fn = jest.fn((n) => n);
|
|
3
|
+
fn.invert = jest.fn((n) => n);
|
|
4
|
+
return fn;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export const graphProps = (dmin = 0, dmax = 1, rmin = 0, rmax = 1) => ({
|
|
8
|
+
scale: {
|
|
9
|
+
x: scaleMock(),
|
|
10
|
+
y: scaleMock(),
|
|
11
|
+
},
|
|
12
|
+
snap: {
|
|
13
|
+
x: jest.fn((n) => n),
|
|
14
|
+
y: jest.fn((n) => n),
|
|
15
|
+
},
|
|
16
|
+
domain: {
|
|
17
|
+
min: dmin,
|
|
18
|
+
max: dmax,
|
|
19
|
+
step: 1,
|
|
20
|
+
},
|
|
21
|
+
range: {
|
|
22
|
+
min: rmin,
|
|
23
|
+
max: rmax,
|
|
24
|
+
step: 1,
|
|
25
|
+
},
|
|
26
|
+
size: {
|
|
27
|
+
width: 400,
|
|
28
|
+
height: 400,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { render } from '@testing-library/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Plot, { RawPlot } from '../plot';
|
|
4
|
+
import { graphProps } from './utils';
|
|
5
|
+
|
|
6
|
+
describe('Plot', () => {
|
|
7
|
+
const xBand = () => {};
|
|
8
|
+
xBand.bandwidth = () => {};
|
|
9
|
+
const onChange = jest.fn();
|
|
10
|
+
|
|
11
|
+
const renderComponent = (extras) => {
|
|
12
|
+
const defaults = {
|
|
13
|
+
classes: {},
|
|
14
|
+
className: 'className',
|
|
15
|
+
graphProps: graphProps(),
|
|
16
|
+
xBand,
|
|
17
|
+
onChange,
|
|
18
|
+
data: [{ value: 0, label: '0' }],
|
|
19
|
+
};
|
|
20
|
+
const props = { ...defaults, ...extras };
|
|
21
|
+
return render(<Plot {...props} />);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
describe('rendering', () => {
|
|
25
|
+
it('renders without crashing', () => {
|
|
26
|
+
const { container } = renderComponent();
|
|
27
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe('RawPlot', () => {
|
|
33
|
+
const xBand = () => {};
|
|
34
|
+
xBand.bandwidth = () => {};
|
|
35
|
+
const onChangeCategory = jest.fn();
|
|
36
|
+
|
|
37
|
+
const renderComponent = (extras) => {
|
|
38
|
+
const defaults = {
|
|
39
|
+
classes: {},
|
|
40
|
+
className: 'className',
|
|
41
|
+
graphProps: graphProps(),
|
|
42
|
+
xBand,
|
|
43
|
+
onChangeCategory,
|
|
44
|
+
data: [],
|
|
45
|
+
label: 'label',
|
|
46
|
+
CustomBarElement: () => <div />,
|
|
47
|
+
};
|
|
48
|
+
const props = { ...defaults, ...extras };
|
|
49
|
+
return render(<RawPlot {...props} />);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
describe('rendering', () => {
|
|
53
|
+
it('renders without crashing', () => {
|
|
54
|
+
const { container } = renderComponent();
|
|
55
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe('functionality', () => {
|
|
60
|
+
it('calls onChangeCategory when drag completes with a value', () => {
|
|
61
|
+
const { container } = renderComponent();
|
|
62
|
+
// Testing drag functionality requires interaction - the component should
|
|
63
|
+
// call onChangeCategory when a drag operation completes with a new value
|
|
64
|
+
// This would typically be tested through user interactions rather than
|
|
65
|
+
// directly calling instance methods
|
|
66
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const scaleMock = () => {
|
|
2
|
+
const fn = jest.fn((n) => n);
|
|
3
|
+
fn.invert = jest.fn((n) => n);
|
|
4
|
+
return fn;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export const graphProps = (dmin = 0, dmax = 1, rmin = 0, rmax = 1) => ({
|
|
8
|
+
scale: {
|
|
9
|
+
x: scaleMock(),
|
|
10
|
+
y: scaleMock(),
|
|
11
|
+
},
|
|
12
|
+
snap: {
|
|
13
|
+
x: jest.fn((n) => n),
|
|
14
|
+
y: jest.fn((n) => n),
|
|
15
|
+
},
|
|
16
|
+
domain: {
|
|
17
|
+
min: dmin,
|
|
18
|
+
max: dmax,
|
|
19
|
+
step: 1,
|
|
20
|
+
},
|
|
21
|
+
range: {
|
|
22
|
+
min: rmin,
|
|
23
|
+
max: rmax,
|
|
24
|
+
step: 1,
|
|
25
|
+
},
|
|
26
|
+
size: {
|
|
27
|
+
width: 400,
|
|
28
|
+
height: 400,
|
|
29
|
+
},
|
|
30
|
+
});
|