Skip to content
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

Added tooltip for TiledHeatmapMesh #1193

Merged
merged 1 commit into from
Oct 3, 2022
Merged

Added tooltip for TiledHeatmapMesh #1193

merged 1 commit into from
Oct 3, 2022

Conversation

loichuder
Copy link
Member

Related to #1177

Tried an analytical method as using the raycaster was not convienient at all. Indeed, as the whole layer group is intersected by the ray, we still need to filter manually the tiles. Perhaps I missed something so I could revisit this later.

The tooltip is not working properly for two cases:

  • with flipped axes
  • with transforms

I am fairly confident I can fix it for flipped axes but we can already discuss the current implementation.

packages/lib/src/vis/tiles/TiledHeatmapMesh.tsx Outdated Show resolved Hide resolved
packages/lib/src/vis/tiles/utils.ts Outdated Show resolved Hide resolved
packages/lib/src/vis/tiles/utils.ts Show resolved Hide resolved
@loichuder loichuder requested a review from t20100 August 18, 2022 13:44
Copy link
Member

@t20100 t20100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we already discussed, flipped axes support is needed and transforms support would be nice to have but not needed for now.

To me in the end, the tooltip mesh will need to be handled outside of the TiledHeatmapMesh because it should handle more than one mesh, but that's better to go step by step and it's fine for me like it is in this PR.

packages/lib/src/vis/tiles/TiledHeatmapMesh.tsx Outdated Show resolved Hide resolved
packages/lib/src/vis/tiles/TiledHeatmapMesh.tsx Outdated Show resolved Hide resolved
@loichuder
Copy link
Member Author

To me in the end, the tooltip mesh will need to be handled outside of the TiledHeatmapMesh because it should handle more than one mesh

Agreed. But it means the variables computed in TiledHeatmapMesh (tooltipLayer and meshSize) should somehow be available outside of it

@@ -152,11 +172,7 @@ const Template: Story<TiledHeatmapStoryProps> = (args) => {
<Zoom />
<SelectToZoom keepRatio modifierKey="Control" />
<ResetZoomButton />
<group
scale={[abscissaConfig.flip ? -1 : 1, ordinateConfig.flip ? -1 : 1, 1]}
>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flip is now handled at the layer level to avoid flipping the TiledTooltipMesh

@@ -46,9 +50,11 @@ function TiledHeatmapMesh(props: Props) {
);
const visibleBox = getObject3DVisibleBox(ndcToLocalMatrix);

const bounds = scaleToLayer(visibleBox, baseLayerSize, meshSize);
const { xScale, yScale } = useLayerScales(baseLayerSize, meshSize);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scales are now computed by a hook outside of scaleToLayer (renamed scaleBox) to be able to access the AxisContext and take the flip in account

@loichuder loichuder requested a review from t20100 August 25, 2022 13:12
@t20100
Copy link
Member

t20100 commented Aug 25, 2022

My bad, transforms (scale and position) also need to be supported, and flipped axes handled outside of the TiledHeatmaComponent.

@axelboc
Copy link
Contributor

axelboc commented Sep 5, 2022

To me in the end, the tooltip mesh will need to be handled outside of the TiledHeatmapMesh because it should handle more than one mesh

Agreed. But it means the variables computed in TiledHeatmapMesh (tooltipLayer and meshSize) should somehow be available outside of it

IMO, the most important is that the rendering of the tooltip content be the responsibility of the consumer, so there has to be a renderTooltip prop somewhere in the public API, and this prop should accept a function that gets called with all the necessary info.

renderTooltip can be a prop of TiledHeatmapMesh for now. If the prop is not set then TiledHeatmapMesh doesn't render a TooltipMesh at all.

Then, you can help consumers by providing a component to use inside renderTooltip - e.g. TiledTooltip (pretty much like TiledTooltipMesh but without the TooltipMesh): renderTooltip={tooltipProps => <TiledTooltip {...tooltipProps} />}

In the long term, maybe #988 will bring out some refactoring opportunities to allow having a fully separate TiledTooltipMesh component, I don't know... Or maybe a custom hook for consumers to use together with TiledHeatmapMesh and TiledTooltipMesh could be an option...

@loichuder loichuder marked this pull request as draft September 15, 2022 09:27
@loichuder
Copy link
Member Author

As the support of transform is needed, I will need to rework this. I am drafting it in the mean time.

@loichuder loichuder force-pushed the tiled-tooltip branch 5 times, most recently from 5b44cb2 to 6143e56 Compare September 29, 2022 14:00
@loichuder loichuder marked this pull request as ready for review September 29, 2022 14:03
@loichuder
Copy link
Member Author

Now handling transforms. I may revert the refactoring of scaleToLayer as the new implementation does not need it.

/>
))}
</group>
{showTooltip && <TiledTooltipMesh size={meshSize} />}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to make the size of TooltipMesh match the size of the TiledHeatmap

return (
<TooltipMesh
size={size}
renderTooltip={() => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renderTooltip could be exposed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is great for this PR. It can be passed down as prop in a separate PR.

Copy link
Contributor

@axelboc axelboc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reckon that the tooltip store is taking us really close to a shared solution for both the heatmap and the tiled heatmap, where the TooltipMesh would remain outside of/decoupled from the (Tiled)HeatmapMesh component. This has great potential: it could allow, for instance, consumers of the lib replace the tooltip with a status bar, a bit like on vector graphics software:

image

packages/lib/src/vis/tiles/Tile.tsx Show resolved Hide resolved
packages/lib/src/vis/tiles/utils.ts Outdated Show resolved Hide resolved
return (
<TooltipMesh
size={size}
renderTooltip={() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is great for this PR. It can be passed down as prop in a separate PR.

packages/lib/src/vis/tiles/TiledLayer.tsx Outdated Show resolved Hide resolved
packages/lib/src/vis/tiles/TiledLayer.tsx Outdated Show resolved Hide resolved
packages/lib/src/vis/tiles/utils.ts Show resolved Hide resolved
@axelboc
Copy link
Contributor

axelboc commented Sep 30, 2022

Now handling transforms. I may revert the refactoring of scaleToLayer as the new implementation does not need it.

No need, it's clear what's what, and the refactoring is nice 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants