Change tick label colors

1,931 views
Skip to first unread message

Michael

unread,
Jun 11, 2010, 4:36:39 AM6/11/10
to Flot graphs
Hi,

is there a way to change the colors of the tick labels? I have two y
axes and want to color the labels on the axes according to the data.

Bye,
Michael

Michael

unread,
Jun 11, 2010, 5:46:06 PM6/11/10
to Flot graphs
Hi again,

I ended up patching flot, because I realized that it's not possible
in the current version after looking at the source. It was simple
enough: In insertLabels() I changed the class of the axes' labels from
"tickLabel" to "tickLabelY1" and "tickLabelY2".
Bye,
Michael

Annie Lausier

unread,
Jun 12, 2010, 1:20:48 PM6/12/10
to flot-...@googlegroups.com
I was just going to reply with how you can do it with slicing/CSS outside of flot, but your way sounds much better:

You should be able to use css to change the style of the tick labels. They all have the class "tickLabel", so you can use jQuery to select the ones you'd like to change. I did this recently, and used Firebug to figure out what order the tickLabels were in (x-axis and y-axis ticks all have the same class). I used jQuery to grab those (6 in my case) ticks and change their color:

var ticks = $(".tickLabel").slice(0,6); //get first six tickLabels ticks.each(function(i) { $(this).css("color", "#ff0000"); });

-Annie

Matt S

unread,
Jun 12, 2010, 6:07:06 PM6/12/10
to Flot graphs
I've been working on a bunch of css control of tick labels too - would
be a great addition to Flot to be able to specify a classname for each
axis' tickLabels as Michael alludes above... seems pretty straight
forward.
Reply all
Reply to author
Forward
0 new messages