2-D 3 layered bar graph

tokyods

New Member
Joined
Apr 14, 2009
Messages
2
I need to create a 2-dimensional bar graph with three layers:

x-axis: months

Rear layer: target (this will be the widest bar: overlap 100, gap 50, currently on primary axis)

Middle layer: forecast (medium width: overlap 100, gap 220, currently first in order on secondary axis)

Front layer: actuals (narrowest: overlap 100, also secondary axis, gap currently 220, but would like this to be the thinnest bar)

I want to stack these one on top of the other with different widths so all are visible, but I when I adjust gap width, the middle and front layers change simultaneously (because they are on the same axis). That is, I can't set separate gaps to make sure they are both visible if they happen to have the same values.

Thanks for your help in advance.
 
Paste this data into a blank worksheet:

Excel Workbook
ABCDEFGH
1Back BarMiddle BarFront BarGaps
2new group1#N/A#N/A#N/AInter-series1
3pre-pad2#N/A#N/A#N/AInter-months1
4Back266#N/A#N/ALittle width3
5post-pad266#N/A#N/A
6pre-pad366#N/A#N/A
7middle36643#N/A
8post-pad36643#N/A
9pre-pad46643#N/A
10Front466438
11post-pad466438
12Back width766438
13pre-pad866438
14Front866438
15post-pad86643#N/A
16pre-pad96643#N/A
17middle96643#N/A
18post-pad966#N/A#N/A
19pre-pad1066#N/A#N/A
20Back1066#N/A#N/A
21post-pad10#N/A#N/A#N/A
22new group11#N/A#N/A#N/A
23pre-pad12#N/A#N/A#N/A
24Back1225#N/A#N/A
25post-pad1225#N/A#N/A
26pre-pad1325#N/A#N/A
27middle132533#N/A
28post-pad132533#N/A
29pre-pad142533#N/A
30Front14253386
31post-pad14253386
32Back width17253386
33pre-pad18253386
34Front18253386
35post-pad182533#N/A
36pre-pad192533#N/A
37middle192533#N/A
38post-pad1925#N/A#N/A
39pre-pad2025#N/A#N/A
40Back2025#N/A#N/A
41post-pad20#N/A#N/A#N/A
42new group21#N/A#N/A#N/A
43pre-pad22#N/A#N/A#N/A
44Back2210#N/A#N/A
45post-pad2210#N/A#N/A
46pre-pad2310#N/A#N/A
47middle23105#N/A
48post-pad23105#N/A
49pre-pad24105#N/A
50Front2410516
51post-pad2410516
52Back width2710516
53pre-pad2810516
54Front2810516
55post-pad28105#N/A
56pre-pad29105#N/A
57middle29105#N/A
58post-pad2910#N/A#N/A
59pre-pad3010#N/A#N/A
60Back3010#N/A#N/A
61post-pad30#N/A#N/A#N/A
62new group31#N/A#N/A#N/A
Sheet3


The data in RED are the heights of your bars. The rest of the formulas re-adjust. Select the whole table from B:E and make a non-stacked Area graph. You should see 9 flat-topped pyramids. Now right-click the chart, go to "Chart Options" -> "Axes" -> Category X-Axis = Time-scale

Now click [OK] and you should have 3 bars with the 'back bar' visible behind the 'middle bar' visible behind the 'front bar'.

Adding to H2 makes the difference in column widths bigger (if you set it at 1, the front bar is 1 unit smaller than the middle bar which is 1 unit smaller than the back bar).

Adding to H3 makes the gap between series bigger (if you set it at 100, the gaps between the first set of bars and the second will be 100 units apart).

Adding to H4 makes the smallest column wider (if you set it to 1, it is only 1 unit wide).

That should explain the methodology for creating it. To add more series you can just copy rows down. To add more series you'll have to diddle with the formulas and labels in columns A/B. In general, it goes:

new group
pad -> series label -> pad
middle
pad -> series label -> pad
new group
...

You can add multiple series and the like if you'd like.

There are many other ways of doing this if you use VBA. But this will do what you want without it, if you can figure out the logic and don't mind diddling around 'til you get something you like.
 
Upvote 0
Whoah! Thanks so much, Sal. It'll take me a little bit to understand the logic, but I was able to make the graph work.
 
Upvote 0
Okay, here's the long and the short of it. When you switch to a Time-scale axis, you get to give exact X,Y coordinates which will be plotted in the order you give them.

So basically, you want to draw an outline of the shape you'd like.

In this case, you want bar graphs, so you're just drawing rectangles on an X-Y chalkboard. So you want to go right across the axis until you get to where to start the first series, go up at that point until you get to the right height, go right until you get to the proper width, and head down until you get back to the axis.

Simple example:

Excel Workbook
AB
17Box
1800
1910
2015
2125
2220
2330
Sheet1


Plot this and you get a nice pyramid. Change it to time-scale and you get an awesome rectangle like you want. See how the plotted points go (x-y)?

0-0 to 1-0 to 1-5 to 2-5 to 2-0 to 3-0

So 1 square right, 5 squares up, 1 square right, 5 squares down, 1 square right

In order to do that properly for lots of series, you need to plot a silly-big amount of points. Hence the massive data table. Basically, each point you have (and you need 4-6 points per rectangle) needs to have 3 different X values. As you add more series, you need even more points. And more points. And more points.

Since you can only have a primary and secondary axis, that means you can really only use 2 different sets of X values. That means with more than 2 series, you need to combine all your X values into a nice table like I had, where you have tons of repeating values that aren't necessary for several of the series. It's a pain, but it gets the job done.

Once you get the hang of it, it isn't difficult at all. Just time-consuming.
 
Upvote 0
Thank you for the information, Andy.

tokyods

In the future if you cross-post, write it in your post, as well as the corresponding cross-post address.

If you do not do this, you may have people spending their time trying to help you when the problem is already solved. This is unfriendly and leaves a bad impression.
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top