Skip to content

Display the vertical line in the timeline when hovering the marker chart or stack chart, fixes #222.#4742

Merged
julienw merged 2 commits into
firefox-devtools:mainfrom
fqueze:vertical-line
Sep 14, 2023
Merged

Display the vertical line in the timeline when hovering the marker chart or stack chart, fixes #222.#4742
julienw merged 2 commits into
firefox-devtools:mainfrom
fqueze:vertical-line

Conversation

@fqueze

@fqueze fqueze commented Sep 11, 2023

Copy link
Copy Markdown
Contributor

Fixes #222

This PR does the PR 3 and PR 4 work mentioned in Greg's comment explaining what were the things to do.

I haven't included tests, if we think we need some, I would need a bit of help to figure out where they should be, and what they should do.

The code in the new onMouseMove methods has some duplication with the hitTest methods. It could be possible to factor out some of it (but a new method would need to return both the xInUnitInterval and xInTime values), not sure it's worth it.

This only displays the vertical line in the timeline when hovering the marker chart of stack chart. Ideally we would want to show vertical lines in these two panels too, but I thought this small PR was already useful enough to be worth pushing, and we could do the rest in future PRs.

@fqueze fqueze requested review from canova and julienw September 11, 2023 16:26
@codecov

codecov Bot commented Sep 11, 2023

Copy link
Copy Markdown

Codecov Report

Patch coverage: 91.17% and project coverage change: +0.01% 🎉

Comparison is base (f615beb) 88.32% compared to head (5a691d8) 88.34%.

❗ Current head 5a691d8 differs from pull request most recent head a9946fa. Consider uploading reports for the commit a9946fa to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4742      +/-   ##
==========================================
+ Coverage   88.32%   88.34%   +0.01%     
==========================================
  Files         300      300              
  Lines       26734    26767      +33     
  Branches     7214     7219       +5     
==========================================
+ Hits        23612    23646      +34     
  Misses       2909     2909              
+ Partials      213      212       -1     
Files Changed Coverage Δ
src/components/marker-chart/index.js 100.00% <ø> (ø)
src/components/stack-chart/index.js 86.66% <ø> (ø)
src/reducers/profile-view.js 96.46% <ø> (ø)
src/components/timeline/Selection.js 79.06% <50.00%> (-0.46%) ⬇️
src/components/stack-chart/Canvas.js 93.53% <84.61%> (-0.62%) ⬇️
src/components/marker-chart/Canvas.js 93.93% <100.00%> (+0.62%) ⬆️
src/components/shared/chart/Canvas.js 91.33% <100.00%> (+1.75%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@julienw julienw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe we should pass the React events to these handlers, but otherwise this looks pretty good to me.

In terms of testing, you could add something in src/test/components/MarkerChart.test.js , you can see how we use fireMouseEvent in some tests. For example you could fire a mousemove event, and then check the value of the mouse position in the store, fire another mousemove event and then check this moved, and finally fire a mouseleave event and check the value is null.

Tell me what you think!

Comment thread src/components/shared/chart/Canvas.js Outdated
Comment on lines +34 to +35
+onMouseMove?: MouseEventHandler,
+onMouseLeave?: MouseEventHandler,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Currently, your design makes these functions take a DOM MouseEvent (and you pass it nativeEvent). I think it would be less surprising if we passed the React event instead. To access offsetX I believe we still need to use nativeEvent (at least according to Flow) so that shouldn't change your code otherwise.

@julienw julienw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm, thanks for the test!

@julienw julienw enabled auto-merge (squash) September 14, 2023 12:13
@julienw julienw merged commit 3e8d88f into firefox-devtools:main Sep 14, 2023
tenderlove added a commit to tenderlove/profiler that referenced this pull request Jan 16, 2024
* main: (37 commits)
  Show the hovered time in the ruler at the top of the timeline. (PR firefox-devtools#4748)
  Hardcode 'project' to 'firefox-profiler' in .taskcluster.yml (PR firefox-devtools#4759)
  Update all Yarn dependencies (2023-09-27) (PR firefox-devtools#4758)
  Update the uploading command in the developer documentation (PR firefox-devtools#4752)
  Make prettier ignore the taskcluster files
  Add taskcluster
  Update all Yarn dependencies (2023-09-20) (PR firefox-devtools#4756)
  Add a robots.txt file to disallow indexing our profile links (PR firefox-devtools#4753)
  Avoid showing the calltree panel in profiles without samples. (PR firefox-devtools#4744)
  Display the vertical line in the timeline when hovering the marker chart or stack chart (PR firefox-devtools#4742)
  Draw a single rectangle for 2 markers in bar charts only if both the start and end horizontal pixels match. (PR firefox-devtools#4734)
  Update all Yarn dependencies (2023-09-13) (firefox-devtools#4746)
  Update all Yarn dependencies (2023-09-06) (PR firefox-devtools#4741)
  Remove prefer-wait-for rule in our config because it's been removed from the plugin
  ⬆️ Update eslint-plugin-testing-library to version 6.0.1
  Use a cache for prettier (PR firefox-devtools#4731)
  Remove leftover eslint error
  Run prettier on the codebase
  Upgrade prettier to latest version
  Ignore the coverage directory when present
  ...
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.

Time-aligned panels should track mouse position in the timeline-axis

2 participants