Skip to content

Commit

Permalink
update from d3.nest to d3.group requires implies in key values
Browse files Browse the repository at this point in the history
This re-establishes the parent / scope hierarchy in Dataset Explorer.
manage-explorer.js : parentAndScope() : use n.entries() to retain the values with undefined / null keys.  recognise undefined and null values for key instead of corresponding string values - d3.nest() mapped keys to strings, whereas d3.group() preserves the original key values.
  • Loading branch information
Don-Isdale committed Mar 28, 2024
1 parent 74ef7ee commit f75ba24
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions frontend/app/components/panel/manage-explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1456,19 +1456,22 @@ export default ManageBase.extend({
* Since this .reduce() is mapping that result to a hash {key : value, .. },
* some simplification may be possible here.
*
* Object.entries(n) will not include the key undefined, so to display the
* orphan datasets use n.entries() which does,
* i.e. Array.from(n.entries()).reduce( )
* Object.entries(n) will not include the keys undefined or null, so to
* display the orphan datasets use n.entries() which does.
*/
let grouped =
Object.entries(n).reduce(
let grouped = Array.from(n.entries()).reduce(
/** Apply datasetsToBlocksByScope() to value or to the children of value
* if datasets in value are not children (i.e. ! key) */
function (result, datasetsByParent) {
const [key, values] = datasetsByParent;
/** hash: [scope] -> [blocks]. */
if (trace_dataTree > 1)
console.log('datasetsByParent', datasetsByParent);
// as commented in .key() function above.
if ((key === 'undefined') || (key === 'null')) {
/* d3.nest() mapped keys to strings, which resulted in strings
* 'undefined' and 'null' for key here, whereas d3.group() preserves
* the original key values */
if ((key === undefined) || (key === null)) {
/* datasets without parent - no change atm, just convert the nest to hash.
* but possibly move the children up to be parallel to the parents.
* i.e. merge datasetsByParent.values into result.
Expand Down

0 comments on commit f75ba24

Please sign in to comment.