-
Notifications
You must be signed in to change notification settings - Fork 118
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
feat: graph events #84
base: main
Are you sure you want to change the base?
Conversation
Support for graph events added.
### `EventTooltipComponent` | ||
An additional event component that is rendered if the `SelectionDot` overlaps an `Event`. | ||
|
||
### `onEventHover` |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
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.
The library does not work with any tap gestures so far. The only user interaction so far is created by the pan gesture which is also the gesture that enables the new event functionality of this PR. I would prefer to not add this functionality to not make the PR too big. The onPressEvent
could be added to the follow-up PR if needed.
### `EventComponent` | ||
A component that is used to render an event. | ||
|
||
### `EventTooltipComponent` |
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.
Please create some default component EventTooltip and link it here as example (same asi SelectionDot)
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.
Default component created in the fixup 5ff9fd7.
|
||
### `EventComponent` | ||
A component that is used to render an event. |
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.
Link EventComponent file here as example (same as SelectionDot)
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.
Linked in the fixup 5ff9fd7.
README.md
Outdated
|
||
Example: | ||
|
||
<img src="./img/events.png" align="right" height="200" /> |
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.
nit: Can you make default color of event different that line? Maybe some kind of simple fade out gradient of dot or something like that will make it really nice.
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.
The style of the default event component was adjusted to appear more contrasting. 5ff9fd7
src/hooks/useEventTooltipProps.ts
Outdated
onEventHover?: () => void | ||
) => { | ||
const [activeEventIndex, setActiveEventIndex] = useState<number | null>(null) | ||
const handleDisplayEventTooltip = ( |
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.
useCallback
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.
Fixed in 5ff9fd7.
Oh wow, this is pretty cool. CC @chrispader |
} | ||
|
||
export const LineGraph = React.memo(LineGraphImpl) | ||
export const LineGraph = React.memo(LineGraphImpl) as typeof LineGraphImpl |
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.
Why? This should be typed
I'll try to review this during this week! 👍 |
@chrispader Any progress with the review? 🙏🙂 |
hey guys, any updates on this? |
Will look into this tmrw! |
Description
This pull request introduces support for graph events in the application. The main goal is to enhance the user experience by providing the ability to render events in the line graph and highlight important interactions.
To achieve this, the AnimatedLineGraph component accepts four new props
events
,EventComponent
,EventTooltipComponent
andonEventHover
.events
is an array of objects that represents each individual interaction and its associated metadata. Each object in this array includes a date
property, which is used to calculate the coordinates of the event on the graph.EventComponent
is a component that receives the coordinates and metadata of each event and renders it within the graph.EventTooltipComponent
optional element that is rendered when hovering over an EventComponent element.onEventHover
is a callback that triggers hovering over anEventComponent
allowing for additional actions.Demo
Screen.Recording.2023-07-17.at.7.46.52.mov