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

Sankey link stroke gradient reference being corrupted by transition function #84

Closed
malcolmsheppardsig opened this issue Dec 6, 2018 · 1 comment

Comments

@malcolmsheppardsig
Copy link

malcolmsheppardsig commented Dec 6, 2018

NOTE: Also posted as d3-Sankey issue #61.

I am setting the stroke of the Sankey links to a function that typically returns a color spec (i.e. #678 or rgb(255,64.0)). I recently added the capability for the stroke setting function to also return a gradient definition reference, such as "url(#grd_lb03)". I'm using the "Bostock Update Pattern" to manage the nodes and links. I am using the ".transition()" function when updating the links. However, I've discovered that is during the update cycle, when the stroke function is now returning a gradient definition reference, the transition function is inappropriately munching the URL so that I sometimes lose leading zeros in the URL string, such as "url(#grd_lb3)" in my earlier example. If I move the transition function call after stroke setting clause, the URL is not affected. This appears to be a bug in the transition function, trying to deal with the URL as if it is a color spec.

Snippet:

 // UPDATE old elements present in new data
this._Links.select("path")
    .attr("stroke", linkStrokeFunction)

    // This needs to be after the stroke setting due to an apprent bug in D3 that tries to transform a gradient defintiion URL reference during transition
    .transition().duration(this.STANDARD_TRANSITION_DURATION).delay(this.STANDARD_TRANSITION_DELAY)

    .attr("d", this._D3SankeyLinkHorizontal())
    .attr("stroke-width", (d: any) => Math.max(2, d.width))
    ;
@mbostock
Copy link
Member

mbostock commented Dec 6, 2018

Please use Stack Overflow tag d3.js to ask for help. Stack Overflow provides a better collaborative forum: thousands of D3-related questions have been asked there, and some answers may be relevant to you.

When asking for help, please include a link to demonstrate the issue, preferably as an Observable notebook. It is often impossible to debug from code snippets alone. Isolate the issue and reduce your code as much as possible before asking for help. The less code you post, the easier it is for someone to debug, and the more likely you are to get a helpful response.

If you have a question about D3’s behavior and want to discuss it with other users, also consider the d3-js Google Group or joining the d3-js Slack.

Thank you! 🤗

@mbostock mbostock closed this as completed Dec 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants