Open
Description
Feature Proposal
Description:
I'm requesting that Chart.js expose its cubic interpolation algorithm (specifically the 'monotone' mode) as a utility function that developers can use outside of the main chart drawing functionality.
Use Case:
I'm currently developing an application where I need to:
- Display a main curve using Chart.js's excellent cubic interpolation
- Show a moving point (date of interest indicator) that should follow the exact same curve
- Currently, I can only approximate this with linear interpolation between points
- Having access to the same interpolation algorithm would ensure consistent visualization
Current Workarounds:
Currently, developers needing this functionality must either:
- Implement their own cubic interpolation (potentially inconsistent with Chart.js)
- Use linear interpolation (less visually appealing)
- Create complex workarounds to try to access the internal calculations
Proposed Solution:
Add a utility function to Chart.js that:
- Takes an array of points (x,y coordinates)
- Takes a specific x value to interpolate
- Returns the interpolated y value using the same algorithm as cubicInterpolationMode: 'monotone'
Example API could look like:
const interpolatedY = Chart.helpers.interpolateCubicMonotone(points, xValue);
### Possible Implementation
Proposed Solution:
Add a utility function to Chart.js that:
- Takes an array of points (x,y coordinates)
- Takes a specific x value to interpolate
- Returns the interpolated y value using the same algorithm as cubicInterpolationMode: 'monotone'
Example API could look like:
```javascript
const interpolatedY = Chart.helpers.interpolateCubicMonotone(points, xValue);