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

Provide monotone interpolation #820

Open
1 task done
chengluyu opened this issue Apr 13, 2020 · 0 comments
Open
1 task done

Provide monotone interpolation #820

chengluyu opened this issue Apr 13, 2020 · 0 comments

Comments

@chengluyu
Copy link

  • I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

Currently, users could interpolate the source data by setting shape to "smooth" when using lines and areas. But only one interpolation method is provided yet, which unfortunately doesn't ensure monotonicity.

image

In the image above, the 7 points in the middle has same y-value, but the projected line shows two peaks at both the beginning and the end. This may cause misleading in some circumstances. In other words, for each two neighboring data point (x_i, y_i) and (x_{i 1}, y_{i 1}), the interpolated curve should ensure that y_i <= y <= y_{i+1} is true for all point (x, y) that satisfying x_i <= x <= x_{i+1}.

Here's a reference implementation in D3.js.

By the way, I'm willing to help. Please let me know if I could do anything.

What does the proposed API look like?

Although we could offer the new interpolation as a new type of shape, it's better to add interpolation as a separate attribute of lines and areas.

chart.line().interpolation('linear').position('x*y'); // Default behavior
chart.line().interpolation('monotone').position('x*y');
chart.line().interpolation('catmull-rom').position('x*y'); // New interpolation methods
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

No branches or pull requests

1 participant