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

Accept custom interpolation functions #1387

Merged

Conversation

sanniassin
Copy link
Contributor

This PR extends interpolation property in VictoryLine and VictoryArea by allowing to pass functions instead of interpolation names. This gives more control over curves from d3-shape (such as specifying tension for cardinal curves) and also allows to use custom curves.

I think it fixes #561, though the proposed solution was different.

@boygirl
Copy link
Contributor

boygirl commented Aug 29, 2019

@sanniassin Thanks for this improvement! These changes all look correct to me, but would you mind running nps format and commiting the changes?

@boygirl
Copy link
Contributor

boygirl commented Aug 29, 2019

Thanks! I'll release a patch for you :)

@joket1999
Copy link

How can I use it ?
Like this?

<VictoryArea interpolation={d3.line().curve(d3.curveCardinal.tension(0.5))} />

Error:
ERROR TypeError: null is not an object (evaluating 'output.areaStart')

@Vemassa
Copy link

Vemassa commented Sep 12, 2023

How can I use it ? Like this?

<VictoryArea interpolation={d3.line().curve(d3.curveCardinal.tension(0.5))} />

Error: ERROR TypeError: null is not an object (evaluating 'output.areaStart')

If you check the linked commit, you can see that the newly accepted interpolationFunction is actually passed as

.line()
.defined(defined)
.curve(interpolationFunction || d3Shape[${interpolationName}Closed])
...

Typically, instead of passing:
<VictoryArea interpolation={d3.line().curve(d3.curveCardinal.tension(0.5))} />
you should only do:
<VictoryArea interpolation={d3.curveCardinal.tension(0.5)} />

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.

Expose d3Curve Interpolation Options
4 participants