@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/bg.tsx
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-lib/packages/graphing-solution-set/src/bg.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 { pointer, select } from 'd3-selection';
|
|
14
|
+
import { types, utils } from '@pie-lib/plot';
|
|
15
|
+
import { getTickValues, thinnerShapesNeeded } from './utils.js';
|
|
16
|
+
|
|
17
|
+
export default class Bg extends React.Component {
|
|
18
|
+
static propTypes = {
|
|
19
|
+
width: PropTypes.number.isRequired,
|
|
20
|
+
height: PropTypes.number.isRequired,
|
|
21
|
+
onClick: PropTypes.func.isRequired,
|
|
22
|
+
graphProps: types.GraphPropsType.isRequired,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
static defaultProps = {};
|
|
26
|
+
|
|
27
|
+
componentDidMount() {
|
|
28
|
+
const rect = select(this.rect);
|
|
29
|
+
|
|
30
|
+
rect.on('click', (event) => this.onRectClick(rect, event));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
shouldComponentUpdate(nextProps) {
|
|
34
|
+
return (
|
|
35
|
+
!utils.isDomainRangeEqual(this.props.graphProps, nextProps.graphProps) ||
|
|
36
|
+
this.props.width !== nextProps.width ||
|
|
37
|
+
this.props.height !== nextProps.height
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
getRectPadding: any = () => {
|
|
42
|
+
const { graphProps } = this.props;
|
|
43
|
+
|
|
44
|
+
return thinnerShapesNeeded(graphProps) ? 6 : 10;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Note: we use d3 click + pointer to give us domain values directly.
|
|
49
|
+
* Saves us having to calculate them ourselves from a MouseEvent.
|
|
50
|
+
*/
|
|
51
|
+
onRectClick: any = (rect, event) => {
|
|
52
|
+
const { onClick, graphProps } = this.props;
|
|
53
|
+
const { scale } = graphProps;
|
|
54
|
+
|
|
55
|
+
const padding = this.getRectPadding();
|
|
56
|
+
const coords = pointer(event, rect.node());
|
|
57
|
+
|
|
58
|
+
// decrease the padding from coordinates to indicate the correct point clicked
|
|
59
|
+
const x = scale.x.invert(coords[0] - padding);
|
|
60
|
+
const y = scale.y.invert(coords[1] - padding);
|
|
61
|
+
|
|
62
|
+
const rowTicks = getTickValues(graphProps.range);
|
|
63
|
+
const columnTicks = getTickValues(graphProps.domain);
|
|
64
|
+
|
|
65
|
+
const closest = (ticks, value) => {
|
|
66
|
+
return (
|
|
67
|
+
ticks.length &&
|
|
68
|
+
ticks.reduce((prev, curr) => {
|
|
69
|
+
const currentDistance = Math.abs(curr - value);
|
|
70
|
+
const previousDistance = Math.abs(prev - value);
|
|
71
|
+
|
|
72
|
+
return currentDistance <= previousDistance ? curr : prev;
|
|
73
|
+
})
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
let snapped = {};
|
|
78
|
+
|
|
79
|
+
if (columnTicks.indexOf(x) >= 0 && rowTicks.indexOf(y) >= 0) {
|
|
80
|
+
snapped.x = x;
|
|
81
|
+
snapped.y = y;
|
|
82
|
+
} else {
|
|
83
|
+
snapped.x = closest(columnTicks, x);
|
|
84
|
+
snapped.y = closest(rowTicks, y);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
onClick(snapped);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
render() {
|
|
91
|
+
const { width, height } = this.props;
|
|
92
|
+
const padding = this.getRectPadding();
|
|
93
|
+
|
|
94
|
+
// expand the size of clickable area so a small area outside the edges of the grid lines to be clickable
|
|
95
|
+
return (
|
|
96
|
+
<rect
|
|
97
|
+
ref={(rect) => (this.rect = rect)}
|
|
98
|
+
transform={`translate(-${padding}, -${padding})`}
|
|
99
|
+
fill="red"
|
|
100
|
+
fillOpacity="0.0"
|
|
101
|
+
width={width + padding * 2}
|
|
102
|
+
height={height + padding * 2}
|
|
103
|
+
/>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-lib/packages/graphing-solution-set/src/container/actions.js
|
|
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
|
+
export const addMark = () => ({
|
|
12
|
+
type: 'ADD_MARK',
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const changeMarks = (marks) => ({
|
|
16
|
+
type: 'CHANGE_MARKS',
|
|
17
|
+
marks,
|
|
18
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-lib/packages/graphing-solution-set/src/container/index.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 { connect, Provider } from 'react-redux';
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { applyMiddleware, createStore } from 'redux';
|
|
14
|
+
import reducer from './reducer.js';
|
|
15
|
+
import { changeMarks } from './actions.js';
|
|
16
|
+
import PropTypes from 'prop-types';
|
|
17
|
+
import { isEqual } from 'lodash-es';
|
|
18
|
+
import { ActionCreators } from 'redux-undo';
|
|
19
|
+
import GraphWithControls from '../graph-with-controls.js';
|
|
20
|
+
import { getLastAction, lastActionMiddleware } from './middleware.js';
|
|
21
|
+
|
|
22
|
+
const mapStateToProps = (s) => ({
|
|
23
|
+
marks: s.marks.present,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const mapDispatchToProps = (dispatch) => ({
|
|
27
|
+
onChangeMarks: (m) => dispatch(changeMarks(m)),
|
|
28
|
+
onUndo: () => dispatch(ActionCreators.undo()),
|
|
29
|
+
onRedo: () => dispatch(ActionCreators.redo()),
|
|
30
|
+
onReset: () => dispatch(changeMarks([])),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export const GraphContainer = connect(mapStateToProps, mapDispatchToProps)(GraphWithControls);
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The graph component entry point with undo/redo
|
|
37
|
+
* Redux is an implementation detail, hide it in the react component.
|
|
38
|
+
*/
|
|
39
|
+
class Root extends React.Component {
|
|
40
|
+
static propTypes = {
|
|
41
|
+
onChangeMarks: PropTypes.func,
|
|
42
|
+
marks: PropTypes.array,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
constructor(props) {
|
|
46
|
+
super(props);
|
|
47
|
+
|
|
48
|
+
const r = reducer();
|
|
49
|
+
this.store = createStore(r, { marks: props.marks }, applyMiddleware(lastActionMiddleware));
|
|
50
|
+
|
|
51
|
+
this.store.subscribe(this.onStoreChange);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
componentDidUpdate(prevProps) {
|
|
55
|
+
const { marks } = this.props;
|
|
56
|
+
const storeState = this.store.getState();
|
|
57
|
+
|
|
58
|
+
if (isEqual(storeState.marks.present, marks)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (!isEqual(prevProps.marks, marks)) {
|
|
63
|
+
this.store.dispatch(changeMarks(marks));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
onStoreChange: any = () => {
|
|
68
|
+
const { marks, onChangeMarks } = this.props;
|
|
69
|
+
const storeState = this.store.getState();
|
|
70
|
+
const lastAction = getLastAction();
|
|
71
|
+
const isUndoOperation = lastAction.type.includes('UNDO') || lastAction.type.includes('REDO');
|
|
72
|
+
|
|
73
|
+
if (!isEqual(storeState.marks.present, marks)) {
|
|
74
|
+
onChangeMarks(storeState.marks.present, isUndoOperation);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
render() {
|
|
79
|
+
// eslint-disable-next-line no-unused-vars
|
|
80
|
+
const { onChangeMarks, marks, ...rest } = this.props;
|
|
81
|
+
const correctnessSet = marks && marks.find((m) => m.correctness);
|
|
82
|
+
|
|
83
|
+
if (correctnessSet) {
|
|
84
|
+
return <GraphWithControls {...rest} marks={marks} disabled={correctnessSet} />;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<Provider store={this.store}>
|
|
89
|
+
<GraphContainer {...rest} />
|
|
90
|
+
</Provider>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export default Root;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-lib/packages/graphing-solution-set/src/container/marks.js
|
|
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
|
+
const marks = (state = [], action) => {
|
|
12
|
+
switch (action.type) {
|
|
13
|
+
case 'CHANGE_MARKS':
|
|
14
|
+
if (Array.isArray(action.marks)) {
|
|
15
|
+
return action.marks;
|
|
16
|
+
} else {
|
|
17
|
+
throw new Error('marks must be an array');
|
|
18
|
+
}
|
|
19
|
+
default:
|
|
20
|
+
return state;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default marks;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-lib/packages/graphing-solution-set/src/container/middleware.js
|
|
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
|
+
let lastAction = null;
|
|
12
|
+
export const getLastAction = () => lastAction;
|
|
13
|
+
|
|
14
|
+
export const lastActionMiddleware = () => (next) => (action) => {
|
|
15
|
+
lastAction = action;
|
|
16
|
+
return next(action);
|
|
17
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-lib/packages/graphing-solution-set/src/container/reducer.js
|
|
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 { combineReducers } from 'redux';
|
|
12
|
+
import marks from './marks.js';
|
|
13
|
+
import undoable from 'redux-undo';
|
|
14
|
+
|
|
15
|
+
export default () => combineReducers({ marks: undoable(marks, { debug: false }) });
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-lib/packages/graphing-solution-set/src/coordinates-label.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 { types } from '@pie-lib/plot';
|
|
14
|
+
import { color } from '@pie-lib/render-ui';
|
|
15
|
+
import { styled } from '@mui/material/styles';
|
|
16
|
+
import InputBase from '@mui/material/InputBase';
|
|
17
|
+
import { roundNumber } from './utils.js';
|
|
18
|
+
|
|
19
|
+
const StyledInputBase: any = styled(InputBase)(({ theme }) => ({
|
|
20
|
+
fontFamily: theme.typography.fontFamily,
|
|
21
|
+
fontSize: theme.typography.fontSize,
|
|
22
|
+
borderRadius: '8px',
|
|
23
|
+
background: theme.palette.common.white,
|
|
24
|
+
color: color.defaults.BLACK,
|
|
25
|
+
'& .MuiInputBase-input': {
|
|
26
|
+
padding: 0,
|
|
27
|
+
},
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
export const getLabelPosition = (graphProps, x, y, labelLength) => {
|
|
31
|
+
const { scale, domain, range } = graphProps;
|
|
32
|
+
// treat corner cases for maximum and minimum
|
|
33
|
+
const topShift = y === range.min ? 16 : y === range.max ? 0 : 8;
|
|
34
|
+
const leftShift = 10;
|
|
35
|
+
const rightEdge = scale.x(x) + labelLength + leftShift;
|
|
36
|
+
|
|
37
|
+
if (rightEdge >= scale.x(domain.max)) {
|
|
38
|
+
return {
|
|
39
|
+
left: scale.x(x) - leftShift - labelLength,
|
|
40
|
+
top: scale.y(y) - topShift,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
left: scale.x(x) + leftShift,
|
|
46
|
+
top: scale.y(y) - topShift,
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const CoordinatesLabel = ({ x, y, graphProps }) => {
|
|
51
|
+
const label = `(${roundNumber(x)}, ${roundNumber(y)})`;
|
|
52
|
+
const labelLength = (label.length || 0) * 6;
|
|
53
|
+
const labelPosition = getLabelPosition(graphProps, x, y, labelLength);
|
|
54
|
+
|
|
55
|
+
const style = {
|
|
56
|
+
position: 'absolute',
|
|
57
|
+
pointerEvents: 'auto',
|
|
58
|
+
width: labelLength,
|
|
59
|
+
padding: 0,
|
|
60
|
+
...labelPosition,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return <StyledInputBase style={style} value={label} inputProps={{ ariaLabel: 'naked' }} />;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
CoordinatesLabel.propTypes = {
|
|
67
|
+
graphProps: types.GraphPropsType,
|
|
68
|
+
x: PropTypes.number,
|
|
69
|
+
y: PropTypes.number,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export default CoordinatesLabel;
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-lib/packages/graphing-solution-set/src/graph-with-controls.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 { styled } from '@mui/material/styles';
|
|
14
|
+
import classNames from 'classnames';
|
|
15
|
+
import { isString, uniq } from 'lodash-es';
|
|
16
|
+
import { color } from '@pie-lib/render-ui';
|
|
17
|
+
import ToolMenu from './tool-menu.js';
|
|
18
|
+
import Graph, { graphPropTypes } from './graph.js';
|
|
19
|
+
import UndoRedo from './undo-redo.js';
|
|
20
|
+
import { allTools, toolsArr } from './tools/index.js';
|
|
21
|
+
import { Accordion, AccordionDetails, AccordionSummary, Typography } from '@mui/material';
|
|
22
|
+
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
23
|
+
|
|
24
|
+
export const setToolbarAvailability = (toolbarTools) =>
|
|
25
|
+
toolsArr.map((tA) => ({
|
|
26
|
+
...tA,
|
|
27
|
+
toolbar: !!toolbarTools.find((t) => t === tA.type),
|
|
28
|
+
})) || [];
|
|
29
|
+
|
|
30
|
+
export const toolIsAvailable = (tools, currentTool) =>
|
|
31
|
+
currentTool && tools && (tools.find((tool) => tool.type === currentTool.type) || {}).toolbar;
|
|
32
|
+
|
|
33
|
+
export const getAvailableTool = (tools) => tools.find((tool) => tool.toolbar);
|
|
34
|
+
|
|
35
|
+
export const filterByValidToolTypes = (backgroundMarks) =>
|
|
36
|
+
backgroundMarks.filter((bM) => !!allTools.find((tool) => tool === bM.type));
|
|
37
|
+
|
|
38
|
+
export const filterByVisibleToolTypes = (toolbarTools, marks) =>
|
|
39
|
+
marks.filter((bM) => !!toolbarTools.find((tool) => tool === bM.type));
|
|
40
|
+
|
|
41
|
+
const getDefaultCurrentTool = (toolType) => toolsArr.find((tool) => tool.type === toolType) || null;
|
|
42
|
+
|
|
43
|
+
const GraphWithControlsRoot: any = styled('div')(() => ({
|
|
44
|
+
display: 'flex',
|
|
45
|
+
flexDirection: 'column',
|
|
46
|
+
width: 'min-content',
|
|
47
|
+
}));
|
|
48
|
+
|
|
49
|
+
const Controls: any = styled('div')(() => ({
|
|
50
|
+
display: 'flex',
|
|
51
|
+
justifyContent: 'space-between',
|
|
52
|
+
padding: 'calc(1.25rem - 12px) calc(1.25rem - 12px) 1.25rem',
|
|
53
|
+
color: color.text(),
|
|
54
|
+
backgroundColor: '#9FA8DA',
|
|
55
|
+
'& button': {
|
|
56
|
+
fontSize: '0.875rem',
|
|
57
|
+
padding: '0.25rem .3rem',
|
|
58
|
+
width: '5rem',
|
|
59
|
+
},
|
|
60
|
+
}));
|
|
61
|
+
|
|
62
|
+
const StyledAccordion: any = styled(Accordion)(() => ({
|
|
63
|
+
backgroundColor: color.primaryLight(),
|
|
64
|
+
width: '100%',
|
|
65
|
+
boxShadow: 'none',
|
|
66
|
+
}));
|
|
67
|
+
|
|
68
|
+
const StyledAccordionSummary: any = styled(AccordionSummary)(({ theme }) => ({
|
|
69
|
+
padding: `0 ${theme.spacing(1)}`,
|
|
70
|
+
minHeight: '32px !important',
|
|
71
|
+
'& .MuiAccordionSummary-content': {
|
|
72
|
+
margin: '4px 0 !important',
|
|
73
|
+
},
|
|
74
|
+
}));
|
|
75
|
+
|
|
76
|
+
const StyledAccordionDetails: any = styled(AccordionDetails)(({ theme }) => ({
|
|
77
|
+
padding: 0,
|
|
78
|
+
marginTop: theme.spacing(1),
|
|
79
|
+
display: 'flex',
|
|
80
|
+
justifyContent: 'space-between',
|
|
81
|
+
}));
|
|
82
|
+
|
|
83
|
+
const UndoRedoOuterDiv: any = styled('div')(() => ({
|
|
84
|
+
display: 'flex',
|
|
85
|
+
flexDirection: 'column',
|
|
86
|
+
marginTop: '.5rem',
|
|
87
|
+
}));
|
|
88
|
+
|
|
89
|
+
const Collapsible = ({ children, title }) => (
|
|
90
|
+
<StyledAccordion square disableGutters>
|
|
91
|
+
<StyledAccordionSummary expandIcon={<ExpandMoreIcon />}>
|
|
92
|
+
<Typography variant="subtitle1">{title}</Typography>
|
|
93
|
+
</StyledAccordionSummary>
|
|
94
|
+
<StyledAccordionDetails>{children}</StyledAccordionDetails>
|
|
95
|
+
</StyledAccordion>
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
Collapsible.propTypes = {
|
|
99
|
+
children: PropTypes.node,
|
|
100
|
+
title: PropTypes.string,
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export class GraphWithControls extends React.Component {
|
|
104
|
+
static propTypes = {
|
|
105
|
+
...graphPropTypes,
|
|
106
|
+
onUndo: PropTypes.func,
|
|
107
|
+
onRedo: PropTypes.func,
|
|
108
|
+
onReset: PropTypes.func,
|
|
109
|
+
toolbarTools: PropTypes.arrayOf(PropTypes.string),
|
|
110
|
+
language: PropTypes.string,
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
static defaultProps = {
|
|
114
|
+
collapsibleToolbar: false,
|
|
115
|
+
collapsibleToolbarTitle: '',
|
|
116
|
+
disabledLabels: false,
|
|
117
|
+
disabledTitle: false,
|
|
118
|
+
showLabels: true,
|
|
119
|
+
showTitle: true,
|
|
120
|
+
toolbarTools: [],
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
constructor(props) {
|
|
124
|
+
super(props);
|
|
125
|
+
this.state = {
|
|
126
|
+
currentTool: getDefaultCurrentTool(props.defaultTool),
|
|
127
|
+
labelModeEnabled: false,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
componentDidUpdate(prevProps) {
|
|
132
|
+
const { defaultTool } = this.props;
|
|
133
|
+
if (prevProps.defaultTool !== defaultTool) {
|
|
134
|
+
const currentTool = getDefaultCurrentTool(defaultTool);
|
|
135
|
+
this.setState({ currentTool });
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
changeCurrentTool = (tool, tools) => this.setState({ currentTool: tools.find((t) => t.type === tool) });
|
|
140
|
+
|
|
141
|
+
toggleLabelMode = () => this.setState((state) => ({ labelModeEnabled: !state.labelModeEnabled }));
|
|
142
|
+
|
|
143
|
+
render() {
|
|
144
|
+
let { currentTool, labelModeEnabled } = this.state;
|
|
145
|
+
const {
|
|
146
|
+
axesSettings,
|
|
147
|
+
className,
|
|
148
|
+
coordinatesOnHover,
|
|
149
|
+
collapsibleToolbar,
|
|
150
|
+
collapsibleToolbarTitle,
|
|
151
|
+
disabled,
|
|
152
|
+
disabledLabels,
|
|
153
|
+
disabledTitle,
|
|
154
|
+
domain,
|
|
155
|
+
labels,
|
|
156
|
+
labelsPlaceholders,
|
|
157
|
+
onChangeLabels,
|
|
158
|
+
onChangeMarks,
|
|
159
|
+
onChangeTitle,
|
|
160
|
+
onUndo,
|
|
161
|
+
onRedo,
|
|
162
|
+
range,
|
|
163
|
+
size,
|
|
164
|
+
showLabels,
|
|
165
|
+
showPixelGuides,
|
|
166
|
+
showTitle,
|
|
167
|
+
title,
|
|
168
|
+
titlePlaceholder,
|
|
169
|
+
language,
|
|
170
|
+
disableToolbar = false,
|
|
171
|
+
gssLineData,
|
|
172
|
+
onChangeGssLineData,
|
|
173
|
+
onSolutionSetSelected,
|
|
174
|
+
onCustomReset,
|
|
175
|
+
} = this.props;
|
|
176
|
+
|
|
177
|
+
let { backgroundMarks, marks, toolbarTools } = this.props;
|
|
178
|
+
|
|
179
|
+
toolbarTools = uniq(toolbarTools || []).filter((tT) => !!isString(tT)) || [];
|
|
180
|
+
backgroundMarks = filterByValidToolTypes(backgroundMarks || []);
|
|
181
|
+
marks = filterByVisibleToolTypes(toolbarTools, marks || []);
|
|
182
|
+
|
|
183
|
+
if (gssLineData && gssLineData.lineA && marks[0] && marks[0].type === 'line')
|
|
184
|
+
marks[0].fill = gssLineData.lineA.lineType;
|
|
185
|
+
if (gssLineData && gssLineData.lineB && marks[1] && marks[1].type === 'line')
|
|
186
|
+
marks[1].fill = gssLineData.lineB.lineType;
|
|
187
|
+
|
|
188
|
+
const tools = setToolbarAvailability(toolbarTools);
|
|
189
|
+
if (!currentTool || !toolIsAvailable(tools, currentTool)) {
|
|
190
|
+
currentTool = getAvailableTool(tools);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const gssActions = gssLineData && (
|
|
194
|
+
<>
|
|
195
|
+
<ToolMenu
|
|
196
|
+
numberOfLines={gssLineData.numberOfLines}
|
|
197
|
+
gssLineData={gssLineData}
|
|
198
|
+
onChange={onChangeGssLineData}
|
|
199
|
+
disabled={!!disabled}
|
|
200
|
+
language={language}
|
|
201
|
+
/>
|
|
202
|
+
{!disabled && (
|
|
203
|
+
<UndoRedoOuterDiv>
|
|
204
|
+
<UndoRedo onUndo={onUndo} onRedo={onRedo} onReset={onCustomReset} language={language} />
|
|
205
|
+
</UndoRedoOuterDiv>
|
|
206
|
+
)}
|
|
207
|
+
</>
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
return (
|
|
211
|
+
<GraphWithControlsRoot className={classNames(className)}>
|
|
212
|
+
{!disableToolbar && (
|
|
213
|
+
<Controls>
|
|
214
|
+
{collapsibleToolbar ? <Collapsible title={collapsibleToolbarTitle}>{gssActions}</Collapsible> : gssActions}
|
|
215
|
+
</Controls>
|
|
216
|
+
)}
|
|
217
|
+
|
|
218
|
+
<div ref={(r) => (this.labelNode = r)} />
|
|
219
|
+
|
|
220
|
+
<Graph
|
|
221
|
+
axesSettings={axesSettings}
|
|
222
|
+
backgroundMarks={backgroundMarks}
|
|
223
|
+
coordinatesOnHover={coordinatesOnHover}
|
|
224
|
+
currentTool={currentTool}
|
|
225
|
+
disabledLabels={disabledLabels}
|
|
226
|
+
disabledTitle={disabledTitle}
|
|
227
|
+
domain={domain}
|
|
228
|
+
labels={labels}
|
|
229
|
+
labelModeEnabled={labelModeEnabled}
|
|
230
|
+
labelsPlaceholders={labelsPlaceholders}
|
|
231
|
+
marks={marks}
|
|
232
|
+
onChangeMarks={!disabled ? onChangeMarks : undefined}
|
|
233
|
+
onChangeLabels={onChangeLabels}
|
|
234
|
+
onChangeTitle={onChangeTitle}
|
|
235
|
+
range={range}
|
|
236
|
+
size={size}
|
|
237
|
+
showLabels={showLabels}
|
|
238
|
+
showPixelGuides={showPixelGuides}
|
|
239
|
+
showTitle={showTitle}
|
|
240
|
+
title={title}
|
|
241
|
+
titlePlaceholder={titlePlaceholder}
|
|
242
|
+
tools={tools}
|
|
243
|
+
gssLineData={gssLineData}
|
|
244
|
+
onSolutionSetSelected={onSolutionSetSelected}
|
|
245
|
+
disabled={!!disabled}
|
|
246
|
+
/>
|
|
247
|
+
</GraphWithControlsRoot>
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export default GraphWithControls;
|