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

Add point selection handling to WebstatusLineChartPanel #1178

Merged
merged 2 commits into from
Feb 20, 2025

Conversation

jcscottiii
Copy link
Collaborator

@jcscottiii jcscottiii commented Feb 18, 2025

This will be useful for this milestone: https://github.com/GoogleChrome/webstatus.dev/milestone/10

This PR builds upon the enhanced webstatus-gchart component (see related PR #1177 ) by adding functionality to the WebstatusLineChartPanel abstract class to handle point selection and deselection events. This provides a consistent and customizable way for subclasses to react to user interactions with the chart.

Key changes:

  • createPointSelectedTask method: This new method allows subclasses to define a Task to be executed when a point is selected on the chart. It also enables them to provide a renderSuccess function to render content based on the task's result.
  • Event handling: The handlePointSelected and handlePointDeselected methods handle the point-selected and point-deselected events dispatched by the webstatus-gchart component.
  • State management: The _pointSelectedTask and _renderCustomPointSelectedSuccess properties store the state associated with the selected point.
  • Rendering: The renderPointSelectedDetails method provides a placeholder for rendering details about the selected point, which can be customized by subclasses.
  • Loading states: The renderPointSelectedDetails method now includes loading states (pending, initial, error) to provide visual feedback during task execution.

This enhancement enables subclasses of WebstatusLineChartPanel to easily handle point selection and deselection events, providing a more interactive and informative user experience. It leverages the new events introduced in the webstatus-gchart component (see related PR #1177) to provide a seamless and consistent way to manage chart interactions.

@jcscottiii jcscottiii force-pushed the jcscotttiii/line-use-click branch from 9f37b24 to fd32f8a Compare February 19, 2025 13:57
@jcscottiii jcscottiii force-pushed the jcscottiii/capture-gchart-click branch from 7363ed6 to ea8053d Compare February 19, 2025 14:14
@jcscottiii jcscottiii force-pushed the jcscotttiii/line-use-click branch from fd32f8a to 1bbac3a Compare February 19, 2025 14:15
@jcscottiii jcscottiii force-pushed the jcscottiii/capture-gchart-click branch from ea8053d to e19d966 Compare February 19, 2025 21:46
@jcscottiii jcscottiii force-pushed the jcscotttiii/line-use-click branch from 1bbac3a to c52894b Compare February 19, 2025 21:47
@jcscottiii jcscottiii linked an issue Feb 19, 2025 that may be closed by this pull request
Copy link
Collaborator

@jrobbins jrobbins left a comment

Choose a reason for hiding this comment

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

LGTM after one question.

Base automatically changed from jcscottiii/capture-gchart-click to main February 20, 2025 19:47
This PR builds upon the enhanced `webstatus-gchart` component (see related PR) by adding functionality to the `WebstatusLineChartPanel` abstract class to handle point selection and deselection events. This provides a consistent and customizable way for subclasses to react to user interactions with the chart.

**Key changes:**

* **`createPointSelectedTask` method:** This new method allows subclasses to define a `Task` to be executed when a point is selected on the chart. It also enables them to provide a `renderSuccess` function to render content based on the task's result.
* **Event handling:** The `handlePointSelected` and `handlePointDeselected` methods handle the `point-selected` and `point-deselected` events dispatched by the `webstatus-gchart` component.
* **State management:** The `_pointSelectedTask` and `_renderCustomPointSelectedSuccess` properties store the state associated with the selected point.
* **Rendering:** The `renderPointSelectedDetails` method provides a placeholder for rendering details about the selected point, which can be customized by subclasses.
* **Loading states:** The `renderPointSelectedDetails` method now includes loading states (pending, initial, error) to provide visual feedback during task execution.

This enhancement enables subclasses of `WebstatusLineChartPanel` to easily handle point selection and deselection events, providing a more interactive and informative user experience. It leverages the new events introduced in the `webstatus-gchart` component (see related PR) to provide a seamless and consistent way to manage chart interactions.
@jcscottiii jcscottiii force-pushed the jcscotttiii/line-use-click branch from c52894b to 41821d9 Compare February 20, 2025 20:13
@jcscottiii jcscottiii added this pull request to the merge queue Feb 20, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 20, 2025
@jcscottiii jcscottiii added this pull request to the merge queue Feb 20, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 20, 2025
@jcscottiii jcscottiii added this pull request to the merge queue Feb 20, 2025
Merged via the queue into main with commit 8035e25 Feb 20, 2025
6 checks passed
@jcscottiii jcscottiii deleted the jcscotttiii/line-use-click branch February 20, 2025 23:18
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.

Add ability to detect clicks on data points
2 participants