Export to GitHub

flot - issue #159

Multi series bar charts


Posted on May 5, 2009 by Massive Lion

It appears that when there are an even number of series in the dataset, flot improperly calculates a starting offset and positions the bars improperly. See the attached pdf. Notice the 2,4, and 6 series are shifted to the right too far.

Attachments

Comment #1

Posted on May 5, 2009 by Massive Lion

BTW, this is in FF 3.08 on WinXP using r147 patch.

Comment #2

Posted on May 7, 2009 by Quick Wombat

Are you sure this is not a bug in your offset code? There's no multi-series bar offset in Flot that I know of. Flot only knows whether to center or left-justify the bars.

Comment #3

Posted on May 7, 2009 by Massive Lion

I'm using r147 without any mods. I'm only adding extra series to the dataset, and noticed that it was shifted to the right too far when there are an even number of series. I haven't dug into the code to figure out why r147 is calculating the offset improperly.

Comment #4

Posted on May 25, 2009 by Quick Wombat

Sorry for the sluggish reply.

Could you provide a minimal code example? I'm not quite sure I understand what exactly is happening here.

Comment #5

Posted on Jul 4, 2009 by Quick Wombat

(No comment was entered for this change.)

Comment #6

Posted on Jul 21, 2009 by Happy Ox

Adding multi bar support.

This is the first patch/plugin I've worked on so I am after some feedback here. I have made 1 change throughout jquery.flot.js which I would like feedback on. I fully expect that I have overlooked something. I have not, for instance, run horizontal graphs or dynamically altered data.

The patch for that change is below applied to r194 from svn.

As far as the plugin goes, I'm not entirely happy but I think I have made reasonable use of the available hooks. Is there a better way to achieve the same result?

Hover works if the patch submitted by Zollman in issue 190 is applied (can we get this in svn when you have time).

It's obvious from the code but multi.html is setup as if it were in the examples directory and all scripts are in the parent directory.

Any feedback greatly appreciated, I still need to do more work on stacked bars and pie charts if I'm to get a green light!

Attachments

Comment #7

Posted on Oct 6, 2009 by Massive Lion

Sorry for the long delay. Here is the HTML test file I was using, and the patched flot js file. View the HTML, then remove a series from the "metrics" and refresh browser.
Remove another series and refresh. With each subsequent refresh, the bars will be centered and then left aligned.

Attachments

Comment #8

Posted on Oct 7, 2009 by Helpful Camel

Nice work. Seems to align nicely for the 400x300 dimensions in your example. But when I enlarged the graph to 800x600, the ticks seem to go out of alignment. Looks like you are getting close to making it work, though.

Comment #9

Posted on Oct 7, 2009 by Quick Wombat

Younda: I looked at your HTML, and it doesn't look like Flot code at all. You say you're using a patched Flot JS file? You need to take the problem to who wrote that patch. Or try the forum/mailing list.

I'm going to let Petter Trotter's patch highjack this issue.

Comment #10

Posted on Oct 8, 2009 by Happy Ox

Added a comment and created new patch for latest revision (205). Will update again when I get a chance to put some more test cases together.

jquery.flot.multi.js and multi.html remain unchanged.

Attachments

Comment #11

Posted on Oct 8, 2009 by Massive Lion

Thanks Peter, this patch and works perfectly.

Attachments

Comment #12

Posted on Nov 4, 2009 by Happy Ox

Hi All, sorry for the delay updating for the latest release.

jquery.flot.multi.js remains unchanged and I've attached the latest patch for jquery.flot.js

Attachments

Comment #13

Posted on Aug 17, 2010 by Massive Dog

Hi, I've come to this thread late. Is it now possible to render multiple series neatly in a single bar chart? As far as I understand it, the only options for aligning multiple series in a bar chart are 'left' and 'center', which results in an overlap (attached in test.html). Any pointers for how to render stuff so the bars appear alongside one another? Thanks v. much!

Attachments

Comment #14

Posted on Sep 15, 2010 by Happy Hippo

Peter, patch/plugin seems to work very well... good job. In the latest trunk revisions one of the hunks gets rejected, but no big deal at all to get it working.

I've setup a live demo of it in case anyone ever wants to try it and mess around to make sure it works in more situations.

http://jsfiddle.net/ryleyb/B3uGP/2/

Ole, this one seems like a no-brainer for inclusion in trunk!

Comment #15

Posted on Sep 16, 2010 by Massive Giraffe

Hi, I would like to know whether Flot multiple bar charts support month value?

As you can see fromt the attached graph attachment, the x-axis month is repeating instead of printing unique months and 3 bars per month. I am looking for the one similar to the above attached graph multibarWithLine.gif

I appreciate your help.

Regards, Ravivit9

CODE :

$(function () { var d1=[[1277942400000,4],[1280620800000,19],[1283299200000,2]]; var d2=[[1277942400000,7],[1280620800000,34],[1283299200000,7]]; var d3=[[1277942400000,7],[1280620800000,34],[1283299200000,7]]; xax={mode: "time", tickLength: 5, timeformat: "%b"}; $.plot($("#placeholder"), [ { data: d1, color: '#409628', label:'d1', bars: { show: true, align:'center', barWidth:0.3 } }, { data: d2, color: '#C0504D', label:'d2', bars: { show: true, align:'center', barWidth:0.3 } }, { data: d3, label:'d3', bars: { show: true, align:'center', barWidth:0.3 } } ], { selection: { mode: "xy" }, grid: { hoverable: true, clickable: true }, xaxis: xax, yaxis:{ min:0}, multiplebars: true }); });

