zakodium-oss / react-science

React components and tools to build scientific applications.
https://react-science.pages.dev
MIT License
2 stars 6 forks source link

MeasurementPlot, zoom and enhancements #144

Closed lpatiny closed 2 years ago

lpatiny commented 2 years ago

Add properties allowing to zoom, scroll, pan

Some default behaviour without properties:

Some other properties:

wadjih-bencheikh18 commented 2 years ago

Using react hooks conditionally is forbidden i couldn't find a solution to implement these functionalities, i only suggest adding a new param in react-plot hooks so the user will be able to use them conditionally or would you please suggest any other possible solutions?

lpatiny commented 2 years ago

I think that the hooks can always be 'active'. However we could think about properties at the level of the hook that disabled it.

For example:

https://github.com/zakodium-oss/react-plot/blob/2c74502a14007959b717d1837372281916dc1a86/src/hooks/useAxisZoom.tsx#L17-L18

Could have direction:'none' to disable the hook.

Same for the wheel and crosshair hooks.

@targos Does this make sense ?

targos commented 2 years ago

Yes, but I would create a general option.

What about usePlotEvents({ disabled: true }) which would not pass the callbacks and can be inherited by all higher-level hooks?

wadjih-bencheikh18 commented 2 years ago

which would not pass the callbacks and can be inherited by all higher-level hooks?

I agree with using a general option

lpatiny commented 2 years ago

Please also add small default spaces between the axis values and axis labels (4px ?)

image

image

As well as between the title and the chart

image

Please check also that you deal correctly with the fact that the data may be missing a scale label of the chart title.