-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Component | Treemap: New component #2
base: exaforce
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great progress! Lets some small, mainly code style related comments to the code.
const nestedData = group(data.keys(), ...layerAccessors as [(d: number) => string]) | ||
|
||
const rootNode = config.value !== undefined | ||
? hierarchy(nestedData).sum(index => typeof index === 'number' && getNumber(data[index], config.value, index)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious, what will happen when typeof index
is not a number?
Also you can use the isNumber
function from utils here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH I don't fully grok this section of the code. It's mainly copied over from the packages/ts/src/components/nested-donut/index.ts
component. I think index
is always a number, but TypeScript doesn't know that, so this check is probably just to make the TypeScript linting happy.
Anyway, I'm debating how much of this to rip out, and how much to keep. Some of it is definitely useful to support the layers
config idea. Ideally we could refactor the logic that's useful for both components into a single definition. Maybe some of the _getHierarchyData
implementation from the nested donut could be moved into a shared utility.
Would it be fine to introduce such a refactoring in this PR? Or maybe it would be best to have duplication for the first version, then refactor later? Not sure.
In any case, if we clean this up here we can also clean it up in nested donut.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still need to circle back and test this code path. I'm thinking to add a new example that tests this path, compare that to what nested donut does, and truly get to the bottom of what this is supposed to do, and why that typeof
check is even there. I suspect is has to do with using the output of group
as the input to hierarchy
, in which case the type of data
is different for internal nodes (a 2-element array) and leaf nodes (the integer index - which I think this is checking for).
|
||
export interface TreemapNode<Datum> extends HierarchyRectangularNode<TreemapDatum<Datum>> { | ||
_id: string; | ||
_state?: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know NestedDonut
has a similar type, but do we really need this _state
as a dedicated nested object?
I feel like we can flatten it and that will make the code look cleaner (by removing _state?.
fragments).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I was also skeptical about pulling in this logic from the nested donut. Will try to get rid of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's tricky to remove this, because it helps with propagating the colors from the parents to the children.
I tried computing the color at render time, but it's more complex since we'd need to traverse up the tree for each node to figure out what color it should be, based on its parents.
I say let's leave this logic here, as it's in a way cleaner to traverse the whole hierarchy just once to compute the colors in a dedicated step. Perhaps later we can clean it up in both the treemap and nested donut at the same time, if there's a cleaner way.
@curran Also I think we should use Unovis text utils here to handle labels. Check out the Annotations component for a usage example: unovis/packages/ts/src/components/annotations/index.ts Lines 64 to 72 in d41b469
|
The initial transition looks a bit weird to me. I think it would be better if the rectangles were already placed where they should be, and just faded out. Screen.Recording.2025-01-06.at.4.08.14.PM.mp4 |
Thanks so much for the detailed review! I'll go through each point and make sure to address them all. I have not been paying attention to the transitions at all, thanks for calling that out! I'll plan to work through the development like this:
checkpoint for potential PR merge
|
Directions moving forward
|
Current status: searchDemo.mov
|
Closes f5#516