Thanks, Ravivit9.

Attachments

Comment #16

Posted on Sep 16, 2010 by Massive Giraffe

hi, how do I include the patch file jquery.flot.js.r226.patch in my script?

Comment #17

Posted on Sep 16, 2010 by Happy Hippo

@Ravivit9 - you use the "patch" program... usually in the form "patch jquery.flot.js jquery.flot.js.r226.patch" but that assumes you're using some brand of Unix. If you're using Windows, I'm not sure what most people do... Google for "patch windows" and install and use whatever that comes up with?

Comment #18

Posted on Sep 17, 2010 by Massive Giraffe

hi ryleyb, thanks for your update, I am relatively new to javascript, could you please put in the actual script line for me, so that I can include it in my script.

I appreciate your reply.

Comment #19

Posted on Oct 26, 2010 by Helpful Horse

Why is this patch not integrated into a distribution yet? It's been up for a year.

Comment #20

Posted on Oct 26, 2010 by Happy Hippo

@charlie - the bright side is that you can use the plugin as is, regardless of whether its in the distribution or not.

Comment #21

Posted on Dec 6, 2010 by Grumpy Ox

I wasn't able to patch automatically:

patch jquery.flot.js jquery.flot.js.r226.patch patching file jquery.flot.js Assertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 354

This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.

However I did manage to change the js file manually.

Thank you Peter!

Comment #22

Posted on Jan 4, 2011 by Quick Bear

Your patch is wonderful! However.....was wondering if anyone has been able to have multi series bar AND stacked bars at the same time. I just tried to do it and it looks like multi is using the same functionality as stacked but shifting and moving down the additional bars which would have been used by stacked.

It is wonderful though that your patch doesn't break the stacked functionality. Great job!

Kc

Comment #23

Posted on Jan 7, 2011 by Helpful Bird

I'm also getting errors trying to patch the jquery.flot.js file. Does anybody has the correct .js file for me?

Comment #24

Posted on Apr 30, 2011 by Swift Rabbit

Here is the patch updated for Flot 0.7.

Attachments

Comment #25

Posted on Jul 1, 2011 by Happy Camel

Comment deleted

Comment #26

Posted on Aug 10, 2011 by Happy Horse

The patch given by fras still not works, this is the fixed one

Attachments

Comment #27

Posted on Aug 15, 2011 by Swift Giraffe

I took the patch given above by wbshang, and have added the ability to enable or disable the multibar feature:

To enable multiple bars, simply add:

series: { multipleBars: true }

...to your options.

Attachments

Comment #28

Posted on Oct 5, 2011 by Massive Hippo

Thanks thaman. When I use your patch, stacked bargraphs don't break, but bargraphs with lineplots are broken (line is plotted after the bars instead of centered).

I found out you will need to edit the jquery.flot.multi.js file to get that fixed:

options.multiplebars -> options.series.multipleBars (line 35 and 36)

Comment #29

Posted on Oct 11, 2011 by Swift Giraffe

This style works for me with my patch:

var options = { series: { multipleBars: true, bars: { barWidth: * 0.8 / , align: 'center' }, }, ...

var plotdata = [ {label: 'bar1', data: graphdata1, color: 'blue', yaxis: 1, bars: { show: true } }, {label: 'bar2', data: graphdata2, color: 'red', yaxis: 1, bars: { show: true } }, {label: 'line1', data: graphdata3, color: 'purple', yaxis: 2, lines: { show: true }, }, ];

Let me know if you have problems.

Comment #30

Posted on Mar 10, 2012 by Happy Bird

Hi, This does not seem working if xaxis is in time mode.

$(function () { var d1=[[1277942400000,4],[1280620800000,19],[1283299200000,2]]; var d2=[[1277942400000,7],[1280620800000,34],[1283299200000,7]]; var d3=[[1277942400000,7],[1280620800000,34],[1283299200000,7]]; xax={mode: "time", tickLength: 5, timeformat: "%b"}; $.plot($("#placeholder"), [ { data: d1, color: '#409628', label:'d1', bars: { show: true, align:'center', barWidth:0.3 } }, { data: d2, color: '#C0504D', label:'d2', bars: { show: true, align:'center', barWidth:0.3 } }, { data: d3, label:'d3', bars: { show: true, align:'center', barWidth:0.3 } } ], { selection: { mode: "xy" }, grid: { hoverable: true, clickable: true }, xaxis: xax, yaxis:{ min:0}, multiplebars: true }); });

Comment #31

Posted on May 8, 2012 by Happy Wombat

(No comment was entered for this change.)

Comment #32

Posted on Feb 5, 2013 by Helpful Wombat

Can we add jquery.flow.multiple to the github repository?

Comment #33

Posted on Nov 21, 2014 by Massive Giraffe

Comment deleted

Comment #34

Posted on Nov 21, 2014 by Massive Giraffe

some one can send me a complete file?

I can't patch with 0.9 version!

email weeylink#gmail.com

Status: Accepted

Labels:
Type-Enhancement Priority-Medium