-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Optimize marker rendering and support custom markers #7653
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
Open
gatopeich
wants to merge
23
commits into
plotly:master
Choose a base branch
from
gatopeich:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,189
−663
Open
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
2d44177
Initial plan
Copilot 8310635
Add addCustomMarker API for registering custom SVG markers
Copilot 343dd6c
Add demo file for custom marker feature
Copilot 90c697a
Add comprehensive documentation for custom marker API
Copilot 547b0b7
Add implementation summary document
Copilot 86086e0
Simplify API: allow passing custom functions directly as marker.symbol
Copilot 099b0d6
Check if symbol is function before calling symbolNumber() in backoff …
Copilot 42ab66d
Simplify function check in backoff calculation
Copilot d8739bd
Merge pull request #1 from gatopeich/copilot/add-custom-svg-markers
gatopeich 398d1d4
Merge branch 'plotly:master' into master
gatopeich db38309
Add change draft log entry
gatopeich 0cc49cc
Pass customdata to custom marker functions (backward compatible) (#2)
Copilot c055d26
Fix test assertions for custom marker function call counts
gatopeich ce14c7e
Tighten test assertions: expect exactly 3 or 6 marker function calls
ap-viavi fd70889
Add consolidated demo: all_demos.html
ap-viavi 2c1110b
Fix CI: rename docs to lowercase, skip non-symbol exports in schema
gatopeich 71ca7a9
Merge branch 'plotly:master' into master
gatopeich e073716
Fix brittle test assertions in custom marker function tests (#6)
Claude cef92be
Merge branch 'plotly:master' into master
gatopeich 3026a1e
Optimize marker render pipeline via SVG `<symbol>`/`<use>` (#7)
Copilot 6bbdb63
Restore dist files deleted by PR #7 (#9)
Copilot c74c81d
Remove coerce.js function pass-through hack; fatal errors on unknown …
Copilot 5d2add8
Address PR #7653 review comments: restore symDef.n, rename/clean demo…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Pass customdata to custom marker functions (backward compatible) (#2)
* Initial plan * Add data point and trace context to custom marker functions Co-authored-by: gatopeich <7722268+gatopeich@users.noreply.github.com> * Improve comment clarity for custom marker function parameters Co-authored-by: gatopeich <7722268+gatopeich@users.noreply.github.com> * Add weather map demo and documentation for custom marker functions Co-authored-by: gatopeich <7722268+gatopeich@users.noreply.github.com> * Add backward compatibility test demo Co-authored-by: gatopeich <7722268+gatopeich@users.noreply.github.com> * Remove dist folder changes - these are build artifacts for maintainers Co-authored-by: gatopeich <7722268+gatopeich@users.noreply.github.com> * Fix coercion to allow function values for marker.symbol Allow functions to pass through enumerated coercion for custom marker symbols. Update weather map demo with proper meteorological wind barbs. * Auto-rotate custom marker functions via align() - Export align() from symbol_defs.js - Apply align() automatically to custom function results in makePointPath() - Simplify custom function signature to (r, d, trace) - Update weather demo with cleaner wind barbs and compact layout * Simplify custom marker function signature to (r, customdata) - Custom functions now receive (r, customdata) instead of (r, d, trace) - customdata is the value from trace.customdata[i] for each point - Rotation and standoff handled automatically via align() - Updated demos to use new signature * Improve weather demo with jet stream wind pattern * Add UTF-8 icons to weather demo legend * Rename pt back to d to match call sites * Remove unused trace parameter from makePointPath * Update docs and tests for (r, customdata) signature --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: gatopeich <7722268+gatopeich@users.noreply.github.com>
- Loading branch information
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <meta charset="utf-8"> | ||
| <title>Custom Markers - With and Without Customdata</title> | ||
| <script src="../../dist/plotly.js"></script> | ||
| <style> | ||
| body { font-family: Arial, sans-serif; margin: 20px; } | ||
| h2 { color: #333; } | ||
| .info { background: #e7f3ff; padding: 10px; border-left: 4px solid #3b82f6; margin: 10px 0; } | ||
| code { background: #f0f0f0; padding: 2px 6px; border-radius: 3px; } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <h2>Custom Markers - With and Without Customdata</h2> | ||
| <div class="info"> | ||
| <strong>Simple markers</strong> use <code>function(r)</code><br> | ||
| <strong>Data-aware markers</strong> use <code>function(r, customdata)</code> | ||
| </div> | ||
| <div id="plot" style="width: 700px; height: 400px;"></div> | ||
|
|
||
| <script> | ||
| // SIMPLE: just uses radius - diamond shape | ||
| function diamondMarker(r) { | ||
| return 'M' + r + ',0L0,' + r + 'L-' + r + ',0L0,-' + r + 'Z'; | ||
| } | ||
|
|
||
| // SIMPLE: star shape | ||
| function starMarker(r) { | ||
| var points = 5, path = 'M'; | ||
| for (var i = 0; i < points * 2; i++) { | ||
| var radius = i % 2 === 0 ? r : r * 0.4; | ||
| var ang = (i * Math.PI) / points - Math.PI / 2; | ||
| path += (i === 0 ? '' : 'L') + | ||
| (radius * Math.cos(ang)).toFixed(2) + ',' + | ||
| (radius * Math.sin(ang)).toFixed(2); | ||
| } | ||
| return path + 'Z'; | ||
| } | ||
|
|
||
| // DATA-AWARE: shape depends on customdata[i] | ||
| function dataAwareMarker(r, customdata) { | ||
| var type = customdata; | ||
| if (type === 'big') { | ||
| // Larger diamond | ||
| var r2 = r * 1.4; | ||
| return 'M' + r2 + ',0L0,' + r2 + 'L-' + r2 + ',0L0,-' + r2 + 'Z'; | ||
| } | ||
| if (type === 'star') { | ||
| // Star shape | ||
| var points = 5, path = 'M'; | ||
| for (var i = 0; i < points * 2; i++) { | ||
| var radius = i % 2 === 0 ? r : r * 0.4; | ||
| var ang = (i * Math.PI) / points - Math.PI / 2; | ||
| path += (i === 0 ? '' : 'L') + | ||
| (radius * Math.cos(ang)).toFixed(2) + ',' + | ||
| (radius * Math.sin(ang)).toFixed(2); | ||
| } | ||
| return path + 'Z'; | ||
| } | ||
| // Default: circle | ||
| return 'M' + r + ',0A' + r + ',' + r + ' 0 1,1 0,-' + r + | ||
| 'A' + r + ',' + r + ' 0 0,1 ' + r + ',0Z'; | ||
| } | ||
|
|
||
| Plotly.newPlot('plot', [{ | ||
| name: 'Simple: diamond(r)', | ||
| type: 'scatter', | ||
| x: [1, 2, 3, 4], | ||
| y: [1, 1, 1, 1], | ||
| mode: 'markers', | ||
| marker: { symbol: diamondMarker, size: 25, color: '#3b82f6' } | ||
| }, { | ||
| name: 'Simple: star(r)', | ||
| type: 'scatter', | ||
| x: [1, 2, 3, 4], | ||
| y: [2, 2, 2, 2], | ||
| mode: 'markers', | ||
| marker: { symbol: starMarker, size: 25, color: '#f59e0b' } | ||
| }, { | ||
| name: 'Data-aware: (r, customdata)', | ||
| type: 'scatter', | ||
| x: [1, 2, 3, 4], | ||
| y: [3, 3, 3, 3], | ||
| customdata: ['circle', 'big', 'star', 'circle'], | ||
| mode: 'markers', | ||
| marker: { symbol: dataAwareMarker, size: 25, color: '#10b981' } | ||
| }], { | ||
| title: 'Custom Marker Functions', | ||
| xaxis: { range: [0, 5] }, | ||
| yaxis: { range: [0, 4], tickvals: [1, 2, 3], ticktext: ['Diamond', 'Star', 'Data-driven'] }, | ||
| showlegend: true | ||
| }); | ||
| </script> | ||
| </body> | ||
| </html> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This file seems redundant