@pie-lib/graphing 4.0.5-next.3 → 4.0.5-next.31
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/autosize-input.d.ts +10 -0
- package/dist/autosize-input.js +66 -0
- package/dist/axis/arrow.d.ts +13 -0
- package/dist/axis/arrow.js +34 -0
- package/dist/axis/axes.d.ts +132 -0
- package/dist/axis/axes.js +214 -0
- package/dist/axis/index.d.ts +10 -0
- package/dist/bg.d.ts +51 -0
- package/dist/bg.js +44 -0
- package/dist/container/actions.d.ts +15 -0
- package/dist/container/actions.js +7 -0
- package/dist/container/index.d.ts +58 -0
- package/dist/container/index.js +48 -0
- package/dist/container/marks.d.ts +10 -0
- package/dist/container/marks.js +11 -0
- package/dist/container/middleware.d.ts +10 -0
- package/dist/container/middleware.js +4 -0
- package/dist/container/reducer.d.ts +14 -0
- package/dist/container/reducer.js +7 -0
- package/dist/coordinates-label.d.ts +50 -0
- package/dist/coordinates-label.js +46 -0
- package/dist/graph-with-controls.d.ts +88 -0
- package/dist/graph-with-controls.js +154 -0
- package/dist/graph.d.ts +126 -0
- package/dist/graph.js +209 -0
- package/dist/grid-setup.d.ts +27 -0
- package/dist/grid-setup.js +307 -0
- package/dist/grid.d.ts +43 -0
- package/dist/grid.js +59 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +7 -0
- package/dist/key-legend.d.ts +21 -0
- package/dist/key-legend.js +231 -0
- package/dist/label-svg-icon.d.ts +18 -0
- package/dist/label-svg-icon.js +42 -0
- package/dist/labels.d.ts +37 -0
- package/dist/labels.js +152 -0
- package/dist/mark-label.d.ts +58 -0
- package/dist/mark-label.js +171 -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/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_curve@3.12.0/node_modules/@visx/curve/esm/index.js +2 -0
- package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/Grid.js +79 -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/utils/coerceNumber.js +10 -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/toString.js +6 -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/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/invariant@2.2.4/node_modules/invariant/browser.js +28 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_Hash.js +21 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_ListCache.js +21 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_Map.js +10 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_MapCache.js +21 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_Symbol.js +9 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_assocIndexOf.js +14 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_baseGetTag.js +15 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_baseIsNative.js +16 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_coreJsData.js +9 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_freeGlobal.js +8 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_getMapData.js +14 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_getNative.js +15 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_getRawTag.js +19 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_getValue.js +11 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashClear.js +13 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashDelete.js +12 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashGet.js +18 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashHas.js +14 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashSet.js +14 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_isKeyable.js +12 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_isMasked.js +16 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheClear.js +11 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheDelete.js +14 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheGet.js +14 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheHas.js +13 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheSet.js +14 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheClear.js +19 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheDelete.js +14 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheGet.js +13 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheHas.js +13 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheSet.js +14 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_nativeCreate.js +9 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_objectToString.js +12 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_root.js +10 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_toSource.js +20 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/eq.js +11 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/isFunction.js +16 -0
- package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/isObject.js +12 -0
- package/dist/node_modules/.bun/lodash@4.17.21/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/react-redux@9.3.0_9e2203c65d1d5fa1/node_modules/react-redux/dist/react-redux.js +471 -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/node_modules/.bun/redux-undo@1.1.0/node_modules/redux-undo/dist/redux-undo.js +185 -0
- package/dist/node_modules/.bun/redux@5.0.1/node_modules/redux/dist/redux.js +198 -0
- package/dist/node_modules/.bun/use-sync-external-store@1.6.0_f4eacebf2041cd4f/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.development.js +53 -0
- package/dist/node_modules/.bun/use-sync-external-store@1.6.0_f4eacebf2041cd4f/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.production.js +51 -0
- package/dist/node_modules/.bun/use-sync-external-store@1.6.0_f4eacebf2041cd4f/node_modules/use-sync-external-store/with-selector.js +10 -0
- package/dist/toggle-bar.d.ts +40 -0
- package/dist/toggle-bar.js +155 -0
- package/dist/tool-menu.d.ts +29 -0
- package/dist/tool-menu.js +41 -0
- package/dist/tools/absolute/component.d.ts +16 -0
- package/dist/tools/absolute/component.js +15 -0
- package/dist/tools/absolute/index.d.ts +20 -0
- package/dist/tools/absolute/index.js +32 -0
- package/dist/tools/circle/bg-circle.d.ts +116 -0
- package/dist/tools/circle/bg-circle.js +72 -0
- package/dist/tools/circle/component.d.ts +83 -0
- package/dist/tools/circle/component.js +195 -0
- package/dist/tools/circle/index.d.ts +20 -0
- package/dist/tools/circle/index.js +22 -0
- package/dist/tools/exponential/component.d.ts +16 -0
- package/dist/tools/exponential/component.js +14 -0
- package/dist/tools/exponential/index.d.ts +20 -0
- package/dist/tools/exponential/index.js +32 -0
- package/dist/tools/index.d.ts +27 -0
- package/dist/tools/index.js +55 -0
- package/dist/tools/line/component.d.ts +124 -0
- package/dist/tools/line/component.js +72 -0
- package/dist/tools/line/index.d.ts +13 -0
- package/dist/tools/line/index.js +6 -0
- package/dist/tools/parabola/component.d.ts +16 -0
- package/dist/tools/parabola/component.js +14 -0
- package/dist/tools/parabola/index.d.ts +20 -0
- package/dist/tools/parabola/index.js +32 -0
- package/dist/tools/point/component.d.ts +50 -0
- package/dist/tools/point/component.js +85 -0
- package/dist/tools/point/index.d.ts +15 -0
- package/dist/tools/point/index.js +13 -0
- package/dist/tools/polygon/component.d.ts +120 -0
- package/dist/tools/polygon/component.js +262 -0
- package/dist/tools/polygon/index.d.ts +19 -0
- package/dist/tools/polygon/index.js +55 -0
- package/dist/tools/polygon/line.d.ts +125 -0
- package/dist/tools/polygon/line.js +63 -0
- package/dist/tools/polygon/polygon.d.ts +122 -0
- package/dist/tools/polygon/polygon.js +74 -0
- package/dist/tools/ray/component.d.ts +101 -0
- package/dist/tools/ray/component.js +71 -0
- package/dist/tools/ray/index.d.ts +13 -0
- package/dist/tools/ray/index.js +6 -0
- package/dist/tools/segment/component.d.ts +100 -0
- package/dist/tools/segment/component.js +52 -0
- package/dist/tools/segment/index.d.ts +13 -0
- package/dist/tools/segment/index.js +6 -0
- package/dist/tools/shared/arrow-head.d.ts +51 -0
- package/dist/tools/shared/arrow-head.js +63 -0
- package/dist/tools/shared/icons/CorrectSVG.d.ts +26 -0
- package/dist/tools/shared/icons/CorrectSVG.js +29 -0
- package/dist/tools/shared/icons/IncorrectSVG.d.ts +26 -0
- package/dist/tools/shared/icons/IncorrectSVG.js +27 -0
- package/dist/tools/shared/icons/MissingSVG.d.ts +26 -0
- package/dist/tools/shared/icons/MissingSVG.js +28 -0
- package/dist/tools/shared/line/index.d.ts +245 -0
- package/dist/tools/shared/line/index.js +319 -0
- package/dist/tools/shared/line/line-path.d.ts +57 -0
- package/dist/tools/shared/line/line-path.js +71 -0
- package/dist/tools/shared/line/with-root-edge.d.ts +142 -0
- package/dist/tools/shared/line/with-root-edge.js +73 -0
- package/dist/tools/shared/point/arrow-point.d.ts +56 -0
- package/dist/tools/shared/point/arrow-point.js +41 -0
- package/dist/tools/shared/point/arrow.d.ts +45 -0
- package/dist/tools/shared/point/arrow.js +35 -0
- package/dist/tools/shared/point/base-point.d.ts +52 -0
- package/dist/tools/shared/point/base-point.js +103 -0
- package/dist/tools/shared/point/index.d.ts +216 -0
- package/dist/tools/shared/point/index.js +45 -0
- package/dist/tools/shared/styles.d.ts +29 -0
- package/dist/tools/shared/styles.js +20 -0
- package/dist/tools/shared/types.d.ts +21 -0
- package/dist/tools/shared/types.js +11 -0
- package/dist/tools/sine/component.d.ts +16 -0
- package/dist/tools/sine/component.js +22 -0
- package/dist/tools/sine/index.d.ts +20 -0
- package/dist/tools/sine/index.js +32 -0
- package/dist/tools/vector/component.d.ts +100 -0
- package/dist/tools/vector/component.js +44 -0
- package/dist/tools/vector/index.d.ts +13 -0
- package/dist/tools/vector/index.js +6 -0
- package/dist/undo-redo.d.ts +22 -0
- package/dist/undo-redo.js +47 -0
- package/dist/use-debounce.d.ts +9 -0
- package/dist/use-debounce.js +13 -0
- package/dist/utils.d.ts +61 -0
- package/dist/utils.js +75 -0
- package/package.json +45 -33
- package/CHANGELOG.json +0 -1
- package/CHANGELOG.md +0 -1469
- package/LICENSE.md +0 -5
- package/lib/axis/arrow.js +0 -79
- package/lib/axis/arrow.js.map +0 -1
- package/lib/axis/axes.js +0 -329
- package/lib/axis/axes.js.map +0 -1
- package/lib/axis/index.js +0 -21
- package/lib/axis/index.js.map +0 -1
- package/lib/bg.js +0 -114
- package/lib/bg.js.map +0 -1
- package/lib/container/actions.js +0 -18
- package/lib/container/actions.js.map +0 -1
- package/lib/container/index.js +0 -118
- package/lib/container/index.js.map +0 -1
- package/lib/container/marks.js +0 -22
- package/lib/container/marks.js.map +0 -1
- package/lib/container/middleware.js +0 -19
- package/lib/container/middleware.js.map +0 -1
- package/lib/container/reducer.js +0 -18
- package/lib/container/reducer.js.map +0 -1
- package/lib/coordinates-label.js +0 -79
- package/lib/coordinates-label.js.map +0 -1
- package/lib/graph-with-controls.js +0 -294
- package/lib/graph-with-controls.js.map +0 -1
- package/lib/graph.js +0 -327
- package/lib/graph.js.map +0 -1
- package/lib/grid-setup.js +0 -414
- package/lib/grid-setup.js.map +0 -1
- package/lib/grid.js +0 -131
- package/lib/grid.js.map +0 -1
- package/lib/index.js +0 -47
- package/lib/index.js.map +0 -1
- package/lib/key-legend.js +0 -201
- package/lib/key-legend.js.map +0 -1
- package/lib/label-svg-icon.js +0 -50
- package/lib/label-svg-icon.js.map +0 -1
- package/lib/labels.js +0 -243
- package/lib/labels.js.map +0 -1
- package/lib/mark-label.js +0 -285
- package/lib/mark-label.js.map +0 -1
- package/lib/toggle-bar.js +0 -252
- package/lib/toggle-bar.js.map +0 -1
- package/lib/tool-menu.js +0 -78
- package/lib/tool-menu.js.map +0 -1
- package/lib/tools/absolute/component.js +0 -29
- package/lib/tools/absolute/component.js.map +0 -1
- package/lib/tools/absolute/index.js +0 -50
- package/lib/tools/absolute/index.js.map +0 -1
- package/lib/tools/circle/bg-circle.js +0 -123
- package/lib/tools/circle/bg-circle.js.map +0 -1
- package/lib/tools/circle/component.js +0 -321
- package/lib/tools/circle/component.js.map +0 -1
- package/lib/tools/circle/index.js +0 -41
- package/lib/tools/circle/index.js.map +0 -1
- package/lib/tools/exponential/component.js +0 -28
- package/lib/tools/exponential/component.js.map +0 -1
- package/lib/tools/exponential/index.js +0 -56
- package/lib/tools/exponential/index.js.map +0 -1
- package/lib/tools/index.js +0 -86
- package/lib/tools/index.js.map +0 -1
- package/lib/tools/line/component.js +0 -97
- package/lib/tools/line/component.js.map +0 -1
- package/lib/tools/line/index.js +0 -11
- package/lib/tools/line/index.js.map +0 -1
- package/lib/tools/parabola/component.js +0 -28
- package/lib/tools/parabola/component.js.map +0 -1
- package/lib/tools/parabola/index.js +0 -50
- package/lib/tools/parabola/index.js.map +0 -1
- package/lib/tools/point/component.js +0 -148
- package/lib/tools/point/component.js.map +0 -1
- package/lib/tools/point/index.js +0 -24
- package/lib/tools/point/index.js.map +0 -1
- package/lib/tools/polygon/component.js +0 -437
- package/lib/tools/polygon/component.js.map +0 -1
- package/lib/tools/polygon/index.js +0 -89
- package/lib/tools/polygon/index.js.map +0 -1
- package/lib/tools/polygon/line.js +0 -112
- package/lib/tools/polygon/line.js.map +0 -1
- package/lib/tools/polygon/polygon.js +0 -130
- package/lib/tools/polygon/polygon.js.map +0 -1
- package/lib/tools/ray/component.js +0 -95
- package/lib/tools/ray/component.js.map +0 -1
- package/lib/tools/ray/index.js +0 -11
- package/lib/tools/ray/index.js.map +0 -1
- package/lib/tools/segment/component.js +0 -71
- package/lib/tools/segment/component.js.map +0 -1
- package/lib/tools/segment/index.js +0 -11
- package/lib/tools/segment/index.js.map +0 -1
- package/lib/tools/shared/arrow-head.js +0 -111
- package/lib/tools/shared/arrow-head.js.map +0 -1
- package/lib/tools/shared/icons/CorrectSVG.js +0 -40
- package/lib/tools/shared/icons/CorrectSVG.js.map +0 -1
- package/lib/tools/shared/icons/IncorrectSVG.js +0 -40
- package/lib/tools/shared/icons/IncorrectSVG.js.map +0 -1
- package/lib/tools/shared/icons/MissingSVG.js +0 -39
- package/lib/tools/shared/icons/MissingSVG.js.map +0 -1
- package/lib/tools/shared/line/index.js +0 -550
- package/lib/tools/shared/line/index.js.map +0 -1
- package/lib/tools/shared/line/line-path.js +0 -118
- package/lib/tools/shared/line/line-path.js.map +0 -1
- package/lib/tools/shared/line/with-root-edge.js +0 -121
- package/lib/tools/shared/line/with-root-edge.js.map +0 -1
- package/lib/tools/shared/point/arrow-point.js +0 -72
- package/lib/tools/shared/point/arrow-point.js.map +0 -1
- package/lib/tools/shared/point/arrow.js +0 -67
- package/lib/tools/shared/point/arrow.js.map +0 -1
- package/lib/tools/shared/point/base-point.js +0 -157
- package/lib/tools/shared/point/base-point.js.map +0 -1
- package/lib/tools/shared/point/index.js +0 -68
- package/lib/tools/shared/point/index.js.map +0 -1
- package/lib/tools/shared/styles.js +0 -33
- package/lib/tools/shared/styles.js.map +0 -1
- package/lib/tools/shared/types.js +0 -16
- package/lib/tools/shared/types.js.map +0 -1
- package/lib/tools/sine/component.js +0 -40
- package/lib/tools/sine/component.js.map +0 -1
- package/lib/tools/sine/index.js +0 -50
- package/lib/tools/sine/index.js.map +0 -1
- package/lib/tools/vector/component.js +0 -68
- package/lib/tools/vector/component.js.map +0 -1
- package/lib/tools/vector/index.js +0 -11
- package/lib/tools/vector/index.js.map +0 -1
- package/lib/undo-redo.js +0 -86
- package/lib/undo-redo.js.map +0 -1
- package/lib/use-debounce.js +0 -25
- package/lib/use-debounce.js.map +0 -1
- package/lib/utils.js +0 -229
- package/lib/utils.js.map +0 -1
- package/src/__tests__/bg.test.jsx +0 -250
- package/src/__tests__/coordinates-label.test.jsx +0 -243
- package/src/__tests__/graph-with-controls.test.jsx +0 -198
- package/src/__tests__/graph.test.jsx +0 -721
- package/src/__tests__/grid-setup.test.jsx +0 -645
- package/src/__tests__/grid.test.jsx +0 -22
- package/src/__tests__/key-legend.test.jsx +0 -260
- package/src/__tests__/label-svg-icon.test.jsx +0 -278
- package/src/__tests__/labels.test.jsx +0 -55
- package/src/__tests__/mark-label.test.jsx +0 -63
- package/src/__tests__/toggle-bar.test.jsx +0 -146
- package/src/__tests__/tool-menu.test.jsx +0 -115
- package/src/__tests__/undo-redo.test.jsx +0 -24
- package/src/__tests__/use-debounce.test.js +0 -21
- package/src/__tests__/utils.js +0 -41
- package/src/__tests__/utils.test.js +0 -105
- package/src/axis/__tests__/arrow.test.jsx +0 -38
- package/src/axis/__tests__/axes.test.jsx +0 -216
- package/src/axis/arrow.jsx +0 -57
- package/src/axis/axes.jsx +0 -285
- package/src/axis/index.js +0 -3
- package/src/bg.jsx +0 -96
- package/src/container/__tests__/actions.test.js +0 -105
- package/src/container/__tests__/index.test.jsx +0 -319
- package/src/container/__tests__/marks.test.js +0 -172
- package/src/container/__tests__/middleware.test.js +0 -235
- package/src/container/__tests__/reducer.test.js +0 -324
- package/src/container/actions.js +0 -8
- package/src/container/index.jsx +0 -83
- package/src/container/marks.js +0 -14
- package/src/container/middleware.js +0 -7
- package/src/container/reducer.js +0 -5
- package/src/coordinates-label.jsx +0 -63
- package/src/graph-with-controls.jsx +0 -239
- package/src/graph.jsx +0 -303
- package/src/grid-setup.jsx +0 -432
- package/src/grid.jsx +0 -133
- package/src/index.js +0 -7
- package/src/key-legend.jsx +0 -142
- package/src/label-svg-icon.jsx +0 -39
- package/src/labels.jsx +0 -207
- package/src/mark-label.jsx +0 -244
- package/src/toggle-bar.jsx +0 -224
- package/src/tool-menu.jsx +0 -49
- package/src/tools/absolute/__tests__/component.test.jsx +0 -53
- package/src/tools/absolute/component.jsx +0 -23
- package/src/tools/absolute/index.js +0 -31
- package/src/tools/circle/__tests__/bg-circle.test.jsx +0 -26
- package/src/tools/circle/__tests__/component.test.jsx +0 -494
- package/src/tools/circle/__tests__/index.test.js +0 -480
- package/src/tools/circle/bg-circle.jsx +0 -81
- package/src/tools/circle/component.jsx +0 -264
- package/src/tools/circle/index.js +0 -25
- package/src/tools/exponential/__tests__/component.test.jsx +0 -53
- package/src/tools/exponential/__tests__/index.test.js +0 -729
- package/src/tools/exponential/component.jsx +0 -23
- package/src/tools/exponential/index.js +0 -39
- package/src/tools/index.js +0 -48
- package/src/tools/line/__tests__/component.test.jsx +0 -37
- package/src/tools/line/component.jsx +0 -93
- package/src/tools/line/index.js +0 -4
- package/src/tools/parabola/__tests__/component.test.jsx +0 -48
- package/src/tools/parabola/__tests__/index.test.js +0 -470
- package/src/tools/parabola/component.jsx +0 -23
- package/src/tools/parabola/index.js +0 -31
- package/src/tools/point/__tests__/component.test.jsx +0 -349
- package/src/tools/point/__tests__/index.test.js +0 -241
- package/src/tools/point/component.jsx +0 -126
- package/src/tools/point/index.js +0 -11
- package/src/tools/polygon/__tests__/component.test.jsx +0 -471
- package/src/tools/polygon/__tests__/index.test.js +0 -294
- package/src/tools/polygon/__tests__/line.test.jsx +0 -35
- package/src/tools/polygon/__tests__/polygon.test.jsx +0 -61
- package/src/tools/polygon/component.jsx +0 -409
- package/src/tools/polygon/index.js +0 -52
- package/src/tools/polygon/line.jsx +0 -74
- package/src/tools/polygon/polygon.jsx +0 -110
- package/src/tools/ray/__tests__/component.test.jsx +0 -29
- package/src/tools/ray/component.jsx +0 -92
- package/src/tools/ray/index.js +0 -4
- package/src/tools/segment/__tests__/component.test.jsx +0 -28
- package/src/tools/segment/component.jsx +0 -65
- package/src/tools/segment/index.js +0 -4
- package/src/tools/shared/__tests__/arrow-head.test.jsx +0 -31
- package/src/tools/shared/arrow-head.jsx +0 -102
- package/src/tools/shared/icons/CorrectSVG.jsx +0 -32
- package/src/tools/shared/icons/IncorrectSVG.jsx +0 -30
- package/src/tools/shared/icons/MissingSVG.jsx +0 -31
- package/src/tools/shared/line/__tests__/index.test.jsx +0 -109
- package/src/tools/shared/line/__tests__/line-path.test.jsx +0 -53
- package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +0 -73
- package/src/tools/shared/line/index.jsx +0 -487
- package/src/tools/shared/line/line-path.jsx +0 -80
- package/src/tools/shared/line/with-root-edge.jsx +0 -97
- package/src/tools/shared/point/__tests__/arrow-point.test.jsx +0 -91
- package/src/tools/shared/point/__tests__/base-point.test.jsx +0 -87
- package/src/tools/shared/point/arrow-point.jsx +0 -46
- package/src/tools/shared/point/arrow.jsx +0 -37
- package/src/tools/shared/point/base-point.jsx +0 -121
- package/src/tools/shared/point/index.jsx +0 -54
- package/src/tools/shared/styles.js +0 -27
- package/src/tools/shared/types.js +0 -10
- package/src/tools/sine/__tests__/component.test.jsx +0 -51
- package/src/tools/sine/component.jsx +0 -32
- package/src/tools/sine/index.js +0 -33
- package/src/tools/vector/__tests__/component.test.jsx +0 -25
- package/src/tools/vector/component.jsx +0 -56
- package/src/tools/vector/index.js +0 -4
- package/src/undo-redo.jsx +0 -45
- package/src/use-debounce.js +0 -13
- package/src/utils.js +0 -224
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { types } from '@pie-lib/plot';
|
|
4
|
-
import { color } from '@pie-lib/render-ui';
|
|
5
|
-
import { styled } from '@mui/material/styles';
|
|
6
|
-
import InputBase from '@mui/material/InputBase';
|
|
7
|
-
import { roundNumber } from './utils';
|
|
8
|
-
|
|
9
|
-
const StyledInputBase = styled(InputBase)(({ theme }) => ({
|
|
10
|
-
fontFamily: theme.typography.fontFamily,
|
|
11
|
-
fontSize: theme.typography.fontSize,
|
|
12
|
-
borderRadius: '8px',
|
|
13
|
-
background: theme.palette.common.white,
|
|
14
|
-
color: color.defaults.PRIMARY_DARK,
|
|
15
|
-
'& .MuiInputBase-input': {
|
|
16
|
-
padding: 0,
|
|
17
|
-
},
|
|
18
|
-
}));
|
|
19
|
-
|
|
20
|
-
// eslint-disable-next-line react/prop-types
|
|
21
|
-
export const getLabelPosition = (graphProps, x, y, labelLength) => {
|
|
22
|
-
const { scale, domain, range } = graphProps;
|
|
23
|
-
// treat corner cases for maximum and minimum
|
|
24
|
-
const topShift = y === range.min ? 16 : y === range.max ? 0 : 8;
|
|
25
|
-
const leftShift = 10;
|
|
26
|
-
const rightEdge = scale.x(x) + labelLength + leftShift;
|
|
27
|
-
|
|
28
|
-
if (rightEdge >= scale.x(domain.max)) {
|
|
29
|
-
return {
|
|
30
|
-
left: scale.x(x) - leftShift - labelLength,
|
|
31
|
-
top: scale.y(y) - topShift,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
left: scale.x(x) + leftShift,
|
|
37
|
-
top: scale.y(y) - topShift,
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const CoordinatesLabel = ({ x, y, graphProps }) => {
|
|
42
|
-
const label = `(${roundNumber(x)}, ${roundNumber(y)})`;
|
|
43
|
-
const labelLength = (label.length || 0) * 6;
|
|
44
|
-
const labelPosition = getLabelPosition(graphProps, x, y, labelLength);
|
|
45
|
-
|
|
46
|
-
const style = {
|
|
47
|
-
position: 'absolute',
|
|
48
|
-
pointerEvents: 'auto',
|
|
49
|
-
width: labelLength,
|
|
50
|
-
padding: 0,
|
|
51
|
-
...labelPosition,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
return <StyledInputBase style={style} value={label} inputProps={{ ariaLabel: 'naked' }} />;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
CoordinatesLabel.propTypes = {
|
|
58
|
-
graphProps: types.GraphPropsType,
|
|
59
|
-
x: PropTypes.number,
|
|
60
|
-
y: PropTypes.number,
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export default CoordinatesLabel;
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { styled } from '@mui/material/styles';
|
|
4
|
-
import { isString, uniq } from 'lodash-es';
|
|
5
|
-
import { color } from '@pie-lib/render-ui';
|
|
6
|
-
|
|
7
|
-
import ToolMenu from './tool-menu';
|
|
8
|
-
import Graph, { graphPropTypes } from './graph';
|
|
9
|
-
import UndoRedo from './undo-redo';
|
|
10
|
-
import { allTools, toolsArr } from './tools';
|
|
11
|
-
import { Accordion, AccordionDetails, AccordionSummary, Typography } from '@mui/material';
|
|
12
|
-
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
13
|
-
|
|
14
|
-
const StyledGraphContainer = styled('div')({
|
|
15
|
-
display: 'flex',
|
|
16
|
-
flexDirection: 'column',
|
|
17
|
-
width: 'min-content',
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
const StyledControls = styled('div')(({ theme }) => ({
|
|
21
|
-
display: 'flex',
|
|
22
|
-
justifyContent: 'space-between',
|
|
23
|
-
padding: theme.spacing(1),
|
|
24
|
-
color: color.text(),
|
|
25
|
-
backgroundColor: color.primaryLight(),
|
|
26
|
-
'& button': {
|
|
27
|
-
fontSize: theme.typography.fontSize,
|
|
28
|
-
},
|
|
29
|
-
}));
|
|
30
|
-
|
|
31
|
-
const StyledAccordion = styled(Accordion)({
|
|
32
|
-
backgroundColor: color.primaryLight(),
|
|
33
|
-
width: '100%',
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const StyledAccordionSummary = styled(AccordionSummary)(({ theme }) => ({
|
|
37
|
-
padding: `0 ${theme.spacing(1)}`,
|
|
38
|
-
minHeight: '32px !important',
|
|
39
|
-
'& .MuiAccordionSummary-content': {
|
|
40
|
-
margin: '4px 0 !important',
|
|
41
|
-
},
|
|
42
|
-
}));
|
|
43
|
-
|
|
44
|
-
const StyledAccordionDetails = styled(AccordionDetails)(({ theme }) => ({
|
|
45
|
-
padding: 0,
|
|
46
|
-
marginTop: theme.spacing(1),
|
|
47
|
-
display: 'flex',
|
|
48
|
-
justifyContent: 'space-between',
|
|
49
|
-
}));
|
|
50
|
-
|
|
51
|
-
export const setToolbarAvailability = (toolbarTools) =>
|
|
52
|
-
toolsArr.map((tA) => ({ ...tA, toolbar: !!toolbarTools.find((t) => t === tA.type) })) || [];
|
|
53
|
-
|
|
54
|
-
export const toolIsAvailable = (tools, currentTool) =>
|
|
55
|
-
currentTool && tools && (tools.find((tool) => tool.type === currentTool.type) || {}).toolbar;
|
|
56
|
-
|
|
57
|
-
export const getAvailableTool = (tools) => tools.find((tool) => tool.toolbar);
|
|
58
|
-
|
|
59
|
-
export const filterByValidToolTypes = (backgroundMarks) =>
|
|
60
|
-
backgroundMarks.filter((bM) => !!allTools.find((tool) => tool === bM.type));
|
|
61
|
-
|
|
62
|
-
export const filterByVisibleToolTypes = (toolbarTools, marks) =>
|
|
63
|
-
marks.filter((bM) => !!toolbarTools.find((tool) => tool === bM.type));
|
|
64
|
-
|
|
65
|
-
const getDefaultCurrentTool = (toolType) => toolsArr.find((tool) => tool.type === toolType) || null;
|
|
66
|
-
|
|
67
|
-
const Collapsible = ({ children, title }) => (
|
|
68
|
-
<StyledAccordion
|
|
69
|
-
elevation={0}
|
|
70
|
-
disableGutters={true}
|
|
71
|
-
square={true}
|
|
72
|
-
TransitionProps={{ timeout: { enter: 225, exit: 195 } }}
|
|
73
|
-
>
|
|
74
|
-
<StyledAccordionSummary expandIcon={<ExpandMoreIcon />}>
|
|
75
|
-
<Typography variant="subheading">{title}</Typography>
|
|
76
|
-
</StyledAccordionSummary>
|
|
77
|
-
<StyledAccordionDetails>{children}</StyledAccordionDetails>
|
|
78
|
-
</StyledAccordion>
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
Collapsible.propTypes = {
|
|
82
|
-
children: PropTypes.array,
|
|
83
|
-
title: PropTypes.string,
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export class GraphWithControls extends React.Component {
|
|
87
|
-
static propTypes = {
|
|
88
|
-
...graphPropTypes,
|
|
89
|
-
onUndo: PropTypes.func,
|
|
90
|
-
onRedo: PropTypes.func,
|
|
91
|
-
onReset: PropTypes.func,
|
|
92
|
-
toolbarTools: PropTypes.arrayOf(PropTypes.string), // array of tool types that have to be displayed in the toolbar, same shape as 'allTools'
|
|
93
|
-
language: PropTypes.string,
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
static defaultProps = {
|
|
97
|
-
collapsibleToolbar: false,
|
|
98
|
-
collapsibleToolbarTitle: '',
|
|
99
|
-
disabledLabels: false,
|
|
100
|
-
disabledTitle: false,
|
|
101
|
-
showLabels: true,
|
|
102
|
-
showTitle: true,
|
|
103
|
-
toolbarTools: [],
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
constructor(props) {
|
|
107
|
-
super(props);
|
|
108
|
-
|
|
109
|
-
this.state = {
|
|
110
|
-
currentTool: getDefaultCurrentTool(props.defaultTool),
|
|
111
|
-
labelModeEnabled: false,
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
componentDidUpdate(prevProps) {
|
|
116
|
-
const { defaultTool } = this.props;
|
|
117
|
-
|
|
118
|
-
if (prevProps.defaultTool !== defaultTool) {
|
|
119
|
-
const currentTool = getDefaultCurrentTool(defaultTool);
|
|
120
|
-
|
|
121
|
-
this.setState({ currentTool });
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
changeCurrentTool = (tool, tools) =>
|
|
126
|
-
this.setState({ currentTool: tools.find((t) => t.type === tool), labelModeEnabled: tool === 'label' });
|
|
127
|
-
|
|
128
|
-
render() {
|
|
129
|
-
let { currentTool, labelModeEnabled } = this.state;
|
|
130
|
-
const {
|
|
131
|
-
axesSettings,
|
|
132
|
-
className,
|
|
133
|
-
coordinatesOnHover,
|
|
134
|
-
collapsibleToolbar,
|
|
135
|
-
collapsibleToolbarTitle,
|
|
136
|
-
disabled,
|
|
137
|
-
disabledLabels,
|
|
138
|
-
disabledTitle,
|
|
139
|
-
domain,
|
|
140
|
-
draggableTools,
|
|
141
|
-
labels,
|
|
142
|
-
labelsPlaceholders,
|
|
143
|
-
onChangeLabels,
|
|
144
|
-
onChangeMarks,
|
|
145
|
-
onChangeTitle,
|
|
146
|
-
onChangeTools,
|
|
147
|
-
onUndo,
|
|
148
|
-
onRedo,
|
|
149
|
-
onReset,
|
|
150
|
-
range,
|
|
151
|
-
size,
|
|
152
|
-
showLabels,
|
|
153
|
-
showPixelGuides,
|
|
154
|
-
showTitle,
|
|
155
|
-
title,
|
|
156
|
-
titlePlaceholder,
|
|
157
|
-
language,
|
|
158
|
-
removeIncompleteTool,
|
|
159
|
-
limitLabeling,
|
|
160
|
-
} = this.props;
|
|
161
|
-
let { backgroundMarks, marks, toolbarTools } = this.props;
|
|
162
|
-
|
|
163
|
-
// make sure only valid tool types are kept (string) and without duplicates
|
|
164
|
-
toolbarTools = uniq(toolbarTools || []).filter((tT) => !!isString(tT)) || [];
|
|
165
|
-
|
|
166
|
-
// keep only the backgroundMarks that have valid types
|
|
167
|
-
backgroundMarks = filterByValidToolTypes(backgroundMarks || []);
|
|
168
|
-
|
|
169
|
-
// keep only the marks that have types which appear in toolbar
|
|
170
|
-
marks = filterByVisibleToolTypes(toolbarTools, marks || []);
|
|
171
|
-
|
|
172
|
-
const tools = setToolbarAvailability(toolbarTools);
|
|
173
|
-
|
|
174
|
-
// set current tool if there's no current tool or if the existing one is no longer available
|
|
175
|
-
if (!currentTool || !toolIsAvailable(tools, currentTool)) {
|
|
176
|
-
currentTool = getAvailableTool(tools);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const graphActions = (
|
|
180
|
-
<React.Fragment>
|
|
181
|
-
<ToolMenu
|
|
182
|
-
currentToolType={currentTool && currentTool.type}
|
|
183
|
-
disabled={!!disabled}
|
|
184
|
-
draggableTools={draggableTools}
|
|
185
|
-
labelModeEnabled={labelModeEnabled}
|
|
186
|
-
onChange={(tool) => this.changeCurrentTool(tool, tools)}
|
|
187
|
-
toolbarTools={toolbarTools}
|
|
188
|
-
onChangeTools={onChangeTools}
|
|
189
|
-
language={language}
|
|
190
|
-
/>
|
|
191
|
-
|
|
192
|
-
{!disabled && <UndoRedo onUndo={onUndo} onRedo={onRedo} onReset={onReset} language={language} />}
|
|
193
|
-
</React.Fragment>
|
|
194
|
-
);
|
|
195
|
-
|
|
196
|
-
return (
|
|
197
|
-
<StyledGraphContainer className={className}>
|
|
198
|
-
<StyledControls>
|
|
199
|
-
{collapsibleToolbar ? (
|
|
200
|
-
<Collapsible title={collapsibleToolbarTitle}>{graphActions}</Collapsible>
|
|
201
|
-
) : (
|
|
202
|
-
graphActions
|
|
203
|
-
)}
|
|
204
|
-
</StyledControls>
|
|
205
|
-
|
|
206
|
-
<div ref={(r) => (this.labelNode = r)} />
|
|
207
|
-
|
|
208
|
-
<Graph
|
|
209
|
-
axesSettings={axesSettings}
|
|
210
|
-
backgroundMarks={backgroundMarks}
|
|
211
|
-
coordinatesOnHover={coordinatesOnHover}
|
|
212
|
-
currentTool={currentTool}
|
|
213
|
-
disabledLabels={disabledLabels}
|
|
214
|
-
disabledTitle={disabledTitle}
|
|
215
|
-
domain={domain}
|
|
216
|
-
labels={labels}
|
|
217
|
-
labelModeEnabled={labelModeEnabled}
|
|
218
|
-
labelsPlaceholders={labelsPlaceholders}
|
|
219
|
-
marks={marks}
|
|
220
|
-
onChangeMarks={!disabled ? onChangeMarks : undefined}
|
|
221
|
-
onChangeLabels={onChangeLabels}
|
|
222
|
-
onChangeTitle={onChangeTitle}
|
|
223
|
-
range={range}
|
|
224
|
-
size={size}
|
|
225
|
-
showLabels={showLabels}
|
|
226
|
-
showPixelGuides={showPixelGuides}
|
|
227
|
-
showTitle={showTitle}
|
|
228
|
-
title={title}
|
|
229
|
-
titlePlaceholder={titlePlaceholder}
|
|
230
|
-
tools={tools}
|
|
231
|
-
removeIncompleteTool={removeIncompleteTool}
|
|
232
|
-
limitLabeling={limitLabeling}
|
|
233
|
-
/>
|
|
234
|
-
</StyledGraphContainer>
|
|
235
|
-
);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
export default GraphWithControls;
|
package/src/graph.jsx
DELETED
|
@@ -1,303 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { cloneDeep, isEqual } from 'lodash-es';
|
|
4
|
-
import { createGraphProps, Root, types } from '@pie-lib/plot';
|
|
5
|
-
import debug from 'debug';
|
|
6
|
-
|
|
7
|
-
import { Axes, AxisPropTypes } from './axis';
|
|
8
|
-
import Grid from './grid';
|
|
9
|
-
import { LabelType } from './labels';
|
|
10
|
-
import Bg from './bg';
|
|
11
|
-
import { isDuplicatedMark } from './utils';
|
|
12
|
-
|
|
13
|
-
const log = debug('pie-lib:graphing:graph');
|
|
14
|
-
|
|
15
|
-
export const graphPropTypes = {
|
|
16
|
-
axesSettings: PropTypes.shape(AxisPropTypes),
|
|
17
|
-
backgroundMarks: PropTypes.array,
|
|
18
|
-
className: PropTypes.string,
|
|
19
|
-
collapsibleToolbar: PropTypes.bool,
|
|
20
|
-
collapsibleToolbarTitle: PropTypes.string,
|
|
21
|
-
disabledLabels: PropTypes.bool,
|
|
22
|
-
disabledTitle: PropTypes.bool,
|
|
23
|
-
domain: types.DomainType,
|
|
24
|
-
labels: PropTypes.shape(LabelType),
|
|
25
|
-
labelModeEnabled: PropTypes.bool,
|
|
26
|
-
coordinatesOnHover: PropTypes.bool,
|
|
27
|
-
marks: PropTypes.array,
|
|
28
|
-
onChangeLabels: PropTypes.func,
|
|
29
|
-
onChangeMarks: PropTypes.func,
|
|
30
|
-
onChangeTitle: PropTypes.func,
|
|
31
|
-
range: types.DomainType,
|
|
32
|
-
size: PropTypes.shape({
|
|
33
|
-
width: PropTypes.number.isRequired,
|
|
34
|
-
height: PropTypes.number.isRequired,
|
|
35
|
-
}),
|
|
36
|
-
showLabels: PropTypes.bool,
|
|
37
|
-
showPixelGuides: PropTypes.bool,
|
|
38
|
-
showTitle: PropTypes.bool,
|
|
39
|
-
title: PropTypes.string,
|
|
40
|
-
tools: PropTypes.array,
|
|
41
|
-
limitLabeling: PropTypes.bool,
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const getMaskSize = (size) => ({
|
|
45
|
-
x: -23,
|
|
46
|
-
y: -23,
|
|
47
|
-
width: size.width + 46,
|
|
48
|
-
height: size.height + 46,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
export const removeBuildingToolIfCurrentToolDiffers = ({ marks, currentTool, onChangeMarks, removeIncompleteTool }) => {
|
|
52
|
-
const buildingMark = marks.filter((m) => m.building)[0];
|
|
53
|
-
let newMarks = cloneDeep(marks);
|
|
54
|
-
|
|
55
|
-
if (buildingMark && currentTool && buildingMark.type !== currentTool.type) {
|
|
56
|
-
const index = newMarks.findIndex((m) => isEqual(m, buildingMark));
|
|
57
|
-
|
|
58
|
-
if (index >= 0) {
|
|
59
|
-
newMarks.splice(index, 1);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (removeIncompleteTool && !isEqual(newMarks, marks)) {
|
|
63
|
-
onChangeMarks(newMarks);
|
|
64
|
-
}
|
|
65
|
-
return newMarks;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export class Graph extends React.Component {
|
|
69
|
-
constructor(props) {
|
|
70
|
-
super(props);
|
|
71
|
-
this.maskUid = this.generateMaskId();
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
static propTypes = {
|
|
75
|
-
...graphPropTypes,
|
|
76
|
-
currentTool: PropTypes.object,
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
static defaultProps = {
|
|
80
|
-
onChangeMarks: () => {},
|
|
81
|
-
disabledLabels: false,
|
|
82
|
-
disabledTitle: false,
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
state = {};
|
|
86
|
-
_justDragged = false;
|
|
87
|
-
|
|
88
|
-
startDrag = () => {
|
|
89
|
-
this._justDragged = false;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
stopDrag = () => {
|
|
93
|
-
this._justDragged = true;
|
|
94
|
-
// Reset after a short delay — long enough for any trailing click/bg-click to fire first.
|
|
95
|
-
setTimeout(() => {
|
|
96
|
-
this._justDragged = false;
|
|
97
|
-
}, 300);
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
generateMaskId() {
|
|
101
|
-
return 'graph-' + (Math.random() * 10000).toFixed();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
componentDidMount = () => this.setState({ labelNode: this.labelNode });
|
|
105
|
-
|
|
106
|
-
changeMark = (oldMark, newMark) => {
|
|
107
|
-
const { onChangeMarks, marks } = this.props;
|
|
108
|
-
let newMarks = cloneDeep(marks);
|
|
109
|
-
|
|
110
|
-
const index = newMarks.findIndex((m) => isEqual(m, oldMark));
|
|
111
|
-
|
|
112
|
-
if (index >= 0 && !isDuplicatedMark(newMark, marks, oldMark)) {
|
|
113
|
-
newMarks.splice(index, 1, newMark);
|
|
114
|
-
|
|
115
|
-
onChangeMarks(newMarks);
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
completeMark = (markData) => {
|
|
120
|
-
const { currentTool, marks } = this.props;
|
|
121
|
-
const buildingMark = marks.filter((m) => m.building)[0];
|
|
122
|
-
|
|
123
|
-
if (!buildingMark || !currentTool) return;
|
|
124
|
-
|
|
125
|
-
const updatedMark = currentTool.complete(buildingMark, markData);
|
|
126
|
-
|
|
127
|
-
this.updateMarks(buildingMark, updatedMark);
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
updateMarks = (existing, update, addIfMissing = false) => {
|
|
131
|
-
const { onChangeMarks, marks } = this.props;
|
|
132
|
-
let newMarks = cloneDeep(marks);
|
|
133
|
-
|
|
134
|
-
if (!update || (!update.building && isDuplicatedMark(update, marks))) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const index = newMarks.findIndex((m) => isEqual(m, existing));
|
|
139
|
-
|
|
140
|
-
if (index >= 0) {
|
|
141
|
-
newMarks.splice(index, 1, update);
|
|
142
|
-
|
|
143
|
-
onChangeMarks(newMarks);
|
|
144
|
-
} else if (addIfMissing) {
|
|
145
|
-
onChangeMarks([...newMarks, update]);
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
getComponent = (mark) => {
|
|
150
|
-
if (!mark) return null;
|
|
151
|
-
|
|
152
|
-
const tool = (this.props.tools || []).find((t) => t.type === mark.type);
|
|
153
|
-
|
|
154
|
-
return (tool && tool.Component) || null;
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
onBgClick = (point) => {
|
|
158
|
-
const { x, y } = point || {};
|
|
159
|
-
const { labelModeEnabled, currentTool, marks } = this.props;
|
|
160
|
-
|
|
161
|
-
if (this._justDragged) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (labelModeEnabled || !currentTool || [null, undefined].includes(x) || [null, undefined].includes(y)) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
log('[onBgClick] x,y: ', x, y);
|
|
170
|
-
|
|
171
|
-
const buildingMark = marks.filter((m) => m.building)[0];
|
|
172
|
-
let updatedMark;
|
|
173
|
-
|
|
174
|
-
// if the building mark has a different type, we just replace it
|
|
175
|
-
if (buildingMark && currentTool && buildingMark.type === currentTool.type) {
|
|
176
|
-
updatedMark = currentTool.addPoint({ x, y }, { ...buildingMark });
|
|
177
|
-
} else {
|
|
178
|
-
updatedMark = currentTool.addPoint({ x, y }, undefined);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
this.updateMarks(buildingMark, updatedMark, true);
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
render() {
|
|
185
|
-
const {
|
|
186
|
-
axesSettings,
|
|
187
|
-
currentTool,
|
|
188
|
-
coordinatesOnHover,
|
|
189
|
-
size,
|
|
190
|
-
disabledLabels,
|
|
191
|
-
disabledTitle,
|
|
192
|
-
domain,
|
|
193
|
-
backgroundMarks,
|
|
194
|
-
range,
|
|
195
|
-
title,
|
|
196
|
-
labels,
|
|
197
|
-
labelModeEnabled,
|
|
198
|
-
labelsPlaceholders,
|
|
199
|
-
limitLabeling,
|
|
200
|
-
showLabels,
|
|
201
|
-
showPixelGuides,
|
|
202
|
-
showTitle,
|
|
203
|
-
titlePlaceholder,
|
|
204
|
-
onChangeLabels,
|
|
205
|
-
onChangeTitle,
|
|
206
|
-
mathMlOptions = {},
|
|
207
|
-
onChangeMarks,
|
|
208
|
-
removeIncompleteTool,
|
|
209
|
-
} = this.props;
|
|
210
|
-
let { marks } = this.props;
|
|
211
|
-
|
|
212
|
-
const graphProps = createGraphProps(domain, range, size, () => this.rootNode);
|
|
213
|
-
|
|
214
|
-
const maskSize = getMaskSize(size);
|
|
215
|
-
const common = { graphProps, labelModeEnabled, limitLabeling };
|
|
216
|
-
|
|
217
|
-
marks = removeBuildingToolIfCurrentToolDiffers({
|
|
218
|
-
marks: marks || [],
|
|
219
|
-
currentTool,
|
|
220
|
-
onChangeMarks,
|
|
221
|
-
removeIncompleteTool,
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
return (
|
|
225
|
-
<Root
|
|
226
|
-
rootRef={(r) => (this.rootNode = r)}
|
|
227
|
-
disabledTitle={disabledTitle}
|
|
228
|
-
disabledLabels={disabledLabels}
|
|
229
|
-
labels={labels}
|
|
230
|
-
labelsPlaceholders={labelsPlaceholders || {}}
|
|
231
|
-
showPixelGuides={showPixelGuides}
|
|
232
|
-
showLabels={showLabels}
|
|
233
|
-
showTitle={showTitle}
|
|
234
|
-
title={title}
|
|
235
|
-
titlePlaceholder={titlePlaceholder}
|
|
236
|
-
onChangeTitle={onChangeTitle}
|
|
237
|
-
onChangeLabels={onChangeLabels}
|
|
238
|
-
mathMlOptions={mathMlOptions}
|
|
239
|
-
{...common}
|
|
240
|
-
>
|
|
241
|
-
<g
|
|
242
|
-
transform={
|
|
243
|
-
domain && domain.padding && domain.range ? `translate(${domain.padding}, ${range.padding})` : undefined
|
|
244
|
-
}
|
|
245
|
-
>
|
|
246
|
-
<Grid {...common} />
|
|
247
|
-
<Axes {...axesSettings} {...common} />
|
|
248
|
-
<Bg {...size} onClick={this.onBgClick} {...common} />
|
|
249
|
-
<mask id={`${this.maskUid}`}>
|
|
250
|
-
<rect {...maskSize} fill="white" /> {/* TODO hardcoded color */}
|
|
251
|
-
</mask>
|
|
252
|
-
|
|
253
|
-
<g id="marks" mask={`url('#${this.maskUid}')`}>
|
|
254
|
-
{(backgroundMarks || []).map((m, index) => {
|
|
255
|
-
const Component = this.getComponent(m);
|
|
256
|
-
const markType = m.type;
|
|
257
|
-
|
|
258
|
-
return (
|
|
259
|
-
<Component
|
|
260
|
-
key={`${markType}-${index}-bg`}
|
|
261
|
-
mark={{ ...m, disabled: true, isBackground: true }}
|
|
262
|
-
labelNode={this.state.labelNode}
|
|
263
|
-
onClick={this.onBgClick}
|
|
264
|
-
{...common}
|
|
265
|
-
/>
|
|
266
|
-
);
|
|
267
|
-
})}
|
|
268
|
-
|
|
269
|
-
{marks.map((m, index) => {
|
|
270
|
-
const Component = this.getComponent(m);
|
|
271
|
-
const markType = m.type;
|
|
272
|
-
|
|
273
|
-
return (
|
|
274
|
-
<Component
|
|
275
|
-
key={`${markType}-${index}`}
|
|
276
|
-
mark={m}
|
|
277
|
-
coordinatesOnHover={coordinatesOnHover}
|
|
278
|
-
onChange={this.changeMark}
|
|
279
|
-
onComplete={this.completeMark}
|
|
280
|
-
onClick={this.onBgClick}
|
|
281
|
-
onDragStart={this.startDrag}
|
|
282
|
-
onDragStop={this.stopDrag}
|
|
283
|
-
labelNode={this.state.labelNode}
|
|
284
|
-
isToolActive={currentTool && markType === currentTool.type}
|
|
285
|
-
{...common}
|
|
286
|
-
/>
|
|
287
|
-
);
|
|
288
|
-
})}
|
|
289
|
-
<foreignObject
|
|
290
|
-
ref={(labelNode) => (this.labelNode = labelNode)}
|
|
291
|
-
x="0"
|
|
292
|
-
y="0"
|
|
293
|
-
{...size}
|
|
294
|
-
style={{ pointerEvents: 'none', fontSize: '14px' }}
|
|
295
|
-
/>
|
|
296
|
-
</g>
|
|
297
|
-
</g>
|
|
298
|
-
</Root>
|
|
299
|
-
);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
export default Graph;
|