-
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
Legend Symbol Parameter [New Feature] #4811
Conversation
legendSymbolLarge: Boolean | ||
|
||
// Width of legend symbol used if legendSymbolLarge is true | ||
boxWidth: Number |
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.
My only comment here is that I think it would be better to remove legendSymbolLarge
and imply it if boxWidth is set. So if boxWidth !== undefined
then it will be used, otherwise it will be set to fontSize
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.
if I'm not wrong, boxWidth is defaulted to 40 so it will be always defined. If we remove default value it may impact current users upgrading to that new version.
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.
ahh, I missed that. To make that clearer I would suggest a rename to useFontSize
or something. Let's wait to rename it until @simonbrunel gets a chance to review this
src/helpers/helpers.canvas.js
Outdated
@@ -44,112 +44,121 @@ var exports = module.exports = { | |||
} | |||
}, | |||
|
|||
drawPoint: function(ctx, style, radius, x, y) { | |||
var type, edgeLength, xOffset, yOffset, height, size; | |||
drawPoint: function(ctx, style, width, height, x, y, isLineWidthZero) { |
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.
what is isLineWidthZero
used for here?
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.
For polygon (circle, rect, ....) if line width is 0, then no border are displayed (no strike).
This is replication of the current behavior for the rect symbol. Not doing this may impact the current users upgrading to that new version even if they don't change anything to their code (regression).
The options logic path seems a bit unclear and I don't think the |
@simonbrunel , my specific need is to use a large line as legend symbol while keeping the dot as point style on the lines. I did few additional changes to be able to use other symbols that were already available as points. All the logic about usePointStyle is to avoid breaking that current functionality. Agree about the helper signature, it could break external plugin using it. I propose the rename the new method and keep the same logic in it. The code from the current method will be changed to call the new method from there and parameter values will be defaulted/updated so the outcome is the same. |
I think it's fine to add a new What about a new drawPoint: (...) {
helpers.canvas.symbol(ctx, style, w, h, x, y); // would be exports.symbol(...)
ctx.stroke();
ctx.fill();
} The legend would use only the Then I would maybe expose the following dataset/legend options: legend: { // nested options under the dataset
symbol: 'rect', // default to rect
boxWidth: ...
} if |
sounds like a plan. @etimberg, any other comments before I start working on it? |
@simonbrunel, ctx.fill() is not required for each symbol, so it should stay in the method logic. |
@touletan I have no other comments. 😄 |
@etimberg , @simonbrunel , @benmccann , new version completed and ready for review. |
…. Symbol type,, boxWidth, border Color and border Width can be defined at dataset level
@simonbrunel have you had a chance to review this since it was last changed? |
updates done |
should be good now |
@touletan this PR needs to be rebased before it can be merged |
@touletan just a reminder that this PR needs to be rebased |
Hi
could you please provide guidelines to do this correctly.
thank you.
…________________________________
De : Ben McCann <notifications@github.com>
Envoyé : 15 juillet 2018 23:23
À : chartjs/Chart.js
Cc : touletan; Mention
Objet : Re: [chartjs/Chart.js] Legend Symbol Parameter [New Feature] (#4811)
@touletan<https://github.com/touletan> just a reminder that this PR needs to be rebased
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#4811 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AE_7QfxoNbPpFU_pwLBG_C0_qXaPrjK3ks5uG87VgaJpZM4Ps-yk>.
|
I would recommend developing each feature on a new branch. You are on the master branch which I would recommend you not to use in the future This might not be exactly right, but hopefully will work or be pretty close:
|
After additional testing, I removed the code related to the point rotation, since it was causing issue with the legend symbol position. I need help to figure out how to re-introduce point rotation .... |
that version is good for review. |
@touletan I'm very sorry this PR will need to be rebased again. Would you be able to update it? |
Thanks @touletan! And sorry again for the delay on getting this in. We are trying to get through the backlog of open reviews. I'm afraid it's hard for us all to find enough spare time, but hopefully we will make it through them all eventually |
} | ||
var radius = width / 2; | ||
var yRadius = height / 2; | ||
var padLeft = isPoint ? radius - width / 2 / Math.sqrt(2) : 0; |
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.
can you add a comment explaining why padding is necessary and what isPoint
is doing? I'm not sure what that part is for
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 added comments on that. In the production version some symbols can only be called as point and they are not usign the full width since the size is based on the radius. When is used as a legend, I want to be sure that the symbol width = the width value pass as parameter. So to not impact the current behavior (when symbol is called for a point) I did that logic for the impacted symbols. I.e. Add padding when called as a point (not usign the full width) and use the full width (no padding) when called as a legend symbol.
@@ -44,8 +45,13 @@ defaults._set('global', { | |||
// lineDashOffset : | |||
// lineJoin : | |||
// lineWidth : | |||
// pointStyle: symbol use on legend when usePointStyle is set | |||
// legendSymbol : Symbol use on legend if not usePointStyle | |||
// boxWidth : width of legend symbol if not userPointStyle |
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.
userPointStyle
should be usePointStyle
.
I would also reword these to something like:
// pointStyle: symbol used on legend when 'usePointStyle' is true
// legendSymbol : symbol used on legend when usePointStyle is false
// boxWidth : width of legend symbol when usePointStyle is false
@touletan would you be able to rebase this PR? |
@touletan I just wanted to check in one last time to see if you still have an interest in moving forward with this PR. It's been needing to be rebased for quite awhile. We'll close it as inactive if we don't hear back soon though you're always welcome to reopen it in the future when you find time to work on it again |
I'll have a look.
…________________________________
De : Ben McCann <notifications@github.com>
Envoyé : 4 avril 2019 00:28
À : chartjs/Chart.js
Cc : Dominic Jean; Mention
Objet : Re: [chartjs/Chart.js] Legend Symbol Parameter [New Feature] (#4811)
@touletan<https://github.com/touletan> I just wanted to check in one last time to see if you still have an interest in moving forward with this PR. It's been needing to be rebased for quite awhile. We'll close it as inactive if we don't hear back soon though you're always welcome to reopen it in the future when you find time to work on it again
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#4811 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AE_7QTEeFOwaWyN0dC0-JIjcNoWhfPZXks5vdX9TgaJpZM4Ps-yk>.
|
@touletan I'm going to close this PR as inactive for the moment to help us keep track of which PRs need review, but please feel free to reopen if you get a chance to rebase and we'll be happy to take a look at it |
I'd be in need of this |
New Feature proposed to display symbol on legend
Legend Symbol Parameter [New Feature] #4804