Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixes to Data Labels in/over bars and bar outline color changes #421

Open
dnschnur opened this Issue · 1 comment

1 participant

@dnschnur
Owner

Original author: ddayd...@gmail.com (May 03, 2010 01:34:50)

This isn't a request as much as it is to give the code that resolves these
issues. I've been testing it for a few days now and I can't seem to break
it so it's pretty solid. I'm attaching a modified "jquery.flot.js" file
that has the changes built in, but I only made modifications to the "bars"
options and to the "drawSeriesBars" function. I'm trying to figure out how
to put this into a plug-in but it's entwined with the drawing of the boxes
right now so I haven't quite figured it out.

The added options are:

bars: {
lineColor: null, // set if bar border color is different from the
series color
dataLabels: false, // set true if you want data labels to show
labelColor: "#000000", // default is black
labelBold: false, // set to make the label bold
labelLoc: "center" // top or center - If using "top" you should also
set the yaxis autoscaleMargin to allow room for the label

lineColor will change the bars border color. If null it will continue to
work as it does now using the series color.

The rest are data label options and are pretty self sufficient. As the
comment says on the location if you put the label at the top you probably
want to modify the yaxis autoscaleMargin. I've found that changing it to
0.05 seems to always work. All of my work is surrounded by comments that
start with "DRD" so they are easy to find. The labels work pretty much the
same as the tick labels so there isn't much magic in there.

I wasn't sure how to submit code (I'm new to Flot) but there it is.

Original issue: http://code.google.com/p/flot/issues/detail?id=342

@dnschnur
Owner

From ddayd...@gmail.com on May 04, 2010 02:52:49
I made one mistake in the file above. I was converting the data labels to absolute
value which was hiding a mistake we made in the data load. I'm attaching a new one
that fixes that. I also was playing with a drop shadow on the stacked bars so that's
in there if you want to turn it on and play with it. Doesn't work for anything but
horizontal bars and overlapping bars look like crap so stacked or single bars are
best. I'm going to play with the plugin stuff some and see if I can't tighten these up.

This is very much work in progress, just thought I would share.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.