You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Issue with 2D stacked bar chart with dates (gannt chart)

Hi,

I would like to highlight the following problem I experienced on Numbers version 6.2.1 (6529) running on a MacBook Pro (Retina, Mid 2012) with Mac Os Catalina 10.15.3.

I hope that someone can help me.


I would like to create with Numbers a so called Gannt chart, highlighting the time span of several projects. Refer to the attached image for the following details.

I inserted 2 tasks, each having a "Start" and "End" value as dates.

I also computed the time interval by using a simple difference (column "Duration").

Then, I used a 2D Stacked Bar Chart in order to plot the "Start" values and, on top of them, the "Duration" value, just like in Excel.

However, the plot doesn't show the values I am expecting. The start dates are correct (I added the label so that you can compare them in the attached image), however the end dates are not: just look at the X axis and compare the end of the green bars with the original data in the table. For example, Task 1 ends on "30 May 2020", however on the chart it ends around December 2021.


So the questions are the following:


  1. Why the chart does not display the green bars spanning the exact amount of time I am expecting and how can the correct plot be obtained?
  2. Minor question: why the minimum value on the X axis is not the same I am setting under the "Axis Scale" section? For example, in this case I inserted the value "1/1/2020" as minimum value. The X axis range has changed, but not in the way I expected. Indeed, the min value is "13 Jun 2018" on the chart. The same behaviour is related to the Maximum Value of X axis, which does not change accordingly to what I specify.


Hope someone can help me.

If you need some additional information, let me know.

Thank you!

MacBook Pro 15", macOS 10.15

Posted on Mar 30, 2020 2:23 AM

Reply
Question marked as Top-ranking reply

Posted on Mar 30, 2020 7:35 PM

Part of it is an Apples and Oranges issue. The rest may come from Numbers trying to solve that issue.


To make any sense, a stacked bar chart, essentially a chart is which two or more bars are stacked, one atop the other, or, as in this case, laid end to end, needs both bars to be displaying the same type of data.


Here, the bright green bar is to display a duration value, days, but the pale bar is provided with a Date and Time value, a value marking a single instant in the flow of time.


Revise your table to provide two duration values, and you should be good to go. Still a bit of a slog, though, as you'll need to add a rotated text box to hold the date labels along the x axis, and may need to add a 'frame' around the chart.



Table:

Row 1 must be a Header row.

Column A must be a header column.


A1 contains the date on which the project starts. This is used in all calculations in column D of the table


The rest of column A contains the labels to be attached o each job/task in the project.


Column B contains the start date of each task.

Column C contains the end date of each task.


Column D contains the formula below, which calculates the number of days from the project start date to the task start date. (length of first bar)


D2: DUR2DAYS(B2−$A$1)


Fill down to the end of column D.


Column E contains the formula below, which calculates the number of days from each task start date to the task end date. (length of second bar)


E2: DUR2DAYS(C2−B2)


Fill down to end of column E.


In the table, select column D for the first set of values to be charted, then select column E for the second set.

The bar colours came up for me as bright blue and glowing green (shown).

Click the first bar, visible in the lower example, then in the Style menu choose No Fill from the pop-up menu labeled 'Fill'.


Click off the chart to deselect the bar (and the chart), then click once of the chart to re-select it. In the inspector, choose Axis, then Value (x) axis.

Set the value labels to Same as Source data, and rotate the labels to vertical left.

Use the stepper in Axis Scale > Steps to get an integer label on each step marker. (Best I could get was 0, 10, 20…).

Add one minor step to get markers at five day intervals.


If you're OK with the axis being marked in numbers of days since start, stop there.

If you want Date values, carry on…


Click on the Table to select it, then click once on the column control (at the right end of the column reference tabs) to add a column to the table.

Click on the new column's reference tab to select it, then click and hold about midway between the letter (F) and the left edge of the tab.After a brief wait, the tab and its column will 'rise' from the table. Drag right to move the column away from the rest of the table. When it separates, drag it to a convenient location, then release the mouse button to drop it onto the canvas.


