@pie-element/graphing 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/author/configure.d.ts +27 -0
- package/dist/author/configure.d.ts.map +1 -0
- package/dist/author/configure.js +208 -0
- package/dist/author/correct-response.d.ts +55 -0
- package/dist/author/correct-response.d.ts.map +1 -0
- package/dist/author/correct-response.js +304 -0
- package/dist/author/defaults.d.ts +295 -0
- package/dist/author/defaults.d.ts.map +1 -0
- package/dist/author/defaults.js +415 -0
- package/dist/author/graphing-config.d.ts +35 -0
- package/dist/author/graphing-config.d.ts.map +1 -0
- package/dist/author/graphing-config.js +244 -0
- package/dist/author/index.d.ts +60 -0
- package/dist/author/index.d.ts.map +1 -0
- package/dist/author/index.js +96 -0
- package/dist/author/utils.d.ts +44 -0
- package/dist/author/utils.d.ts.map +1 -0
- package/dist/author/utils.js +260 -0
- package/dist/controller/defaults.d.ts +60 -0
- package/dist/controller/defaults.d.ts.map +1 -0
- package/dist/controller/defaults.js +61 -0
- package/dist/controller/index.d.ts +34 -0
- package/dist/controller/index.d.ts.map +1 -0
- package/dist/controller/index.js +177 -0
- package/dist/controller/utils.d.ts +37 -0
- package/dist/controller/utils.d.ts.map +1 -0
- package/dist/controller/utils.js +111 -0
- package/dist/delivery/index.d.ts +22 -0
- package/dist/delivery/index.d.ts.map +1 -0
- package/dist/delivery/index.js +43 -0
- package/dist/delivery/main.d.ts +24 -0
- package/dist/delivery/main.d.ts.map +1 -0
- package/dist/delivery/main.js +107 -0
- package/dist/delivery/utils.d.ts +23 -0
- package/dist/delivery/utils.d.ts.map +1 -0
- package/dist/graphing.css +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.iife.d.ts +9 -0
- package/dist/index.iife.d.ts.map +1 -0
- package/dist/index.iife.js +374 -0
- package/dist/index.js +2 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_DataView.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Hash.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_ListCache.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Map.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_MapCache.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Promise.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Set.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_SetCache.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Stack.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Symbol.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_Uint8Array.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_WeakMap.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_apply.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayEach.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayFilter.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayIncludes.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayIncludesWith.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayLikeKeys.js +15 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayMap.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arrayPush.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_arraySome.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assignValue.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_assocIndexOf.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssign.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignIn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseAssignValue.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseClone.js +57 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseCreate.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseDifference.js +23 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseFindIndex.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseFlatten.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetAllKeys.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseGetTag.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIndexOf.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIntersection.js +29 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsArguments.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsEqual.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsEqualDeep.js +30 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsMap.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsNaN.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsNative.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsSet.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseIsTypedArray.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeys.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseKeysIn.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseRest.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseSet.js +22 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseSetToString.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseTimes.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseToString.js +15 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseUnary.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_baseUniq.js +27 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cacheHas.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_castArrayLikeObject.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_castPath.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneArrayBuffer.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneBuffer.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneDataView.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneRegExp.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneSymbol.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_cloneTypedArray.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyArray.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copyObject.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbols.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_copySymbolsIn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_coreJsData.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_createSet.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_defineProperty.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalArrays.js +35 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalByTag.js +35 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_equalObjects.js +32 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_freeGlobal.js +4 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeys.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getAllKeysIn.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getMapData.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getNative.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getPrototype.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getRawTag.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbols.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getSymbolsIn.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getTag.js +23 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_getValue.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashClear.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashDelete.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashGet.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashHas.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_hashSet.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneArray.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneByTag.js +33 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_initCloneObject.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isFlattenable.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isIndex.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isKey.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isKeyable.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isMasked.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_isPrototype.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheClear.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheDelete.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheGet.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheHas.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_listCacheSet.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheClear.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheDelete.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheGet.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheHas.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapCacheSet.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_mapToArray.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_memoizeCapped.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeCreate.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeys.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nativeKeysIn.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_nodeUtil.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_objectToString.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overArg.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_overRest.js +13 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_root.js +5 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setCacheAdd.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setCacheHas.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setToArray.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_setToString.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_shortOut.js +14 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackClear.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackDelete.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackGet.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackHas.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stackSet.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_strictIndexOf.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_stringToPath.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_toKey.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/_toSource.js +15 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/cloneDeep.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/constant.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/differenceWith.js +12 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/eq.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/identity.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/intersection.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArguments.js +10 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArray.js +4 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArrayLike.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isArrayLikeObject.js +8 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isBuffer.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isEmpty.js +21 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isEqual.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isFunction.js +11 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isLength.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isMap.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObject.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isObjectLike.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSet.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isSymbol.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/isTypedArray.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keys.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/keysIn.js +9 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/last.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/memoize.js +16 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/noop.js +4 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/set.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubArray.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/stubFalse.js +6 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/toString.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/uniq.js +7 -0
- package/dist/node_modules/.bun/lodash-es@4.17.23/node_modules/lodash-es/uniqWith.js +7 -0
- package/package.json +72 -0
- package/src/author/configure.tsx +299 -0
- package/src/author/correct-response.tsx +490 -0
- package/src/author/defaults.tsx +434 -0
- package/src/author/graphing-config.tsx +333 -0
- package/src/author/index.ts +204 -0
- package/src/author/utils.ts +144 -0
- package/src/controller/defaults.ts +74 -0
- package/src/controller/index.ts +458 -0
- package/src/controller/utils.ts +361 -0
- package/src/delivery/index.ts +79 -0
- package/src/delivery/main.tsx +180 -0
- package/src/delivery/utils.ts +34 -0
- package/src/index.iife.ts +16 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/graphing/controller/src/utils.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 { differenceWith, isEqual, uniq, uniqWith } from 'lodash-es';
|
|
12
|
+
import {
|
|
13
|
+
getAmplitudeAndFreq,
|
|
14
|
+
pointsToABC,
|
|
15
|
+
pointsToAForAbsolute,
|
|
16
|
+
pointsToABForExponential,
|
|
17
|
+
} from '@pie-lib/graphing-utils';
|
|
18
|
+
|
|
19
|
+
export const equalPoint = (A, B) => {
|
|
20
|
+
// x1 = x2 & y1 = y2
|
|
21
|
+
let equalLabel = true;
|
|
22
|
+
|
|
23
|
+
A = { ...A };
|
|
24
|
+
B = { ...B };
|
|
25
|
+
|
|
26
|
+
if (A.label || B.label) {
|
|
27
|
+
equalLabel = isEqual(A.label, B.label);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return isEqual(A.x, B.x) && isEqual(A.y, B.y);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const equalSegment = (segment1, segment2) => {
|
|
34
|
+
// A.from = B.from, A.to = B.to OR A.from = B.to, A.to = B.from
|
|
35
|
+
// x1 = x3 & y1 = y3 & x2 = x4 & y2 = y4
|
|
36
|
+
return (
|
|
37
|
+
(isEqual(segment1.from, segment2.from) && isEqual(segment1.to, segment2.to)) ||
|
|
38
|
+
(isEqual(segment1.to, segment2.from) && isEqual(segment1.from, segment2.to))
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const equalVector = (vector1, vector2) => {
|
|
43
|
+
// A.from = B.from, A.to = B.to;
|
|
44
|
+
// x1 = x3 & y1 = y3 & x2 = x4 & y2 = y4
|
|
45
|
+
return isEqual(vector1.from, vector2.from) && isEqual(vector1.to, vector2.to);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// this function is implemented in configure as well
|
|
49
|
+
export const sortedAnswers = (answers) =>
|
|
50
|
+
Object.keys(answers || {})
|
|
51
|
+
.sort()
|
|
52
|
+
.reduce((result, key) => {
|
|
53
|
+
if (key !== 'correctAnswer') {
|
|
54
|
+
result[key] = answers[key];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return result;
|
|
58
|
+
}, {});
|
|
59
|
+
|
|
60
|
+
const returnLineEquationCoefficients = (line) => {
|
|
61
|
+
line = { ...line, to: { ...line.to }, from: { ...line.from } };
|
|
62
|
+
|
|
63
|
+
const xA = line.from.x;
|
|
64
|
+
const yA = line.from.y;
|
|
65
|
+
const xB = line.to.x;
|
|
66
|
+
const yB = line.to.y;
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
a: yB - yA,
|
|
70
|
+
b: xA - xB,
|
|
71
|
+
c: xB * yA - xA * yB,
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const getSignificantDecimals = (number) => Math.round(number * 10000) / 10000;
|
|
76
|
+
|
|
77
|
+
export const equalLine = (line1, line2) => {
|
|
78
|
+
// line equation: ax + by + c = 0
|
|
79
|
+
// 2 lines are equal if a1/a2 = b1/b2 = c1/c2, where a, b, c are the coefficients in line equation
|
|
80
|
+
|
|
81
|
+
// line equation knowing 2 points: (y - yA) / (yB - yA) = (x - xA) / (xB - xA)
|
|
82
|
+
// extending this equation, we get: x * (yB - yA) + y * (xA - xB) + (xB * yA - xA * yB) = 0
|
|
83
|
+
// where a = yB - yA; b = xA - xB; c = xB * yA - xA * yB
|
|
84
|
+
|
|
85
|
+
const { a: a1, b: b1, c: c1 } = returnLineEquationCoefficients(line1);
|
|
86
|
+
const { a: a2, b: b2, c: c2 } = returnLineEquationCoefficients(line2);
|
|
87
|
+
|
|
88
|
+
const proportions = [];
|
|
89
|
+
|
|
90
|
+
if (a2 !== 0) {
|
|
91
|
+
proportions.push(getSignificantDecimals(a1 / a2));
|
|
92
|
+
} else if (a1 !== a2) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (b2 !== 0) {
|
|
97
|
+
proportions.push(getSignificantDecimals(b1 / b2));
|
|
98
|
+
} else if (b1 !== b2) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (c2 !== 0) {
|
|
103
|
+
proportions.push(getSignificantDecimals(c1 / c2));
|
|
104
|
+
} else if (c1 !== c2) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return uniq(proportions).length === 1;
|
|
109
|
+
|
|
110
|
+
// (y2 - y1)/(x2 - x1) = (y4 - y3)/(x4 - x3);
|
|
111
|
+
// return ((Math.abs((line1.to.y - line1.from.y) / (line1.to.x - line1.from.x))) === (Math.abs((line2.to.y - line2.from.y) / (line2.to.x - line2.from.x))));
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export const equalRay = (ray1, ray2) => {
|
|
115
|
+
ray1 = { ...ray1, to: { ...ray1.to }, from: { ...ray1.from } };
|
|
116
|
+
ray2 = { ...ray2, to: { ...ray2.to }, from: { ...ray2.from } };
|
|
117
|
+
|
|
118
|
+
// slope: m = (y2-y1)/(x2-x1)
|
|
119
|
+
// slope & x1 = x3 & y1 = y3 & angle between (x1, y1) (x2, y2) is same as angle between (x3, y3) (x4, y4)
|
|
120
|
+
const mRay1 = (ray1.to.y - ray1.from.y) / (ray1.to.x - ray1.from.x);
|
|
121
|
+
const mRay2 = (ray2.to.y - ray2.from.y) / (ray2.to.x - ray2.from.x);
|
|
122
|
+
const angleRay1 = (Math.atan2(ray1.to.y - ray1.from.y, ray1.to.x - ray1.from.x) * 180) / Math.PI;
|
|
123
|
+
const angleRay2 = (Math.atan2(ray2.to.y - ray2.from.y, ray2.to.x - ray2.from.x) * 180) / Math.PI;
|
|
124
|
+
|
|
125
|
+
return mRay1 === mRay2 && ray1.from.x === ray2.from.x && ray1.from.y === ray2.from.y && angleRay1 === angleRay2;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export const constructSegmentsFromPoints = (points) => {
|
|
129
|
+
// takes the list of points that represent a polygon and transforms it into a list of segments; eg.:
|
|
130
|
+
// points: A, B, C, D => segments: AB, BC, CD, DA
|
|
131
|
+
return (points || []).map((point, index) => ({ from: point, to: points[(index + 1) % points.length] }));
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export const removeDuplicateSegments = (segments) => {
|
|
135
|
+
segments = segments || [];
|
|
136
|
+
// removes segments that are duplicates; eg. These segments are the same, so one will be removed:
|
|
137
|
+
// segment1: from: { x: 1, y: 1 }, to: { x: 2, y: 1 }
|
|
138
|
+
// segment2: from: { x: 2, y: 1 }, to: { x: 1, y: 1 }
|
|
139
|
+
return uniqWith(segments, (s1, s2) => equalSegment(s1, s2));
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export const removeInvalidSegments = (segments) => {
|
|
143
|
+
segments = segments || [];
|
|
144
|
+
// removes segments that start in a point and end in the same point (eg.: from: { x: 1, y: 1 }, to: { x: 1, y: 1 })
|
|
145
|
+
|
|
146
|
+
return segments.filter((segment) => !isEqual(segment.from, segment.to));
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export const equalPolygon = (poly1, poly2) => {
|
|
150
|
+
const { points: points1 } = poly1;
|
|
151
|
+
const { points: points2 } = poly2;
|
|
152
|
+
|
|
153
|
+
// generate segments
|
|
154
|
+
const segments1 = constructSegmentsFromPoints(points1);
|
|
155
|
+
const segments2 = constructSegmentsFromPoints(points2);
|
|
156
|
+
|
|
157
|
+
const segments1NoDuplicates = removeDuplicateSegments(removeInvalidSegments(segments1));
|
|
158
|
+
const segments2NoDuplicates = removeDuplicateSegments(removeInvalidSegments(segments2));
|
|
159
|
+
|
|
160
|
+
const differentSegments1 = differenceWith(segments1NoDuplicates, segments2NoDuplicates, equalSegment);
|
|
161
|
+
const differentSegments2 = differenceWith(segments2NoDuplicates, segments1NoDuplicates, equalSegment);
|
|
162
|
+
|
|
163
|
+
return (!differentSegments1 || !differentSegments1.length) && (!differentSegments2 || !differentSegments2.length);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export const equalCircle = (c1, c2) => {
|
|
167
|
+
c1 = { ...c1, root: { ...c1.root }, edge: { ...c1.edge } };
|
|
168
|
+
c2 = { ...c2, root: { ...c2.root }, edge: { ...c2.edge } };
|
|
169
|
+
const equalRootAndEdge = isEqual(c2.edge, c1.edge) && isEqual(c2.root, c1.root);
|
|
170
|
+
|
|
171
|
+
// if both edge and root are the same, it means the shapes are exactly the same
|
|
172
|
+
if (equalRootAndEdge) return true;
|
|
173
|
+
|
|
174
|
+
const rC1 = Math.sqrt((c1.edge.x - c1.root.x) ** 2 + (c1.edge.y - c1.root.y) ** 2);
|
|
175
|
+
const rC2 = Math.sqrt((c2.edge.x - c2.root.x) ** 2 + (c2.edge.y - c2.root.y) ** 2);
|
|
176
|
+
|
|
177
|
+
// if both root and radius are the same, it means the shapes are equal
|
|
178
|
+
return isEqual(c2.root, c1.root) && isEqual(rC1, rC2);
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export const equalSine = (sine1, sine2) => {
|
|
182
|
+
const getPoints = ({ root, edge }) => {
|
|
183
|
+
root = { ...root };
|
|
184
|
+
edge = { ...edge };
|
|
185
|
+
|
|
186
|
+
const { amplitude, freq } = getAmplitudeAndFreq(root, edge);
|
|
187
|
+
// the height of the sine wave
|
|
188
|
+
const tY = Math.abs(root.y - edge.y) * 2;
|
|
189
|
+
// the distance on x axis between edge and root
|
|
190
|
+
const tXRoot = Math.abs(root.x - edge.x);
|
|
191
|
+
// the distance on x axis between 2 edges for sine wave (min & max)
|
|
192
|
+
const tX = tXRoot * 2;
|
|
193
|
+
// the first edge placed east side of root
|
|
194
|
+
let edgeAboveZeroX = edge.x;
|
|
195
|
+
let edgeAboveZeroY = edge.y;
|
|
196
|
+
|
|
197
|
+
// if edge less then 0, find out the appropriate edge placed east side of zero (0)
|
|
198
|
+
while (edgeAboveZeroX < 0 && tX !== 0) {
|
|
199
|
+
edgeAboveZeroX = edgeAboveZeroX + tX;
|
|
200
|
+
edgeAboveZeroY = edgeAboveZeroY < root.y ? edgeAboveZeroY + tY : edgeAboveZeroY - tY;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// if edge more then 0, find out the appropriate edge placed east side of zero (0)
|
|
204
|
+
while (edgeAboveZeroX - tX > 0 && tX !== 0) {
|
|
205
|
+
edgeAboveZeroX = edgeAboveZeroX - tX;
|
|
206
|
+
edgeAboveZeroY = edgeAboveZeroY < root.y ? edgeAboveZeroY + tY : edgeAboveZeroY - tY;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return {
|
|
210
|
+
amplitude: getSignificantDecimals(amplitude),
|
|
211
|
+
freq: getSignificantDecimals(freq),
|
|
212
|
+
min: getSignificantDecimals(edge.y < root.y ? edge.y : edge.y - tY),
|
|
213
|
+
max: getSignificantDecimals(edge.y < root.y ? edge.y + tY : edge.y),
|
|
214
|
+
edgeAboveZeroX: getSignificantDecimals(edgeAboveZeroX),
|
|
215
|
+
edgeAboveZeroY: getSignificantDecimals(edgeAboveZeroY),
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
const studentAnswerBpY = getPoints(sine1);
|
|
220
|
+
const correctAnswerBpY = getPoints(sine2);
|
|
221
|
+
|
|
222
|
+
const {
|
|
223
|
+
amplitude: amplitude1,
|
|
224
|
+
freq: freq1,
|
|
225
|
+
min: min1,
|
|
226
|
+
max: max1,
|
|
227
|
+
edgeAboveZeroX: edgeAboveZeroX1,
|
|
228
|
+
edgeAboveZeroY: edgeAboveZeroY1,
|
|
229
|
+
} = studentAnswerBpY;
|
|
230
|
+
const {
|
|
231
|
+
amplitude: amplitude2,
|
|
232
|
+
freq: freq2,
|
|
233
|
+
min: min2,
|
|
234
|
+
max: max2,
|
|
235
|
+
edgeAboveZeroX: edgeAboveZeroX2,
|
|
236
|
+
edgeAboveZeroY: edgeAboveZeroY2,
|
|
237
|
+
} = correctAnswerBpY;
|
|
238
|
+
|
|
239
|
+
return (
|
|
240
|
+
Math.abs(amplitude1) === Math.abs(amplitude2) &&
|
|
241
|
+
Math.abs(freq1) === Math.abs(freq2) &&
|
|
242
|
+
min1 === min2 &&
|
|
243
|
+
max1 === max2 &&
|
|
244
|
+
edgeAboveZeroX1 === edgeAboveZeroX2 &&
|
|
245
|
+
edgeAboveZeroY1 === edgeAboveZeroY2
|
|
246
|
+
);
|
|
247
|
+
// rootDiff1 === rootDiff2);
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
export const equalParabola = (p1, p2) => {
|
|
251
|
+
const { edge: edgeP1 } = p1;
|
|
252
|
+
const { edge: edgeP2 } = p2;
|
|
253
|
+
let { root: rootP1 } = p1;
|
|
254
|
+
let { root: rootP2 } = p2;
|
|
255
|
+
|
|
256
|
+
rootP1 = { ...rootP1 };
|
|
257
|
+
rootP2 = { ...rootP2 };
|
|
258
|
+
|
|
259
|
+
const p1edge = edgeP1 || { ...rootP1 };
|
|
260
|
+
const p2edge = edgeP2 || { ...rootP2 };
|
|
261
|
+
|
|
262
|
+
const p1mirrorEdge = { x: rootP1.x - (p1edge.x - rootP1.x), y: p1edge.y };
|
|
263
|
+
const p2mirrorEdge = { x: rootP2.x - (p2edge.x - rootP2.x), y: p2edge.y };
|
|
264
|
+
|
|
265
|
+
if (!edgeP1 || !edgeP2) return false;
|
|
266
|
+
|
|
267
|
+
const { a: a1, b: b1, c: c1 } = pointsToABC(rootP1, edgeP1, p1mirrorEdge);
|
|
268
|
+
const { a: a2, b: b2, c: c2 } = pointsToABC(rootP2, edgeP2, p2mirrorEdge);
|
|
269
|
+
|
|
270
|
+
// sometimes numbers have this form: 1.00000000002 because of calculations, we have to round them
|
|
271
|
+
const round = (number) => Math.round(number * 10000) / 10000;
|
|
272
|
+
|
|
273
|
+
return round(a1) === round(a2) && round(b1) === round(b2) && round(c1) === round(c2);
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
/*
|
|
277
|
+
* Function to check if given two points for absolute function
|
|
278
|
+
* for correct answer and student answer are equal or not.
|
|
279
|
+
* @param p1 - student answer
|
|
280
|
+
* @param p2 - correct answer
|
|
281
|
+
* */
|
|
282
|
+
export const equalAbsolute = (p1, p2) => {
|
|
283
|
+
const { edge: edgeP1 } = p1;
|
|
284
|
+
const { edge: edgeP2 } = p2;
|
|
285
|
+
let { root: rootP1 } = p1;
|
|
286
|
+
let { root: rootP2 } = p2;
|
|
287
|
+
|
|
288
|
+
rootP1 = { ...rootP1 };
|
|
289
|
+
rootP2 = { ...rootP2 };
|
|
290
|
+
|
|
291
|
+
const p1edge = edgeP1 || { ...rootP1 };
|
|
292
|
+
const p2edge = edgeP2 || { ...rootP2 };
|
|
293
|
+
|
|
294
|
+
const p1a1 = pointsToAForAbsolute(rootP1, p1edge);
|
|
295
|
+
const p2a2 = pointsToAForAbsolute(rootP2, p2edge);
|
|
296
|
+
|
|
297
|
+
// if both root and a value are equal
|
|
298
|
+
return isEqual(rootP2, rootP1) && isEqual(p2a2, p1a1);
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
/*
|
|
302
|
+
* Function to check if given two points for exponential function
|
|
303
|
+
* for correct answer and student answer are equal or not.
|
|
304
|
+
* @param p1 - student answer
|
|
305
|
+
* @param p2 - correct answer
|
|
306
|
+
* */
|
|
307
|
+
export const equalExponential = (p1, p2) => {
|
|
308
|
+
const { edge: edgeP1 } = p1;
|
|
309
|
+
const { edge: edgeP2 } = p2;
|
|
310
|
+
let { root: rootP1 } = p1;
|
|
311
|
+
let { root: rootP2 } = p2;
|
|
312
|
+
|
|
313
|
+
rootP1 = { ...rootP1 };
|
|
314
|
+
rootP2 = { ...rootP2 };
|
|
315
|
+
|
|
316
|
+
const p1edge = edgeP1 || { ...rootP1 };
|
|
317
|
+
const p2edge = edgeP2 || { ...rootP2 };
|
|
318
|
+
|
|
319
|
+
const { a1, b1 } = pointsToABForExponential(rootP1, p1edge);
|
|
320
|
+
const { a2, b2 } = pointsToABForExponential(rootP2, p2edge);
|
|
321
|
+
|
|
322
|
+
// if both a and b value are equal
|
|
323
|
+
return isEqual(a2, a1) && isEqual(b2, b1);
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
export const equalMarks = {
|
|
327
|
+
circle: (sessAnswer, mark) => equalCircle(sessAnswer, mark),
|
|
328
|
+
line: (sessAnswer, mark) => equalLine(sessAnswer, mark),
|
|
329
|
+
parabola: (sessAnswer, mark) => equalParabola(sessAnswer, mark),
|
|
330
|
+
absolute: (sessAnswer, mark) => equalAbsolute(sessAnswer, mark),
|
|
331
|
+
exponential: (sessAnswer, mark) => equalExponential(sessAnswer, mark),
|
|
332
|
+
point: (sessAnswer, mark) => equalPoint(sessAnswer, mark),
|
|
333
|
+
polygon: (sessAnswer, poly) => equalPolygon(sessAnswer, poly),
|
|
334
|
+
ray: (sessAnswer, mark) => equalRay(sessAnswer, mark),
|
|
335
|
+
segment: (sessAnswer, mark) => equalSegment(sessAnswer, mark),
|
|
336
|
+
sine: (sessAnswer, mark) => equalSine(sessAnswer, mark),
|
|
337
|
+
vector: (sessAnswer, mark) => equalVector(sessAnswer, mark),
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
const completePoint = (point) => point && Number.isFinite(point.x) && Number.isFinite(point.y);
|
|
341
|
+
const completeFromTo = (item) => item && completeMark.point(item.from) && completeMark.point(item.to);
|
|
342
|
+
const completeRootEdge = (item) => item && completeMark.point(item.edge) && completeMark.point(item.root);
|
|
343
|
+
const completePoints = (item) =>
|
|
344
|
+
item &&
|
|
345
|
+
item.points &&
|
|
346
|
+
item.points.length &&
|
|
347
|
+
(item.points.filter((point) => completePoint(point)) || []).length === item.points.length;
|
|
348
|
+
|
|
349
|
+
const completeMark = {
|
|
350
|
+
point: completePoint,
|
|
351
|
+
line: completeFromTo,
|
|
352
|
+
ray: completeFromTo,
|
|
353
|
+
segment: completeFromTo,
|
|
354
|
+
vector: completeFromTo,
|
|
355
|
+
circle: completeRootEdge,
|
|
356
|
+
parabola: completeRootEdge,
|
|
357
|
+
absolute: completeRootEdge,
|
|
358
|
+
exponential: completeRootEdge,
|
|
359
|
+
sine: completeRootEdge,
|
|
360
|
+
polygon: completePoints,
|
|
361
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/graphing/src/index.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 React from 'react';
|
|
12
|
+
import { createRoot } from 'react-dom/client';
|
|
13
|
+
import { SessionChangedEvent } from '@pie-element/shared-player-events';
|
|
14
|
+
import { renderMath } from '@pie-element/shared-math-rendering-mathjax';
|
|
15
|
+
|
|
16
|
+
import Main from './main.js';
|
|
17
|
+
|
|
18
|
+
export { Main as Component };
|
|
19
|
+
|
|
20
|
+
export default class Graphing extends HTMLElement {
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
this._root = null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
set model(m) {
|
|
27
|
+
this._model = m;
|
|
28
|
+
this._render();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
set session(s) {
|
|
32
|
+
this._session = s;
|
|
33
|
+
this._render();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
get session() {
|
|
37
|
+
return this._session;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
connectedCallback() {
|
|
41
|
+
this._render();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
isComplete = (answer) => Array.isArray(answer) && answer.length > 0;
|
|
45
|
+
|
|
46
|
+
changeAnswers: any = (answer) => {
|
|
47
|
+
this._session.answer = answer;
|
|
48
|
+
|
|
49
|
+
this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete(this._session.answer)));
|
|
50
|
+
|
|
51
|
+
this._render();
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
_render() {
|
|
55
|
+
if (!this._model || !this._session) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const el = React.createElement(Main, {
|
|
60
|
+
model: this._model,
|
|
61
|
+
session: this._session,
|
|
62
|
+
onAnswersChange: this.changeAnswers,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
if (!this._root) {
|
|
66
|
+
this._root = createRoot(this);
|
|
67
|
+
}
|
|
68
|
+
this._root.render(el);
|
|
69
|
+
queueMicrotask(() => {
|
|
70
|
+
renderMath(this);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
disconnectedCallback() {
|
|
75
|
+
if (this._root) {
|
|
76
|
+
this._root.unmount();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/graphing/src/main.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 { GraphContainer, KeyLegend } from '@pie-lib/graphing';
|
|
15
|
+
import { color, Collapsible as CollapsibleImport, hasText, hasMedia, PreviewPrompt as PreviewPromptImport, UiLayout as UiLayoutImport } from '@pie-lib/render-ui';
|
|
16
|
+
|
|
17
|
+
function isRenderableReactInteropType(value: any) {
|
|
18
|
+
return (
|
|
19
|
+
typeof value === 'function' ||
|
|
20
|
+
(typeof value === 'object' && value !== null && typeof value.$$typeof === 'symbol')
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function unwrapReactInteropSymbol(maybeSymbol: any, namedExport?: string) {
|
|
25
|
+
if (!maybeSymbol) return maybeSymbol;
|
|
26
|
+
if (isRenderableReactInteropType(maybeSymbol)) return maybeSymbol;
|
|
27
|
+
if (isRenderableReactInteropType(maybeSymbol.default)) return maybeSymbol.default;
|
|
28
|
+
if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport])) {
|
|
29
|
+
return maybeSymbol[namedExport];
|
|
30
|
+
}
|
|
31
|
+
if (namedExport && isRenderableReactInteropType(maybeSymbol[namedExport]?.default)) {
|
|
32
|
+
return maybeSymbol[namedExport].default;
|
|
33
|
+
}
|
|
34
|
+
return maybeSymbol;
|
|
35
|
+
}
|
|
36
|
+
const UiLayout = unwrapReactInteropSymbol(UiLayoutImport, 'UiLayout') || unwrapReactInteropSymbol(renderUi.UiLayout, 'UiLayout');
|
|
37
|
+
const PreviewPrompt = unwrapReactInteropSymbol(PreviewPromptImport, 'PreviewPrompt') || unwrapReactInteropSymbol(renderUi.PreviewPrompt, 'PreviewPrompt');
|
|
38
|
+
const Collapsible = unwrapReactInteropSymbol(CollapsibleImport, 'Collapsible') || unwrapReactInteropSymbol(renderUi.Collapsible, 'Collapsible');
|
|
39
|
+
import * as RenderUiNamespace from '@pie-lib/render-ui';
|
|
40
|
+
const renderUiNamespaceAny = RenderUiNamespace as any;
|
|
41
|
+
const renderUiDefaultMaybe = renderUiNamespaceAny['default'];
|
|
42
|
+
const renderUi =
|
|
43
|
+
renderUiDefaultMaybe && typeof renderUiDefaultMaybe === 'object'
|
|
44
|
+
? renderUiDefaultMaybe
|
|
45
|
+
: renderUiNamespaceAny;
|
|
46
|
+
import CorrectAnswerToggle from '@pie-lib/correct-answer-toggle';
|
|
47
|
+
|
|
48
|
+
const MainContainer: any = styled(UiLayout)({
|
|
49
|
+
color: color.text(),
|
|
50
|
+
backgroundColor: color.background(),
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const TeacherInstructions: any = styled(Collapsible)(({ theme }) => ({
|
|
54
|
+
marginBottom: theme.spacing(2),
|
|
55
|
+
}));
|
|
56
|
+
|
|
57
|
+
const Graph: any = styled(GraphContainer)(({ theme }) => ({
|
|
58
|
+
marginTop: theme.spacing(2),
|
|
59
|
+
marginBottom: theme.spacing(2),
|
|
60
|
+
}));
|
|
61
|
+
|
|
62
|
+
export class Main extends React.Component {
|
|
63
|
+
static propTypes = {
|
|
64
|
+
model: PropTypes.object.isRequired,
|
|
65
|
+
session: PropTypes.object.isRequired,
|
|
66
|
+
onAnswersChange: PropTypes.func,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
state = { showingCorrect: false };
|
|
70
|
+
|
|
71
|
+
toggleCorrect = (showingCorrect) => this.setState({ showingCorrect });
|
|
72
|
+
|
|
73
|
+
render() {
|
|
74
|
+
const { model, onAnswersChange, session } = this.props;
|
|
75
|
+
const { showingCorrect } = this.state;
|
|
76
|
+
const { answer } = session || {};
|
|
77
|
+
const {
|
|
78
|
+
answersCorrected,
|
|
79
|
+
arrows,
|
|
80
|
+
backgroundMarks,
|
|
81
|
+
coordinatesOnHover,
|
|
82
|
+
correctResponse,
|
|
83
|
+
defaultTool,
|
|
84
|
+
disabled,
|
|
85
|
+
domain,
|
|
86
|
+
extraCSSRules,
|
|
87
|
+
labels,
|
|
88
|
+
labelsEnabled,
|
|
89
|
+
prompt,
|
|
90
|
+
range,
|
|
91
|
+
rationale,
|
|
92
|
+
showKeyLegend,
|
|
93
|
+
showToggle,
|
|
94
|
+
title,
|
|
95
|
+
titleEnabled,
|
|
96
|
+
teacherInstructions,
|
|
97
|
+
toolbarTools,
|
|
98
|
+
language,
|
|
99
|
+
} = model || {};
|
|
100
|
+
const size = model?.size || model?.graph || {}; // need this for models that are not processed by controller
|
|
101
|
+
const marks = answersCorrected || answer || [];
|
|
102
|
+
const isLabelAvailable = toolbarTools?.includes('label') || false;
|
|
103
|
+
const showRationale = model.rationale && (hasText(model.rationale) || hasMedia(model.rationale));
|
|
104
|
+
const showTeacherInstructions =
|
|
105
|
+
model.teacherInstructions && (hasText(model.teacherInstructions) || hasMedia(model.teacherInstructions));
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<MainContainer extraCSSRules={extraCSSRules}>
|
|
109
|
+
{showTeacherInstructions && (
|
|
110
|
+
<TeacherInstructions
|
|
111
|
+
labels={{ hidden: 'Show Teacher Instructions', visible: 'Hide Teacher Instructions' }}
|
|
112
|
+
>
|
|
113
|
+
<PreviewPrompt prompt={teacherInstructions} />
|
|
114
|
+
</TeacherInstructions>
|
|
115
|
+
)}
|
|
116
|
+
|
|
117
|
+
{prompt && <PreviewPrompt className="prompt" prompt={prompt} />}
|
|
118
|
+
|
|
119
|
+
<CorrectAnswerToggle
|
|
120
|
+
show={showToggle}
|
|
121
|
+
toggled={showingCorrect}
|
|
122
|
+
onToggle={this.toggleCorrect}
|
|
123
|
+
language={language}
|
|
124
|
+
/>
|
|
125
|
+
|
|
126
|
+
{showingCorrect && showToggle ? (
|
|
127
|
+
<Graph
|
|
128
|
+
axesSettings={{ includeArrows: arrows }}
|
|
129
|
+
backgroundMarks={backgroundMarks.filter((mark) => !mark.building)}
|
|
130
|
+
coordinatesOnHover={coordinatesOnHover}
|
|
131
|
+
disabled={true}
|
|
132
|
+
disabledLabels={true}
|
|
133
|
+
disabledTitle={true}
|
|
134
|
+
domain={domain}
|
|
135
|
+
labels={labels}
|
|
136
|
+
marks={correctResponse.map((i) => ({ ...i, correctness: 'correct' }))}
|
|
137
|
+
onChangeMarks={onAnswersChange}
|
|
138
|
+
range={range}
|
|
139
|
+
showLabels={labelsEnabled}
|
|
140
|
+
showTitle={titleEnabled}
|
|
141
|
+
size={size}
|
|
142
|
+
title={title}
|
|
143
|
+
toolbarTools={toolbarTools}
|
|
144
|
+
language={language}
|
|
145
|
+
/>
|
|
146
|
+
) : (
|
|
147
|
+
<Graph
|
|
148
|
+
axesSettings={{ includeArrows: arrows }}
|
|
149
|
+
backgroundMarks={backgroundMarks.filter((mark) => !mark.building)}
|
|
150
|
+
coordinatesOnHover={coordinatesOnHover}
|
|
151
|
+
defaultTool={defaultTool}
|
|
152
|
+
disabled={disabled}
|
|
153
|
+
disabledLabels={true}
|
|
154
|
+
disabledTitle={true}
|
|
155
|
+
domain={domain}
|
|
156
|
+
labels={labels}
|
|
157
|
+
marks={marks}
|
|
158
|
+
onChangeMarks={onAnswersChange}
|
|
159
|
+
range={range}
|
|
160
|
+
showLabels={labelsEnabled}
|
|
161
|
+
showTitle={titleEnabled}
|
|
162
|
+
size={size}
|
|
163
|
+
title={title}
|
|
164
|
+
toolbarTools={toolbarTools}
|
|
165
|
+
language={language}
|
|
166
|
+
limitLabeling={true}
|
|
167
|
+
/>
|
|
168
|
+
)}
|
|
169
|
+
{showKeyLegend && !showingCorrect && <KeyLegend isLabelAvailable={isLabelAvailable}></KeyLegend>}
|
|
170
|
+
{showRationale && (
|
|
171
|
+
<Collapsible labels={{ hidden: 'Show Rationale', visible: 'Hide Rationale' }}>
|
|
172
|
+
<PreviewPrompt prompt={rationale} />
|
|
173
|
+
</Collapsible>
|
|
174
|
+
)}
|
|
175
|
+
</MainContainer>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export default Main;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* @synced-from pie-elements/packages/graphing/src/utils.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 completePoint = (point) => point && Number.isFinite(point.x) && Number.isFinite(point.y);
|
|
12
|
+
const completeFromTo = (item) => item && completeMark.point(item.from) && completeMark.point(item.to);
|
|
13
|
+
const completeRootEdge = (item) => item && completeMark.point(item.edge) && completeMark.point(item.root);
|
|
14
|
+
const completePoints = (item) =>
|
|
15
|
+
item &&
|
|
16
|
+
item.points &&
|
|
17
|
+
item.points.length &&
|
|
18
|
+
(item.points.filter((point) => completePoint(point)) || []).length === item.points.length;
|
|
19
|
+
|
|
20
|
+
const completeMark = {
|
|
21
|
+
point: completePoint,
|
|
22
|
+
line: completeFromTo,
|
|
23
|
+
ray: completeFromTo,
|
|
24
|
+
segment: completeFromTo,
|
|
25
|
+
vector: completeFromTo,
|
|
26
|
+
circle: completeRootEdge,
|
|
27
|
+
parabola: completeRootEdge,
|
|
28
|
+
absolute: completeRootEdge,
|
|
29
|
+
exponential: completeRootEdge,
|
|
30
|
+
sine: completeRootEdge,
|
|
31
|
+
polygon: completePoints,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { completeMark };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IIFE entry point for graphing element
|
|
3
|
+
* This file is only used for IIFE builds and includes auto-registration
|
|
4
|
+
*
|
|
5
|
+
* @sync-generated - Auto-generated during sync from pie-elements
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import Element from './index.js';
|
|
9
|
+
|
|
10
|
+
// Auto-register the custom element for IIFE mode
|
|
11
|
+
if (typeof window !== 'undefined' && !customElements.get('graphing-element')) {
|
|
12
|
+
customElements.define('graphing-element', Element);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Export for IIFE global
|
|
16
|
+
export default Element;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './delivery/index.js';
|