* Retrieve row array and column names from an object of the form {a: [1,2,3,4], b: [30,20, 30, 20]} * @param obj The object to retrieve rows and column names from.
(obj: object)
| 178 | * @param obj The object to retrieve rows and column names from. |
| 179 | */ |
| 180 | getRowAndColValues(obj: object): [ArrayType1D | ArrayType2D, string[]] { |
| 181 | const colNames = Object.keys(obj); |
| 182 | const colData = Object.values(obj); |
| 183 | const firstColLen = colData[0].length; |
| 184 | |
| 185 | colData.forEach((cdata) => { |
| 186 | if (cdata.length != firstColLen) { |
| 187 | throw Error("Length Error: Length of columns must be the same!"); |
| 188 | } |
| 189 | }); |
| 190 | |
| 191 | const rowsArr = this.transposeArray(colData) |
| 192 | return [rowsArr, colNames]; |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * Converts a 2D array of array to 1D array for Series Class |
no test coverage detected