In cell A2 of the new, single column table, enter the starting date shown in A1 of the main table. In A3, type= to open the formula browser, then enter the formula A2+5 (this assumes you'll have a 10 day difference between the numbers along the axis). Click the green check to confirm the formula and close the browser.


Add as many rows as needed to get to the last date on the chart, then fill the formula down fro A3 to the end of the column.

Copy the cells containing the dates, then click the text button to open a text box. Drag it to a convenient location, then click in the box, go to the edit menu and choose Paste and match style.


With the box selected, but not the text, go to the Arrange inspector panel and set rotate to 90°

Change to the Style section and change No Fill to Color fill and choose White.


You may have to do some adjustments to the line spacing in the box or to the width of the chart to get an acceptable alignment of the labels in the box with the date marker lines on the chart.


Place the box so that Jan 1 is at the left most number (0), then use as far right as possible to match with the correct marker on the chart axis.


When satisfied. nudge the box upward to cover the numbers as shown above.


Note on the Border:

The border I used is a rectangular shape with no fill, thin borders, and no shadow placed behind the chart.

If you prefer it to the border placed by the checkbox in the inspector, roll your own. If you OK with the 'native' border, go with that one. I used the bigger one mostly because I'd already taken the screen shot when I found the checkbox. :-)


Regards,

Barry





Similar questions

5 replies
Question marked as Top-ranking reply

Mar 30, 2020 7:35 PM in response to egl2017

Part of it is an Apples and Oranges issue. The rest may come from Numbers trying to solve that issue.


To make any sense, a stacked bar chart, essentially a chart is which two or more bars are stacked, one atop the other, or, as in this case, laid end to end, needs both bars to be displaying the same type of data.


Here, the bright green bar is to display a duration value, days, but the pale bar is provided with a Date and Time value, a value marking a single instant in the flow of time.


Revise your table to provide two duration values, and you should be good to go. Still a bit of a slog, though, as you'll need to add a rotated text box to hold the date labels along the x axis, and may need to add a 'frame' around the chart.



Table:

Row 1 must be a Header row.

Column A must be a header column.


A1 contains the date on which the project starts. This is used in all calculations in column D of the table


The rest of column A contains the labels to be attached o each job/task in the project.


Column B contains the start date of each task.

Column C contains the end date of each task.


Column D contains the formula below, which calculates the number of days from the project start date to the task start date. (length of first bar)


D2: DUR2DAYS(B2−$A$1)


Fill down to the end of column D.


Column E contains the formula below, which calculates the number of days from each task start date to the task end date. (length of second bar)


E2: DUR2DAYS(C2−B2)


Fill down to end of column E.


In the table, select column D for the first set of values to be charted, then select column E for the second set.

The bar colours came up for me as bright blue and glowing green (shown).

Click the first bar, visible in the lower example, then in the Style menu choose No Fill from the pop-up menu labeled 'Fill'.


Click off the chart to deselect the bar (and the chart), then click once of the chart to re-select it. In the inspector, choose Axis, then Value (x) axis.

Set the value labels to Same as Source data, and rotate the labels to vertical left.

Use the stepper in Axis Scale > Steps to get an integer label on each step marker. (Best I could get was 0, 10, 20…).

Add one minor step to get markers at five day intervals.


If you're OK with the axis being marked in numbers of days since start, stop there.

If you want Date values, carry on…


Click on the Table to select it, then click once on the column control (at the right end of the column reference tabs) to add a column to the table.

Click on the new column's reference tab to select it, then click and hold about midway between the letter (F) and the left edge of the tab.After a brief wait, the tab and its column will 'rise' from the table. Drag right to move the column away from the rest of the table. When it separates, drag it to a convenient location, then release the mouse button to drop it onto the canvas.


In cell A2 of the new, single column table, enter the starting date shown in A1 of the main table. In A3, type= to open the formula browser, then enter the formula A2+5 (this assumes you'll have a 10 day difference between the numbers along the axis). Click the green check to confirm the formula and close the browser.


Add as many rows as needed to get to the last date on the chart, then fill the formula down fro A3 to the end of the column.

Copy the cells containing the dates, then click the text button to open a text box. Drag it to a convenient location, then click in the box, go to the edit menu and choose Paste and match style.


With the box selected, but not the text, go to the Arrange inspector panel and set rotate to 90°

Change to the Style section and change No Fill to Color fill and choose White.


You may have to do some adjustments to the line spacing in the box or to the width of the chart to get an acceptable alignment of the labels in the box with the date marker lines on the chart.


Place the box so that Jan 1 is at the left most number (0), then use as far right as possible to match with the correct marker on the chart axis.


When satisfied. nudge the box upward to cover the numbers as shown above.


Note on the Border:

The border I used is a rectangular shape with no fill, thin borders, and no shadow placed behind the chart.

If you prefer it to the border placed by the checkbox in the inspector, roll your own. If you OK with the 'native' border, go with that one. I used the bigger one mostly because I'd already taken the screen shot when I found the checkbox. :-)


Regards,

Barry





Mar 31, 2020 4:38 AM in response to Barry

Hi Barry,

thank you very much for your extensive and detailed suggestions!


I summarise your point in order to make it accessible in a few seconds to the readers:

  • obtain a value of duration with respect to a fixed date for both "Starting Date" and "End Dates" columns;
  • plot such durations with a 2D Stacked Bar Chart;
  • put a patch text box containing the dates just below the X axis in order to overlap the units displayed.


However, in my opinion such method does not represent a general and coherent way to solve the issue. Just imagine adding 1 more task, or modifying the original data: you should create your text box again, and place it again below the X axis to create a new patch, paying a lot of attention in order to make the text and the ticks match.


Another point which I do not fully understand is when you say: "a stacked bar chart... needs both bars to be displaying the same type of data.". The format Date/Time and the format Number should in theory both be just numbers: in fact, a date is only a given number of days (or hours, ecc...) starting from a reference value, which in Number should be "2001/01/01 00:00:00". Therefore, in my opinion, stacking a date value and a number value should be perfectly fine. Moreover, just as an additional check, if I add a natural number (for example 10) to a date, it returns, as expected, a date shifted of 10 days (see the attached image).

Therefore, it seems that Numbers, at least in this simple formula, correctly stacks a natural number on a date to return another date. But such behaviour simply seems not to work properly in the chart.


I think also point 2 in my original questions remains open: the maximum and minimum of the X axis seems not to work at all.


Please, correct me if I'm wrong, but I think both points are still open.

Any other suggestions are very welcome!


Mar 31, 2020 5:44 AM in response to egl2017

Hi egl2017

egl2017 wrote:

if I add a natural number (for example 10) to a date, it returns, as expected, a date shifted of 10 days (see the attached image).

Numbers interprets +10 not as a natural number, but Numbers helps us out by assuming that we mean, by default, 10 days (or we can type it more explicitly as "10d", a Duration).


If we explicitly want to add a Duration of two weeks to 1 Jan 2020:


Date & Time format (a single point in time) is not the same as Duration format (a period of time).


Regards,

Ian.

Mar 31, 2020 7:10 PM in response to egl2017

"in my opinion such method does not represent a general and coherent way to solve the issue."


"general and coherent" are qualities to strive for, but sometimes inaccessible.


This is, after all, a user-to-user community. The participants here are not part of the Numbers development team, and have no control over the properties of the application. We get to work with the software as it currently exists, not 'as it "should" exist.


Gantt charts have been a recurring topic here for several years. Jerrold Green1 was possibly the first to provide a useful one (originally, If I recall correctly, written for AppleWorks. I did a reconstruction of that document some time after Jerry had left the community, and could provide instructions for constructing it, if you are interested. It looks like this:


A second technique is to use a Table as the chart, and construct the 'bars' using conditional highlighting.

I'm not certain who posted this example.



Regards,

Barry




Mar 31, 2020 7:34 AM in response to Yellowbox

Hi Ian,

thanks a lot for your reply.


So, Numbers correctly interprets the formula when adding to a date a number (for example 10 is like 10 days) or a string like "2w" (which is 2 weeks).

Therefore, despite the fact that, as you said, Duration format and Date&Time format are not the same, the sum is correctly handled.


This remark, however, confirms my doubts, especially with respect to point 1 in my original question, where it seems that the sum of a date and a duration is not correctly handled on the graph.

Besides, point 2 is still completely inexplicable to me.


Thank you again!

Issue with 2D stacked bar chart with dates (gannt chart)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.