@pie-lib/graphing-solution-set 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.js +23 -0
- package/dist/axis/arrow.d.ts +14 -0
- package/dist/axis/arrow.d.ts.map +1 -0
- package/dist/axis/arrow.js +34 -0
- package/dist/axis/axes.d.ts +133 -0
- package/dist/axis/axes.d.ts.map +1 -0
- package/dist/axis/axes.js +214 -0
- package/dist/axis/index.d.ts +11 -0
- package/dist/axis/index.d.ts.map +1 -0
- package/dist/bg.d.ts +52 -0
- package/dist/bg.d.ts.map +1 -0
- package/dist/bg.js +44 -0
- package/dist/container/actions.d.ts +16 -0
- package/dist/container/actions.d.ts.map +1 -0
- package/dist/container/actions.js +7 -0
- package/dist/container/index.d.ts +27 -0
- package/dist/container/index.d.ts.map +1 -0
- package/dist/container/index.js +48 -0
- package/dist/container/marks.d.ts +11 -0
- package/dist/container/marks.d.ts.map +1 -0
- package/dist/container/marks.js +11 -0
- package/dist/container/middleware.d.ts +11 -0
- package/dist/container/middleware.d.ts.map +1 -0
- package/dist/container/middleware.js +4 -0
- package/dist/container/reducer.d.ts +13 -0
- package/dist/container/reducer.d.ts.map +1 -0
- package/dist/container/reducer.js +7 -0
- package/dist/coordinates-label.d.ts +50 -0
- package/dist/coordinates-label.d.ts.map +1 -0
- package/dist/coordinates-label.js +46 -0
- package/dist/graph-with-controls.d.ts +86 -0
- package/dist/graph-with-controls.d.ts.map +1 -0
- package/dist/graph-with-controls.js +155 -0
- package/dist/graph.d.ts +120 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +221 -0
- package/dist/grid-setup.d.ts +27 -0
- package/dist/grid-setup.d.ts.map +1 -0
- package/dist/grid-setup.js +307 -0
- package/dist/grid.d.ts +44 -0
- package/dist/grid.d.ts.map +1 -0
- package/dist/grid.js +59 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/labels.d.ts +74 -0
- package/dist/labels.d.ts.map +1 -0
- package/dist/labels.js +134 -0
- package/dist/mark-label.d.ts +50 -0
- package/dist/mark-label.d.ts.map +1 -0
- package/dist/mark-label.js +84 -0
- package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js +7 -0
- package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/defineProperty.js +12 -0
- package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/extends.js +12 -0
- package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js +7 -0
- package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/objectSpread2.js +25 -0
- package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js +12 -0
- package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js +8 -0
- package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/toPrimitive.js +14 -0
- package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js +9 -0
- package/dist/node_modules/.bun/@babel_runtime@7.28.6/node_modules/@babel/runtime/helpers/esm/typeof.js +11 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Axis.js +100 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisRenderer.js +61 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Ticks.js +42 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/constants/orientation.js +9 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/createPoint.js +14 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getAxisRangePaddingConfig.js +21 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getLabelTransform.js +16 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getTickFormatter.js +8 -0
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getTickPosition.js +15 -0
- package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/Grid.js +78 -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 +49 -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 +46 -0
- package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/lib/shapes/Line.js +52 -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/hoist-non-react-statics@3.3.2/node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js +68 -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-input-autosize@2.2.2_f4eacebf2041cd4f/node_modules/react-input-autosize/lib/AutosizeInput.js +216 -0
- package/dist/node_modules/.bun/react-is@16.13.1/node_modules/react-is/cjs/react-is.development.js +82 -0
- package/dist/node_modules/.bun/react-is@16.13.1/node_modules/react-is/cjs/react-is.production.min.js +62 -0
- package/dist/node_modules/.bun/react-is@16.13.1/node_modules/react-is/index.js +10 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/components/Context.js +5 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/components/Provider.js +47 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/components/connectAdvanced.js +95 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/connect/connect.js +52 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/connect/mapDispatchToProps.js +23 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/connect/mapStateToProps.js +13 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/connect/mergeProps.js +26 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/connect/selectorFactory.js +41 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/connect/verifySubselectors.js +11 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/connect/wrapMapToProps.js +28 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/index.js +4 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/utils/isPlainObject.js +10 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/utils/shallowEqual.js +15 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/utils/verifyPlainObject.js +8 -0
- package/dist/node_modules/.bun/react-redux@6.0.1_926323a638b43722/node_modules/react-redux/es/utils/warning.js +9 -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@4.2.1/node_modules/redux/es/redux.js +225 -0
- package/dist/toggle-bar.d.ts +41 -0
- package/dist/toggle-bar.d.ts.map +1 -0
- package/dist/tool-menu.d.ts +22 -0
- package/dist/tool-menu.d.ts.map +1 -0
- package/dist/tool-menu.js +188 -0
- package/dist/tools/index.d.ts +18 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +12 -0
- package/dist/tools/line/component.d.ts +92 -0
- package/dist/tools/line/component.d.ts.map +1 -0
- package/dist/tools/line/component.js +58 -0
- package/dist/tools/line/index.d.ts +14 -0
- package/dist/tools/line/index.d.ts.map +1 -0
- package/dist/tools/line/index.js +6 -0
- package/dist/tools/polygon/component.d.ts +115 -0
- package/dist/tools/polygon/component.d.ts.map +1 -0
- package/dist/tools/polygon/component.js +194 -0
- package/dist/tools/polygon/index.d.ts +20 -0
- package/dist/tools/polygon/index.d.ts.map +1 -0
- package/dist/tools/polygon/index.js +55 -0
- package/dist/tools/polygon/line.d.ts +105 -0
- package/dist/tools/polygon/line.d.ts.map +1 -0
- package/dist/tools/polygon/polygon.d.ts +102 -0
- package/dist/tools/polygon/polygon.d.ts.map +1 -0
- package/dist/tools/polygon/polygon.js +62 -0
- package/dist/tools/shared/arrow-head.d.ts +43 -0
- package/dist/tools/shared/arrow-head.d.ts.map +1 -0
- package/dist/tools/shared/arrow-head.js +37 -0
- package/dist/tools/shared/line/index.d.ts +165 -0
- package/dist/tools/shared/line/index.d.ts.map +1 -0
- package/dist/tools/shared/line/index.js +320 -0
- package/dist/tools/shared/line/line-path.d.ts +58 -0
- package/dist/tools/shared/line/line-path.d.ts.map +1 -0
- package/dist/tools/shared/line/with-root-edge.d.ts +89 -0
- package/dist/tools/shared/line/with-root-edge.d.ts.map +1 -0
- package/dist/tools/shared/point/arrow-point.d.ts +58 -0
- package/dist/tools/shared/point/arrow-point.d.ts.map +1 -0
- package/dist/tools/shared/point/arrow-point.js +47 -0
- package/dist/tools/shared/point/arrow.d.ts +47 -0
- package/dist/tools/shared/point/arrow.d.ts.map +1 -0
- package/dist/tools/shared/point/arrow.js +36 -0
- package/dist/tools/shared/point/base-point.d.ts +51 -0
- package/dist/tools/shared/point/base-point.d.ts.map +1 -0
- package/dist/tools/shared/point/base-point.js +88 -0
- package/dist/tools/shared/point/index.d.ts +154 -0
- package/dist/tools/shared/point/index.d.ts.map +1 -0
- package/dist/tools/shared/point/index.js +51 -0
- package/dist/tools/shared/styles.d.ts +25 -0
- package/dist/tools/shared/styles.d.ts.map +1 -0
- package/dist/tools/shared/styles.js +17 -0
- package/dist/tools/shared/types.d.ts +16 -0
- package/dist/tools/shared/types.d.ts.map +1 -0
- package/dist/tools/shared/types.js +10 -0
- package/dist/undo-redo.d.ts +21 -0
- package/dist/undo-redo.d.ts.map +1 -0
- package/dist/undo-redo.js +33 -0
- package/dist/use-debounce.d.ts +10 -0
- package/dist/use-debounce.d.ts.map +1 -0
- package/dist/use-debounce.js +13 -0
- package/dist/utils.d.ts +59 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +72 -0
- package/package.json +64 -0
- package/src/axis/arrow.tsx +67 -0
- package/src/axis/axes.tsx +321 -0
- package/src/axis/index.ts +13 -0
- package/src/bg.tsx +106 -0
- package/src/container/actions.ts +18 -0
- package/src/container/index.tsx +95 -0
- package/src/container/marks.ts +24 -0
- package/src/container/middleware.ts +17 -0
- package/src/container/reducer.ts +15 -0
- package/src/coordinates-label.tsx +72 -0
- package/src/graph-with-controls.tsx +252 -0
- package/src/graph.tsx +343 -0
- package/src/grid-setup.tsx +470 -0
- package/src/grid.tsx +143 -0
- package/src/index.ts +17 -0
- package/src/labels.tsx +211 -0
- package/src/mark-label.tsx +135 -0
- package/src/toggle-bar.tsx +231 -0
- package/src/tool-menu.tsx +245 -0
- package/src/tools/index.ts +18 -0
- package/src/tools/line/component.tsx +87 -0
- package/src/tools/line/index.ts +14 -0
- package/src/tools/polygon/component.tsx +334 -0
- package/src/tools/polygon/index.ts +62 -0
- package/src/tools/polygon/line.tsx +90 -0
- package/src/tools/polygon/polygon.tsx +103 -0
- package/src/tools/shared/arrow-head.tsx +56 -0
- package/src/tools/shared/line/index.tsx +481 -0
- package/src/tools/shared/line/line-path.tsx +95 -0
- package/src/tools/shared/line/with-root-edge.tsx +107 -0
- package/src/tools/shared/point/arrow-point.tsx +70 -0
- package/src/tools/shared/point/arrow.tsx +50 -0
- package/src/tools/shared/point/base-point.tsx +123 -0
- package/src/tools/shared/point/index.tsx +68 -0
- package/src/tools/shared/styles.ts +30 -0
- package/src/tools/shared/types.ts +18 -0
- package/src/undo-redo.tsx +47 -0
- package/src/use-debounce.ts +23 -0
- package/src/utils.ts +240 -0
package/src/graph.tsx
ADDED
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-lib/packages/graphing-solution-set/src/graph.jsx
|
|
4
|
+
* @auto-generated
|
|
5
|
+
*
|
|
6
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
7
|
+
* Manual edits will be overwritten on next sync.
|
|
8
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import PropTypes from 'prop-types';
|
|
13
|
+
import { cloneDeep, isEqual } from 'lodash-es';
|
|
14
|
+
import { createGraphProps, Root, types } from '@pie-lib/plot';
|
|
15
|
+
import debug from 'debug';
|
|
16
|
+
|
|
17
|
+
import { Axes, AxisPropTypes } from './axis/index.js';
|
|
18
|
+
import Grid from './grid.js';
|
|
19
|
+
import { LabelType } from './labels.js';
|
|
20
|
+
import Bg from './bg.js';
|
|
21
|
+
import { areArraysOfObjectsEqual, isDuplicatedMark } from './utils.js';
|
|
22
|
+
|
|
23
|
+
const log = debug('pie-lib:graphing-solution-set:graph');
|
|
24
|
+
|
|
25
|
+
export const graphPropTypes = {
|
|
26
|
+
axesSettings: PropTypes.shape(AxisPropTypes),
|
|
27
|
+
backgroundMarks: PropTypes.array,
|
|
28
|
+
className: PropTypes.string,
|
|
29
|
+
collapsibleToolbar: PropTypes.bool,
|
|
30
|
+
collapsibleToolbarTitle: PropTypes.string,
|
|
31
|
+
disabledLabels: PropTypes.bool,
|
|
32
|
+
disabledTitle: PropTypes.bool,
|
|
33
|
+
domain: types.DomainType,
|
|
34
|
+
labels: PropTypes.shape(LabelType),
|
|
35
|
+
labelModeEnabled: PropTypes.bool,
|
|
36
|
+
coordinatesOnHover: PropTypes.bool,
|
|
37
|
+
marks: PropTypes.array,
|
|
38
|
+
onChangeLabels: PropTypes.func,
|
|
39
|
+
onChangeMarks: PropTypes.func,
|
|
40
|
+
onChangeTitle: PropTypes.func,
|
|
41
|
+
range: types.DomainType,
|
|
42
|
+
size: PropTypes.shape({
|
|
43
|
+
width: PropTypes.number.isRequired,
|
|
44
|
+
height: PropTypes.number.isRequired,
|
|
45
|
+
}),
|
|
46
|
+
showLabels: PropTypes.bool,
|
|
47
|
+
showPixelGuides: PropTypes.bool,
|
|
48
|
+
showTitle: PropTypes.bool,
|
|
49
|
+
title: PropTypes.string,
|
|
50
|
+
tools: PropTypes.array,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const getMaskSize = (size) => ({
|
|
54
|
+
x: -23,
|
|
55
|
+
y: -23,
|
|
56
|
+
width: size.width + 46,
|
|
57
|
+
height: size.height + 46,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export const removeBuildingToolIfCurrentToolDiffers = ({ marks, currentTool }) => {
|
|
61
|
+
const buildingMark = marks.filter((m) => m.building)[0];
|
|
62
|
+
let newMarks = cloneDeep(marks);
|
|
63
|
+
|
|
64
|
+
if (buildingMark && currentTool && buildingMark.type !== currentTool.type) {
|
|
65
|
+
const index = newMarks.findIndex((m) => isEqual(m, buildingMark));
|
|
66
|
+
|
|
67
|
+
if (index >= 0) {
|
|
68
|
+
newMarks.splice(index, 1);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return newMarks;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export class Graph extends React.Component {
|
|
76
|
+
constructor(props) {
|
|
77
|
+
super(props);
|
|
78
|
+
this.maskUid = this.generateMaskId();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static propTypes = {
|
|
82
|
+
...graphPropTypes,
|
|
83
|
+
currentTool: PropTypes.object,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
static defaultProps = {
|
|
87
|
+
onChangeMarks: () => {},
|
|
88
|
+
disabledLabels: false,
|
|
89
|
+
disabledTitle: false,
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
state = {};
|
|
93
|
+
|
|
94
|
+
generateMaskId() {
|
|
95
|
+
return 'graph-' + (Math.random() * 10000).toFixed();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
componentDidMount = () => this.setState({ labelNode: this.labelNode });
|
|
99
|
+
|
|
100
|
+
changeMark: any = (oldMark, newMark) => {
|
|
101
|
+
const { onChangeMarks, marks, gssLineData } = this.props;
|
|
102
|
+
|
|
103
|
+
if (gssLineData?.selectedTool === 'solutionSet') {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
let newMarks = cloneDeep(marks);
|
|
108
|
+
|
|
109
|
+
const index = newMarks.findIndex((m) => isEqual(m, oldMark));
|
|
110
|
+
|
|
111
|
+
if (index >= 0 && !isDuplicatedMark(newMark, marks, oldMark)) {
|
|
112
|
+
newMarks.splice(index, 1, newMark);
|
|
113
|
+
|
|
114
|
+
onChangeMarks(newMarks);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
completeMark: any = (markData) => {
|
|
119
|
+
const { currentTool, marks } = this.props;
|
|
120
|
+
const buildingMark = marks.filter((m) => m.building)[0];
|
|
121
|
+
|
|
122
|
+
if (!buildingMark || !currentTool) return;
|
|
123
|
+
|
|
124
|
+
const updatedMark = currentTool.complete(buildingMark, markData);
|
|
125
|
+
|
|
126
|
+
this.updateMarks(buildingMark, updatedMark);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
updateMarks: any = (existing, update, addIfMissing = false) => {
|
|
130
|
+
const { onChangeMarks, marks } = this.props;
|
|
131
|
+
let newMarks = cloneDeep(marks);
|
|
132
|
+
|
|
133
|
+
if (!update || (!update.building && isDuplicatedMark(update, marks))) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const index = newMarks.findIndex((m) => isEqual(m, existing));
|
|
138
|
+
|
|
139
|
+
if (index >= 0) {
|
|
140
|
+
newMarks.splice(index, 1, update);
|
|
141
|
+
|
|
142
|
+
onChangeMarks(newMarks);
|
|
143
|
+
} else if (addIfMissing) {
|
|
144
|
+
onChangeMarks([...newMarks, update]);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
getComponent: any = (mark) => {
|
|
149
|
+
if (!mark) return null;
|
|
150
|
+
|
|
151
|
+
const tool = (this.props.tools || []).find((t) => t.type === mark.type);
|
|
152
|
+
|
|
153
|
+
return (tool && tool.Component) || null;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
onBgClick: any = (point) => {
|
|
157
|
+
const { x, y } = point || {};
|
|
158
|
+
const { labelModeEnabled, currentTool, marks, gssLineData, onSolutionSetSelected } = this.props;
|
|
159
|
+
if (gssLineData) {
|
|
160
|
+
if (gssLineData.selectedTool === 'solutionSet') {
|
|
161
|
+
onSolutionSetSelected(point);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (
|
|
165
|
+
gssLineData.numberOfLines === 1 &&
|
|
166
|
+
gssLineData.selectedTool === 'lineA' &&
|
|
167
|
+
marks.length === 1 &&
|
|
168
|
+
!marks[0].building
|
|
169
|
+
) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (gssLineData.numberOfLines === 2 && gssLineData.selectedTool === 'lineA' && marks.length === 2) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (
|
|
176
|
+
gssLineData.numberOfLines === 2 &&
|
|
177
|
+
gssLineData.selectedTool === 'lineA' &&
|
|
178
|
+
marks.length === 1 &&
|
|
179
|
+
!marks[0].building
|
|
180
|
+
) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (
|
|
184
|
+
gssLineData.numberOfLines === 2 &&
|
|
185
|
+
gssLineData.selectedTool === 'lineB' &&
|
|
186
|
+
marks.length === 2 &&
|
|
187
|
+
!marks[1].building
|
|
188
|
+
) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
if (labelModeEnabled || !currentTool || [null, undefined].includes(x) || [null, undefined].includes(y)) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
log('[onBgClick] x,y: ', x, y);
|
|
197
|
+
|
|
198
|
+
const buildingMark = marks.filter((m) => m.building)[0];
|
|
199
|
+
let updatedMark;
|
|
200
|
+
|
|
201
|
+
// if the building mark has a different type, we just replace it
|
|
202
|
+
if (buildingMark && currentTool && buildingMark.type === currentTool.type) {
|
|
203
|
+
updatedMark = currentTool.addPoint({ x, y }, { ...buildingMark });
|
|
204
|
+
} else {
|
|
205
|
+
updatedMark = currentTool.addPoint({ x, y }, undefined);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
this.updateMarks(buildingMark, updatedMark, true);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
render() {
|
|
212
|
+
const {
|
|
213
|
+
axesSettings,
|
|
214
|
+
currentTool,
|
|
215
|
+
coordinatesOnHover,
|
|
216
|
+
size,
|
|
217
|
+
disabledLabels,
|
|
218
|
+
disabledTitle,
|
|
219
|
+
domain,
|
|
220
|
+
backgroundMarks,
|
|
221
|
+
range,
|
|
222
|
+
title,
|
|
223
|
+
labels,
|
|
224
|
+
labelModeEnabled,
|
|
225
|
+
labelsPlaceholders,
|
|
226
|
+
showLabels,
|
|
227
|
+
showPixelGuides,
|
|
228
|
+
showTitle,
|
|
229
|
+
titlePlaceholder,
|
|
230
|
+
onChangeLabels,
|
|
231
|
+
onChangeTitle,
|
|
232
|
+
mathMlOptions = {},
|
|
233
|
+
gssLineData,
|
|
234
|
+
disabled,
|
|
235
|
+
} = this.props;
|
|
236
|
+
let { marks } = this.props;
|
|
237
|
+
|
|
238
|
+
const graphProps = createGraphProps(domain, range, size, () => this.rootNode);
|
|
239
|
+
|
|
240
|
+
const maskSize = getMaskSize(size);
|
|
241
|
+
let common = { graphProps, labelModeEnabled, gssLineData };
|
|
242
|
+
|
|
243
|
+
marks = removeBuildingToolIfCurrentToolDiffers({ marks: marks || [], currentTool });
|
|
244
|
+
let solutionSet = marks.filter((mark) => mark.type === 'polygon');
|
|
245
|
+
if (gssLineData && gssLineData.selectedTool === 'solutionSet') {
|
|
246
|
+
gssLineData.sections.forEach((section) => {
|
|
247
|
+
if (solutionSet.length === 0 || !areArraysOfObjectsEqual(section, solutionSet[0].points)) {
|
|
248
|
+
let polygon = {
|
|
249
|
+
type: 'polygon',
|
|
250
|
+
building: false,
|
|
251
|
+
closed: true,
|
|
252
|
+
points: section,
|
|
253
|
+
isSolution: false,
|
|
254
|
+
};
|
|
255
|
+
if (!disabled) marks.push(polygon);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
//Adjusted layering of added svg elements so that polygons will be added first and lines will be added second
|
|
260
|
+
let newMarks = [];
|
|
261
|
+
newMarks.push(...marks.filter((mark) => mark.type === 'polygon'));
|
|
262
|
+
newMarks.push(...marks.filter((mark) => mark.type === 'line'));
|
|
263
|
+
|
|
264
|
+
return (
|
|
265
|
+
<Root
|
|
266
|
+
rootRef={(r) => (this.rootNode = r)}
|
|
267
|
+
disabledTitle={disabledTitle}
|
|
268
|
+
disabledLabels={disabledLabels}
|
|
269
|
+
labels={labels}
|
|
270
|
+
labelsPlaceholders={labelsPlaceholders || {}}
|
|
271
|
+
showPixelGuides={showPixelGuides}
|
|
272
|
+
showLabels={showLabels}
|
|
273
|
+
showTitle={showTitle}
|
|
274
|
+
title={title}
|
|
275
|
+
titlePlaceholder={titlePlaceholder}
|
|
276
|
+
onChangeTitle={onChangeTitle}
|
|
277
|
+
onChangeLabels={onChangeLabels}
|
|
278
|
+
mathMlOptions={mathMlOptions}
|
|
279
|
+
{...common}
|
|
280
|
+
>
|
|
281
|
+
<g
|
|
282
|
+
transform={
|
|
283
|
+
domain && domain.padding && domain.range ? `translate(${domain.padding}, ${range.padding})` : undefined
|
|
284
|
+
}
|
|
285
|
+
>
|
|
286
|
+
<Grid {...common} />
|
|
287
|
+
<Axes {...axesSettings} {...common} />
|
|
288
|
+
<Bg {...size} onClick={this.onBgClick} {...common} />
|
|
289
|
+
<mask id={`${this.maskUid}`}>
|
|
290
|
+
<rect {...maskSize} fill="white" /> {/* TODO hardcoded color */}
|
|
291
|
+
</mask>
|
|
292
|
+
|
|
293
|
+
<g id="marks" mask={`url('#${this.maskUid}')`}>
|
|
294
|
+
{(backgroundMarks || []).map((m, index) => {
|
|
295
|
+
const Component = this.getComponent(m);
|
|
296
|
+
const markType = m.type;
|
|
297
|
+
|
|
298
|
+
return (
|
|
299
|
+
<Component
|
|
300
|
+
key={`${markType}-${index}-bg`}
|
|
301
|
+
mark={{ ...m, disabled: true, isBackground: true }}
|
|
302
|
+
labelNode={this.state.labelNode}
|
|
303
|
+
onClick={this.onBgClick}
|
|
304
|
+
{...common}
|
|
305
|
+
/>
|
|
306
|
+
);
|
|
307
|
+
})}
|
|
308
|
+
|
|
309
|
+
{newMarks.map((m, index) => {
|
|
310
|
+
const Component = this.getComponent(m);
|
|
311
|
+
const markType = m.type;
|
|
312
|
+
|
|
313
|
+
return (
|
|
314
|
+
<Component
|
|
315
|
+
key={`${markType}-${index}`}
|
|
316
|
+
mark={m}
|
|
317
|
+
coordinatesOnHover={coordinatesOnHover}
|
|
318
|
+
onChange={this.changeMark}
|
|
319
|
+
onComplete={this.completeMark}
|
|
320
|
+
onClick={this.onBgClick}
|
|
321
|
+
onDragStart={this.startDrag}
|
|
322
|
+
onDragStop={this.stopDrag}
|
|
323
|
+
labelNode={this.state.labelNode}
|
|
324
|
+
isToolActive={currentTool && markType === currentTool.type}
|
|
325
|
+
{...common}
|
|
326
|
+
/>
|
|
327
|
+
);
|
|
328
|
+
})}
|
|
329
|
+
<foreignObject
|
|
330
|
+
ref={(labelNode) => (this.labelNode = labelNode)}
|
|
331
|
+
x="0"
|
|
332
|
+
y="0"
|
|
333
|
+
{...size}
|
|
334
|
+
style={{ pointerEvents: 'none', fontSize: '14px' }}
|
|
335
|
+
/>
|
|
336
|
+
</g>
|
|
337
|
+
</g>
|
|
338
|
+
</Root>
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export default Graph;
|