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

Adds label_color as an option to line charts. #7

Merged
merged 2 commits into from
Mar 22, 2013

Conversation

tonyhb
Copy link
Contributor

@tonyhb tonyhb commented Mar 19, 2013

Hi Josh,

This commit adds a setting for the label colour in line charts, allowing users to override the default black label with a hex colour when creating a line chart. This is done by adding a "color" method to the LabelSet class which changes the @color property, and by adding a "label_color" @option to the "draw_x_label" method in the LineChart class.

Changing the "label_color" option for a line graph changes the color of all labels, like so:

abtest.chart = new Charts.LineChart("graph", {
    show_grid: true,
    label_color: '#f00', // Makes all labels red
    max_y_labels: 5,
    max_x_labels: 20,
    y_label_size: 12,
    x_label_size: 12,
});

If no label colour is provided the default colour '#333' is used.

This commit adds a setting for the label colour in line charts, allowing users to override the default black label with a hex colour when creating a line chart. This is done by overriding the LabelSet's "Draw" method for Y axis labels, and by adding an @option to the "draw_x_label" LineChart class.

If no label colour is provided the default colour '#333' is used.
This commit adds axis names to line charts, allowing you to show labels with
the names underneath the graph. You can name graph axis by doing the following:

	chart = new Charts.LineChart('graph', {
		y_axis_name:  'Conversion Rate',
		x_axis_name:  'Date',
		axis_name_color: '#aaa',
		axis_name_size:  10,
		x_padding: 60,
	});

There are options for the axis names, the axis font colour and the axis text
size to differentiate these from the labels for data values.

Note that right now you'll ahve to tweak X padding to work with your text size
for the Y axis.
@tonyhb
Copy link
Contributor Author

tonyhb commented Mar 21, 2013

Hey,

I wanted to make a separate branch and pull request for commit 0f3d496 though it has conflicts with the label colour commit (86c349c) so it's in this pull request, too.

The second commit allows (0f3d496) you to add axis names as part of the line graph options which adds a label to the graph like this:

Screen Shot 2013-03-20 at 10 58 01

I've tested this across IE (7–9), FireFox, Opera, Safari and Chrome and it all works OK with different font sizes (x_padding needs to be adjusted manually for space for the font).

@tonyhb
Copy link
Contributor Author

tonyhb commented Mar 21, 2013

Also, this fixes issue #5 :)

@jcarver989
Copy link
Owner

Hey Tony, thanks for the pull looks good. I'll test it out tonight and merge it in.

@tonyhb
Copy link
Contributor Author

tonyhb commented Mar 22, 2013

Awesome! Let me know if you need me to do anything and I'll try and help.

jcarver989 added a commit that referenced this pull request Mar 22, 2013
Adds label_color as an option to line charts.
@jcarver989 jcarver989 merged commit d4b4820 into jcarver989:master Mar 22, 2013
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

Successfully merging this pull request may close these issues.

2 participants