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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes
28 changes: 28 additions & 0 deletions
28
test/fixtures/element.line/cubicInterpolationMode/monotone-vertical.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module.exports = { | ||
config: { | ||
type: 'line', | ||
data: { | ||
datasets: [ | ||
{ | ||
data: [{x: 10, y: 1}, {x: 0, y: 5}, {x: -10, y: 15}, {x: -5, y: 19}], | ||
borderColor: 'red', | ||
fill: false, | ||
cubicInterpolationMode: 'monotone' | ||
} | ||
] | ||
}, | ||
options: { | ||
indexAxis: 'y', | ||
scales: { | ||
x: {display: false, min: -15, max: 15}, | ||
y: {type: 'linear', display: false, min: 0, max: 20} | ||
} | ||
} | ||
}, | ||
options: { | ||
canvas: { | ||
height: 256, | ||
width: 512 | ||
} | ||
} | ||
}; |
Binary file added
BIN
+8.38 KB
test/fixtures/element.line/cubicInterpolationMode/monotone-vertical.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.