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
Implement legend.align: 'start'/'center'/'end' #6141
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c05a2a6
Fixes Issue #3175:
4081897
Addressing review comments:
01f2876
Addressing 2nd round of review feedback:
b750f79
Adding legend alignment image tests for bottom and right positioned l…
66c0632
Adjustment to legend fit algorithm to make vertical/horizontal more c…
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
25 changes: 25 additions & 0 deletions
25
test/fixtures/plugin.legend/legend-doughnut-bottom-center-mulitiline.json
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,25 @@ | ||
{ | ||
"config": { | ||
"type": "doughnut", | ||
"data": { | ||
"labels": ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""], | ||
"datasets": [{ | ||
"data": [10, 20, 30, 40, 50, 60, 70, 10, 20, 30, 40, 50, 60, 70, 10, 20, 30, 20, 10], | ||
"backgroundColor": "#00ff00", | ||
"borderWidth": 0 | ||
}] | ||
}, | ||
"options": { | ||
"legend": { | ||
"position": "bottom", | ||
"align": "center" | ||
} | ||
} | ||
}, | ||
"options": { | ||
"canvas": { | ||
"height": 256, | ||
"width": 512 | ||
} | ||
} | ||
} |
Binary file added
BIN
+12.3 KB
test/fixtures/plugin.legend/legend-doughnut-bottom-center-mulitiline.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions
25
test/fixtures/plugin.legend/legend-doughnut-bottom-center-single.json
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,25 @@ | ||
{ | ||
"config": { | ||
"type": "doughnut", | ||
"data": { | ||
"labels": [""], | ||
"datasets": [{ | ||
"data": [10], | ||
"backgroundColor": "#00ff00", | ||
"borderWidth": 0 | ||
}] | ||
}, | ||
"options": { | ||
"legend": { | ||
"position": "bottom", | ||
"align": "center" | ||
} | ||
} | ||
}, | ||
"options": { | ||
"canvas": { | ||
"height": 256, | ||
"width": 512 | ||
} | ||
} | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions
25
test/fixtures/plugin.legend/legend-doughnut-bottom-end-mulitiline.json
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,25 @@ | ||
{ | ||
"config": { | ||
"type": "doughnut", | ||
"data": { | ||
"labels": ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""], | ||
"datasets": [{ | ||
"data": [10, 20, 30, 40, 50, 60, 70, 10, 20, 30, 40, 50, 60, 70, 10], | ||
"backgroundColor": "#00ff00", | ||
"borderWidth": 0 | ||
}] | ||
}, | ||
"options": { | ||
"legend": { | ||
"position": "bottom", | ||
"align": "end" | ||
} | ||
} | ||
}, | ||
"options": { | ||
"canvas": { | ||
"height": 256, | ||
"width": 512 | ||
} | ||
} | ||
} |
Binary file added
BIN
+11.4 KB
test/fixtures/plugin.legend/legend-doughnut-bottom-end-mulitiline.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions
25
test/fixtures/plugin.legend/legend-doughnut-bottom-start-mulitiline.json
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,25 @@ | ||
{ | ||
"config": { | ||
"type": "doughnut", | ||
"data": { | ||
"labels": ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""], | ||
"datasets": [{ | ||
"data": [10, 20, 30, 40, 50, 60, 70, 10, 20, 30, 40, 50, 60, 70, 10], | ||
"backgroundColor": "#00ff00", | ||
"borderWidth": 0 | ||
}] | ||
}, | ||
"options": { | ||
"legend": { | ||
"position": "bottom", | ||
"align": "start" | ||
} | ||
} | ||
}, | ||
"options": { | ||
"canvas": { | ||
"height": 256, | ||
"width": 512 | ||
} | ||
} | ||
} |
Binary file added
BIN
+11.3 KB
test/fixtures/plugin.legend/legend-doughnut-bottom-start-mulitiline.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions
25
test/fixtures/plugin.legend/legend-doughnut-left-center-mulitiline.json
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,25 @@ | ||
{ | ||
"config": { | ||
"type": "doughnut", | ||
"data": { | ||
"labels": ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""], | ||
"datasets": [{ | ||
"data": [10, 20, 30, 40, 50, 60, 70, 10, 20, 30, 40, 50, 60, 70, 10, 20, 30], | ||
"backgroundColor": "#00ff00", | ||
"borderWidth": 0 | ||
}] | ||
}, | ||
"options": { | ||
"legend": { | ||
"position": "left", | ||
"align": "center" | ||
} | ||
} | ||
}, | ||
"options": { | ||
"canvas": { | ||
"height": 256, | ||
"width": 512 | ||
} | ||
} | ||
} |
Binary file added
BIN
+14.3 KB
test/fixtures/plugin.legend/legend-doughnut-left-center-mulitiline.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions
25
test/fixtures/plugin.legend/legend-doughnut-left-center-single.json
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,25 @@ | ||
{ | ||
"config": { | ||
"type": "doughnut", | ||
"data": { | ||
"labels": [""], | ||
"datasets": [{ | ||
"data": [10], | ||
"backgroundColor": "#00ff00", | ||
"borderWidth": 0 | ||
}] | ||
}, | ||
"options": { | ||
"legend": { | ||
"position": "left", | ||
"align": "center" | ||
} | ||
} | ||
}, | ||
"options": { | ||
"canvas": { | ||
"height": 256, | ||
"width": 512 | ||
} | ||
} | ||
} | ||
simonbrunel marked this conversation as resolved.
Show resolved
Hide resolved
|
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions
24
test/fixtures/plugin.legend/legend-doughnut-left-default-center.json
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,24 @@ | ||
{ | ||
"config": { | ||
"type": "doughnut", | ||
"data": { | ||
"labels": ["", "", "", "", "", ""], | ||
"datasets": [{ | ||
"data": [10, 20, 30, 40, 50], | ||
"backgroundColor": "#00ff00", | ||
"borderWidth": 0 | ||
}] | ||
}, | ||
"options": { | ||
"legend": { | ||
"position": "left" | ||
} | ||
} | ||
}, | ||
"options": { | ||
"canvas": { | ||
"height": 256, | ||
"width": 512 | ||
} | ||
} | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions
25
test/fixtures/plugin.legend/legend-doughnut-left-end-mulitiline.json
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,25 @@ | ||
{ | ||
"config": { | ||
"type": "doughnut", | ||
"data": { | ||
"labels": ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""], | ||
"datasets": [{ | ||
"data": [10, 20, 30, 40, 50, 60, 70, 10, 20, 30, 40, 50, 60, 70, 10, 20, 30], | ||
"backgroundColor": "#00ff00", | ||
"borderWidth": 0 | ||
}] | ||
}, | ||
"options": { | ||
"legend": { | ||
"position": "left", | ||
"align": "end" | ||
} | ||
} | ||
}, | ||
"options": { | ||
"canvas": { | ||
"height": 256, | ||
"width": 512 | ||
} | ||
} | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions
25
test/fixtures/plugin.legend/legend-doughnut-left-start-mulitiline.json
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,25 @@ | ||
{ | ||
"config": { | ||
"type": "doughnut", | ||
"data": { | ||
"labels": ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""], | ||
"datasets": [{ | ||
"data": [10, 20, 30, 40, 50, 60, 70, 10, 20, 30, 40, 50, 60, 70, 10, 20, 30], | ||
"backgroundColor": "#00ff00", | ||
"borderWidth": 0 | ||
}] | ||
}, | ||
"options": { | ||
"legend": { | ||
"position": "left", | ||
"align": "start" | ||
} | ||
} | ||
}, | ||
"options": { | ||
"canvas": { | ||
"height": 256, | ||
"width": 512 | ||
} | ||
} | ||
} |
Binary file added
BIN
+14.3 KB
test/fixtures/plugin.legend/legend-doughnut-left-start-mulitiline.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
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.
it's a bit funny to me that we have padding on both sides of the comparison. perhaps it should be
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 agree - the fit logic was not trivial to follow. My intention was to make as few changes as possible while making this check consistent between vertical/horizontal. Ideally this fit algo would be refactored in its entirety to be more consistent as a whole between the two. I didn't really feel that was within the scope of this PR, but I could probably find a happy medium.