|
Peltier Tech |
PTS Cluster Stack Utility Documentation.To purchase the Professional Cluster Stack Chart Utility, visit PTS Cluster Stack Chart Utility.
In Clustered-Stacked Column Charts, I described a protocol for constructing clustered-stacked column charts in Excel. This protocol is rather complicated, so I have written a Cluster Stack Chart utility that allows the user to construct clustered-stacked column charts directly from the data. More recently I've added the ability to create clustered-stacked bar charts as well. The utility inserts a new worksheet, adds a table with the appropriate data arrangement and the necessary formulas, and then creates and formats a clustered-stacked column chart from this table. The utility is designed to work in Excel versions 2000, 2002, 2003, 2007, and 2010. The utility has not been tested in any Macintosh version or in Excel 97, it may or may not work on these versions. ContentsInstallationStart installation by closing Excel, then double click on the PTS_ClusterStack_Setup.exe file that you've downloaded. The Cluster Stack Chart Utility is installed as an Excel add-in. In addition, ClusterStackData.xls, a workbook containing sample data to illustrate the operation of the utility, is saved in PTS Charts, a new directory in your My Documents directory. The Excel User InterfaceExcel 2000 through 2003 Interface
Excel 2007 Interface
The Cluster Stack Chart DialogTo use the utility, select a range of data to chart, then select the Clustered Stacked Chart menu item, and the following dialog appears.
If a range containing chartable data has been selected, this range is indicated in the range selection box at the top of the dialog. If the selected range consists of multiple discontiguous areas, if the selected range contains no data, or if the selection is not a range, this box is empty. If the selected range consists of a single cell, the utility identifies the range of data surrounding the active cell in the range selection box, like the Chart Wizard does. If the selection is larger than one row high and one column wide, the utility identifies only the selected range in the box. The utility determines the number of rows (category labels) and columns (number of series) in the data range. When first opened the utility assumes there will be two columns (bars) side by side for each category in the chart, and splits the series as evenly as possible between these two columns (bars). These parameters can all be adjusted, because not all charts have the same number of columns (bars) for each category, or even the same number of series stacked in each column (bar). The utility validates the inputs after every change. The utility inserts a new worksheet for its output. The selected data, linked to the original cells, is copied to this worksheet in an appropriately staggered arrangement, and a chart is created that plots the data. The chart is a standard Excel chart; it can be copied and pasted, moved, resized, and otherwise formatted as any other Excel chart. For a quick refresher of the data requirements, click on the large button above the OK button to see the following screen. Data Requirements
The number of categories is simply the number of clusters of columns that will be plotted in your chart. In the example, there are five categories, with labels "A" through "E".
The number of columns per categories is the number of stacks of columns are clustered together above each category. All categories have the same number of columns, and the same series in each corresponding column (some series may not appear if they have zeros in the data range). In this example there are three columns per category, labeled 1 through 3.
The number of blocks in each stack is the number of series that appear in each column of the cluster. Each column of a cluster may have a different number of blocks. These stacks have 2, 3, and 4 blocks respectively, labeled bottom to top starting with "a".
You must carefully arrange your data as shown in the dialog. The first column must contain category labels, the first row must contain series names, and the top left cell should be blank (though the utility ignores this cell). The series are aligned in worksheet columns. The series from the leftmost stack appear first, starting with the bottom series in the stack. Then the series from the second stack appear, again sorted from bottom to top. This pattern continues for all series in all stacks. Example UsageThe following two examples are offered to help illustrate how to use the Cluster Stack Utility. Example 1An office supplies exporter wants to examine quarterly shipments (Q1 through Q4) of two product lines (pencils and pens) to three geographic regions (North America, Europe, and Asia). A table of the data is shown below; this table is already arranged in the input format required by the utility. The geographical regions comprise the categories, each of the two product lines will be plotted as adjacent columns above each category, and the four quarter results will be stacked in each of these columns.
Select the data range and click the button on the menu, toolbar, or ribbon. The range address is indicated in the edit box, as are the number of rows (categories) and columns (series or blocks). By default, the utility has selected two columns per category, and split the eight series evenly between them.
Since this is the desired arrangement, click OK. The utility inserts a new worksheet, creates a table with values linked to the selected range above, but staggered in order to create the clustered and stacked appearance of the chart.
The clustered-stacked bar version of the chart is shown below:
Example 2This example uses the same data as the first, but the input table below has been rearranged to plot quarterly columns for each region, with the two product lines stacked together.
Note that the entire range need not be selected. If you select one cell in a range, the utility detects the larger range as the initial range in the dialog. Of course you can select a more appropriate range. The columns per category option has been changed to 4, and the list of stacks and blocks has been updated to show two blocks per stacked column.
When the dialog entries are approved, the utility creates the corresponding linked table and chart.
Accessing the PTS Cluster Stack Utility via VBAThe ability to call the PTS Cluster Stack Utility from other VBA procedures has been incorporated in this version of the utility. Documentation is incomplete but will be added here. The following brief explanation should help get experienced programmers started. The core of the PTS Cluster Stack Utility is a procedure called PTS_ClusterStackChart, which can be called from other VBA procedures. The syntax of the PTS_ClusterStackChart function is: Function PTS_ClusterStackChart(ChartData As Range, _
Optional [DataLayouts], _
Optional ChartStyle As String = "Column") _
As Chart
ChartData is the range containing the data to chart, laid out as described above and repeated below: DataLayouts is an array that simply lists the number of series per stacked column (the number of elements in the array indicates the number of columns per category). If DataLayouts is omitted, the utility will assume two columns, and divide the series as evenly as possible between the two columns. In example 1 above, this array would be {4,4}, the same as the default. In example 2 the array would be {2,2,2,2}. To repeat Example 2 programmatically, a calling procedure could select the data range, then run this line of code: PTS_ClusterStackChart Selection, Array(2,2,2,2), "Column" To assign the chart to a variable in order to manipulate it further, the code should be amended: Set chtClusterStack = PTS_ClusterStackChart(Selection, Array(2,2,2,2), "Column") where chtClusterStack has been declared as a variable of type Excel.Chart. Contact MeTo purchase the Professional Cluster Stack Chart Utility, visit PTS Cluster Stack Chart Utility. In the event of problems with this utility, use the following link to send me an email. While I may be unable to answer all email messages, I will certainly address any issues that arise. If you are reporting a problem, please describe the problem as clearly as possible, and if relevant include a copy of the data and chart. I will also consider reasonable enhancements to the utility. I do not plan to make the utility compatible with Excel 97 or earlier, nor do I plan to extend its compatibility to Mac versions of Excel. |
Peltier Technical Services, Inc.Excel Chart Add-Ins | Training | Custom Solutions | Charts and Tutorials | Peltier Tech BlogPeltier Technical Services, Inc., Copyright © 2010. All rights reserved. |