faheem801 / flot

Automatically exported from code.google.com/p/flot
MIT License
0 stars 0 forks source link

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

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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 reported on code.google.com by ddayd...@gmail.com on 3 May 2010 at 1:34

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
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.

Original comment by ddayd...@gmail.com on 4 May 2010 at 2:52

Attachments:

GoogleCodeExporter commented 9 years ago
Issue 341 has been merged into this issue.

Original comment by olau%iol...@gtempaccount.com on 13 Dec 2010 at 4:10

GoogleCodeExporter commented 9 years ago

Original comment by olau%iol...@gtempaccount.com on 13 Dec 2010 at 4:10

GoogleCodeExporter commented 9 years ago

Original comment by dnsch...@gmail.com on 9 May 2012 at 2:00