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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label Color #4

Open
Aresinho opened this issue Dec 19, 2010 · 2 comments
Open

Label Color #4

Aresinho opened this issue Dec 19, 2010 · 2 comments

Comments

@Aresinho
Copy link

I know if probably not too complex, but how do you go to change the color of the label? I assume it is under the $.plot() function on the secondPass but I am not familiar with canvas so I don't know how to do it. Do you mind explaining a bit?

Thanks.

@ghost
Copy link

ghost commented Aug 5, 2013

I know this issue was posted 3 years ago but hopefully this will help anyone else who runs into the same issue.

Here is a gist of the entire modified script

The fix I used for this is relatively simple as reusable. First, in the firstPass set your default value if the option is not set.

Inside of:

if (opts.axisLabelUseCanvas) {
...
} else {

Add this:

if (!opts.axisLabelColor)
 opts.axisLabelFontColor = 'black';

Then, in the secondPass where your canvas ctx methods are being called BEFORE this line...

ctx.fillText(opts.axisLabel, 0, 0);

Set the canvas fillStyle method to our new object property variable:

ctx.fillStyle = opts.axisLabelFontColor;

Then in your chart options you can use this new property for your axes:

var options = {
  xaxis: {
    axisLabelFontColor: "blue"
  },
  yaxis: {
    axisLabelFontColor: "red"
  }
};

Hope this helps

@dibakarjana
Copy link

Thanks this works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants