Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix colour settings of BeforeLabel and BeforeBody #4783

Merged
merged 3 commits into from Oct 2, 2017

Conversation

Rittyan
Copy link
Contributor

@Rittyan Rittyan commented Sep 21, 2017

Hello.
I have found font colour problem when rendering beforeLabel and beforeBody.

Problem

The beforeLabel and beforeBody don't use own colour settings(bodyFontColur,labelTextColor). They use titleFontColor.

jsfiddle:
https://jsfiddle.net/Rittyan/rxhpdyqt/

How fix

It seems missing colour setting before rendering.
I add it.


Sorry I'm not native speaker. so my english broken.
Thanks. 馃檹

@@ -701,10 +705,8 @@ module.exports = function(Chart) {
// Inner square
ctx.fillStyle = mergeOpacity(vm.labelColors[i].backgroundColor, opacity);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you wouldn't need this line since you end up overriding it later

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for reviewing.
I revert it and fixed up. 馃崳

@Rittyan Rittyan force-pushed the fix_beforeBody_beforeLabel_colour branch from 5edf9b1 to b159325 Compare September 22, 2017 02:42
helpers.each(vm.beforeBody, fillLineOfText);

var drawColorBoxes = vm.displayColors;
xLinePadding = drawColorBoxes ? (bodyFontSize + 2) : 0;

// Draw body lines now
helpers.each(body, function(bodyItem, i) {
var labelTextColor = mergeOpacity(vm.labelTextColors[i], opacity);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no need to have an intermediate variable here. the code below would work and result in a smaller file size

ctx.fillStyle = mergeOpacity(vm.labelTextColors[i], opacity);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, sorry. I fixed it.

Copy link
Member

@simonbrunel simonbrunel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@etimberg it duplicates your #4766 but I think this one also takes in account my comment on your PR. What do you think?

helpers.each(vm.beforeBody, fillLineOfText);

var drawColorBoxes = vm.displayColors;
xLinePadding = drawColorBoxes ? (bodyFontSize + 2) : 0;

// Draw body lines now
helpers.each(body, function(bodyItem, i) {
ctx.fillStyle = mergeOpacity(vm.labelTextColors[i], opacity);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be:

var textColor = mergeOpacity(vm.labelTextColors[i], opacity);
ctx.fillStyle = textColor;

then we can remove line 706 and avoid calling this mergeOpacity more than one time per body item, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rittyan what do you think about the suggested change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simonbrunel
I think it is very good.
May I commit that change?(Include removing line 706)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rittyan yup, you can push that change to this branch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it. thanks for reviewing 馃檹

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Rittyan

Copy link
Member

@etimberg etimberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simonbrunel I agree with your comment here. I'm happy to merge this once that comment is addressed over my change

@simonbrunel simonbrunel added this to the Version 2.7.1 milestone Oct 2, 2017
@etimberg etimberg merged commit 0bd0654 into chartjs:master Oct 2, 2017
yofreke pushed a commit to yofreke/Chart.js that referenced this pull request Dec 30, 2017
* fix colour settings of BeforeLabel and BeforeBody

* delete redundant variable declaration

* collect label colour setting.
exwm pushed a commit to exwm/Chart.js that referenced this pull request Apr 30, 2021
* fix colour settings of BeforeLabel and BeforeBody

* delete redundant variable declaration

* collect label colour setting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants