-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Support monotone cubic interpolation for vertical line charts #9084
Conversation
This PR also answers the first question of this comment. |
const me = this; | ||
const options = me.options; | ||
if ((options.tension || options.cubicInterpolationMode === 'monotone') && !options.stepped && !me._pointsUpdated) { | ||
const loop = options.spanGaps ? me._loop : me._fullLoop; | ||
_updateBezierControlPoints(me._points, options, chartArea, loop); | ||
_updateBezierControlPoints(me._points, options, chartArea, loop, indexAxis); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about it, but it could be better to include the indexAxis in options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's possible to include it in options, and it's more flexible than adding an argument to functions. My concern is that indexAxis
is rarely set per element, so exposing this option to users may increase complexity of the configuration. @etimberg Any thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinkin about the lineElement, which is per dataset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, it is the lineElement. But even in that case, it is not usual for each line to have a different index axis (x or y).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, did not read your concern properly. It already is possible to configure the indexAxis
per dataset:
https://codepen.io/kurkle/pen/vYxEpLG
But I agree it would not be common.
It might have been a mistake to move the control point update procedure to the line element, in the MVC point of view, which I rarely think of. But since its there and now needs to know the index axis to work properly, I think the indexAxis can be considered to be a line option.
I don't see a big difference on how the option is passed to the line, but it would remove the need for that argument from the updateControlPoints
call. It would also make it available to external code maybe in a bit more straight forward way. (When interacting a line, you'd get it from line.options)
If an plugin calls the updateControlPoints (like the filler does), it would be possible to provide a contradicting value compared to the line controller. Containing the value in the options would prevent those kinds of mistakes.
All that said, I think its really not a big issue either way, so lets hear what @etimberg thinks about it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have strong opinions on which way. 😄 I slightly prefer the options just for the external interaction case but I won't hold up the PR over it.
This PR adds support for monotone cubic interpolation for vertical line charts.
Version 3.2.1: https://jsfiddle.net/nagix/L32jmkuf/
This PR: https://jsfiddle.net/nagix/k4frLjq2/
Fixes #9083.