diff --git a/src/components/array/ndarray.module.scss b/src/components/array/ndarray.module.scss index a623a61..82c8630 100644 --- a/src/components/array/ndarray.module.scss +++ b/src/components/array/ndarray.module.scss @@ -5,6 +5,7 @@ color: #777; tr { td { + text-align: center; border: 1px solid black; } } @@ -19,4 +20,19 @@ } } } +} + +.numberCell { + width: 100%; + display: flex; + .whole { + flex-grow: 1; + text-align: end; + } + .dot { + + } + .rational { + + } } \ No newline at end of file diff --git a/src/components/array/ndarray.tsx b/src/components/array/ndarray.tsx index 0f9f6af..c495b8a 100644 --- a/src/components/array/ndarray.tsx +++ b/src/components/array/ndarray.tsx @@ -10,6 +10,18 @@ type VisNDArrayProps = { } : unknown) +const NumberCell = ({value, roundTo} : {value: number, roundTo: number}) => { + const whole = Math.floor(value) + const rational = Math.round((Math.abs(value) % 1) * Math.pow(10, roundTo)) + return
+
{(whole + "").replace("-", "−")}
+
.
+
{rational}
+
+} + export const VisNDArray = (props: VisNDArrayProps) => { const maxElems = props.array.reduce((a, b) => Math.max(a, b.length), 0) return
@@ -34,7 +46,10 @@ export const VisNDArray = (props: VisNDArrayProps) {row.map((el, colIndex) => ( { - typeof el === "number" ? el.toFixed((props as VisNDArrayProps).roundTo ?? 2) : el + typeof el === "number" ? + ).roundTo ?? 2}/> + : + el } ))}