Skip to content

Conversation

@gatopeich
Copy link

This pull request introduces support for custom markers via functions in Plotly.js scatter plots, allowing users to pass a function directly as the marker.symbol property to define custom SVG marker shapes. The implementation includes updates to the drawing logic, comprehensive documentation, a demo HTML file, and new tests to ensure correct behavior. This feature provides a flexible and user-friendly way to extend marker capabilities beyond the built-in set.

Custom Marker Function Support:

  • Added support for passing custom functions as marker.symbol in scatter plots, enabling users to define custom SVG path markers directly without registration. The drawing logic is updated to handle both functions and traditional symbol identifiers throughout the rendering pipeline. [1] [2] [3] [4]

Documentation and Examples:

  • Introduced a new CUSTOM_MARKER_FUNCTIONS.md file with detailed documentation, usage examples, function signatures, SVG path command explanations, and best practices for custom marker functions.
  • Added a demo HTML file (devtools/custom_marker_demo.html) showcasing how to use custom marker functions in practice, with live examples and code snippets.

Testing:

  • Added new Jasmine tests to verify that custom marker functions work as expected, including support for arrays of functions and mixing custom functions with built-in symbols.

@camdecoster
Copy link
Contributor

Hello @gatopeich! Before we review this PR, could you please help us understand what use case prompted this change? Ideally, you'd create an issue describing the problem and explaining why it should be fixed.

@gatopeich
Copy link
Author

I've used this professionally over the last few years to plot meaningful icons on top of maps, e.g. pedestrians, cars, directional wind arrows based on data...
Copilot was able to recreate the concept but did not produce a meaningful demo.

@gatopeich gatopeich marked this pull request as draft December 2, 2025 18:38
@gatopeich
Copy link
Author

Let me add some nice example.
I also realize that the function could take more inputs that the size... I solved that with scoped lambdas in the past but now we can make it ellegant.

@camdecoster
Copy link
Contributor

Sounds good. While you're at it, could you double check the test you added? It's failing in CI.

@camdecoster camdecoster assigned gatopeich and unassigned camdecoster Jan 6, 2026
* Initial plan

* Add data point and trace context to custom marker functions

Co-authored-by: gatopeich <[email protected]>

* Improve comment clarity for custom marker function parameters

Co-authored-by: gatopeich <[email protected]>

* Add weather map demo and documentation for custom marker functions

Co-authored-by: gatopeich <[email protected]>

* Add backward compatibility test demo

Co-authored-by: gatopeich <[email protected]>

* Remove dist folder changes - these are build artifacts for maintainers

Co-authored-by: gatopeich <[email protected]>

* 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] <[email protected]>
Co-authored-by: gatopeich <[email protected]>
@gatopeich gatopeich marked this pull request as ready for review January 18, 2026 01:58
@gatopeich
Copy link
Author

I polished the implementation and added access to customdata.
See what you can do with my custom markers now:
image
live demo here: https://gatopeich.github.io/plotly.js/demos/weather_map_demo.html

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.

2 participants