Skip to content

Conversation

@simark
Copy link
Collaborator

@simark simark commented Dec 2, 2025

Allow double-clicking to reset the graph zoom level (Claude told me it's a common pattern) and show the price when hovering the graph.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds two UI enhancements to the price history graph: a double-click gesture to reset zoom levels and a hover display showing the price and date at the cursor position.

  • Implements double-click to reset graph zoom using uPlot's hooks system
  • Adds real-time price/date display when hovering over the graph
  • Provides user guidance with instructional text below the chart

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 120 to 144
u.over.addEventListener('dblclick', handleDblClick);
// Store handler for cleanup when chart is destroyed
(u as any)._dblClickHandler = handleDblClick;
},
],
destroy: [
(u) => {
const handler = (u as any)._dblClickHandler;
if (handler) {
u.over.removeEventListener('dblclick', handler);
}
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

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

The double-click to reset zoom feature is not keyboard accessible. Consider adding keyboard support (e.g., pressing 'R' or 'Escape' to reset) for users who cannot use a mouse. You could add a keydown event listener in the init hook similar to the double-click handler.

Suggested change
u.over.addEventListener('dblclick', handleDblClick);
// Store handler for cleanup when chart is destroyed
(u as any)._dblClickHandler = handleDblClick;
},
],
destroy: [
(u) => {
const handler = (u as any)._dblClickHandler;
if (handler) {
u.over.removeEventListener('dblclick', handler);
}
const handleKeyDown = (event: KeyboardEvent) => {
// Allow 'r' or 'Escape' to reset zoom
if (
(event.key === 'r' || event.key === 'R') ||
event.key === 'Escape'
) {
if (originalScales) {
u.setScale('x', originalScales);
}
}
};
u.over.addEventListener('dblclick', handleDblClick);
window.addEventListener('keydown', handleKeyDown);
// Store handlers for cleanup when chart is destroyed
(u as any)._dblClickHandler = handleDblClick;
(u as any)._keyDownHandler = handleKeyDown;
},
],
destroy: [
(u) => {
const dblClickHandler = (u as any)._dblClickHandler;
if (dblClickHandler) {
u.over.removeEventListener('dblclick', dblClickHandler);
}
const keyDownHandler = (u as any)._keyDownHandler;
if (keyDownHandler) {
window.removeEventListener('keydown', keyDownHandler);
}

Copilot uses AI. Check for mistakes.
The build warned that `chartContainer` was updated but not declared
with `$state(...)`. In Svelte 5, variables used with `bind:this` must
be declared as reactive state to properly track DOM element bindings.

Changed from:
  let chartContainer: HTMLDivElement;

To:
  let chartContainer = $state<HTMLDivElement>(null!);

The `null!` non-null assertion tells TypeScript the value will be
assigned before use (which is guaranteed by `bind:this` at mount time).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

simark and others added 2 commits December 1, 2025 22:47
Users can now double-click the chart or press r/Esc to reset the zoom
level after dragging to zoom in. Also adds a hint below the chart
explaining the zoom controls.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Display the price and date in the chart header when hovering over
the price history graph, providing easier readability of specific
data points.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@simark simark force-pushed the claude-poirier-10-4 branch from 5f0a3e9 to 3cc7631 Compare December 2, 2025 03:48
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.

1 participant