PTS Blog http://peltiertech.com/WordPress PTS Charts and Stuff Wed, 23 Jul 2008 18:05:45 +0000 http://wordpress.org/?v=2.6 en In-Cell Bullet Charts http://peltiertech.com/WordPress/2008/07/23/in-cell-bullet-charts/ http://peltiertech.com/WordPress/2008/07/23/in-cell-bullet-charts/#comments Wed, 23 Jul 2008 18:05:45 +0000 Jon Peltier http://peltiertech.com/WordPress/?p=171 Stephen Few of Perceptual Edge introduced the concept of Bullet Graphs a few years ago, and their use as a replacement for various gauge charts is slowly expanding. Bullet graphs are easier to read than the many gauges that adorn poorly designed business dashboards, while taking up less space and breaking the ineffective metaphor of a business dashboard as the cockpit of a 747.

Stephen Few's Bullet Charts

Charley Kyd of Excel User shows How to Create Bullet Graphs To Replace Gauges in Excel.

Excel User's Excel Bullets

Dealer Diagnostics shows how to Create Bullet Graphs with Google Charts.

Google Bullet Chart Google Bullet Chart

And now Chandoo of Pointy Haired Dilbert wants to help you Become a Dashboard Ninja with Bullet Graphs. Chandoo has done some interesting things with conditional formatting (visit his blog for examples), which he uses for the background colors of his bullets, shown below. The bars and the ticks used to indicate last year’s performance are controlled by worksheet formulas.

Chandoo's In-Cell Excel Bullets

Chandoo's In-Cell Excel Bullets

This is a clever way to get bullet charts into an Excel report.

]]>
http://peltiertech.com/WordPress/2008/07/23/in-cell-bullet-charts/feed/
Easier Interactive Multiple Line Chart http://peltiertech.com/WordPress/2008/07/22/easier-interactive-multiple-line-chart/ http://peltiertech.com/WordPress/2008/07/22/easier-interactive-multiple-line-chart/#comments Wed, 23 Jul 2008 02:37:44 +0000 Jon Peltier http://peltiertech.com/WordPress/?p=163 In Interactive Multiple Line Chart I showed how to make an interactive chart that allows the user to select from among a number of series using a listbox, and the selected series is displayed in a chart.

Line Chart and Listbox with Highlighted Series A

A similar technique is described in Interactive Parallel Coordinates Chart on my web site, and I used this technique in a workbook that supports my blog post Re: Abortion Ratios 1980-2003.

My colleague Dermot Balson read the post and wondered why I was doing it the hard way. Well, he’s right. I built a set of dynamic names that change based on the listbox selection, which is certainly a valid approach. However, for something as “simple” as plotting a column or row of data, it’s overkill. In this post I will describe an easier approach.

Data by Columns

The worksheet has data for multiple companies in columns, with each row representing the respective values on a given date. I made up some sine functions for the company data; a portion of the data is shown below.

Portion of Data Range

For many situations a popular visualization approach is to plot one series in a contrasting color, and the rest of the data set is plotted in the background. I plotted this data on a single chart, and formatted all series to use a light gray line. This chart comprises the background.

Line Chart with 12 Series

We need to define a couple names to make this work. First, the column headers, the range of cells containing the Company names, is named “Companies”.

The listbox we will add requires a columnar (vertical) list, and the company names are in a horizontal list. I selected a range one column wide and 12 rows high (there are 12 companies in the table), typed this formula

=TRANSPOSE(Companies)
 

and held down CTRL+SHIFT while pressing ENTER to make it an array formula. When an array formula is correctly entered, Excel wraps it in curly braces:

{=TRANSPOSE(Companies)}
 

I named this range “CompanyList”, then selected another nearby cell (cell O2 in the shot below) and named it “SelectedItem”.

Defined Range Names

I added a listbox from the forms menu to the worksheet, and formatted it to use CompanyList as the input range and SelectedItem as the cell link. This means the list in CompanyList is displayed in the listbox, and the index of the selected item is displayed in Selecteditem.

Format Listbox

The listbox looks like this:

Listbox

A column adjacent to the data range is used to hold the data for the selected company. Here is a pilot’s eye view of the worksheet (for a better view, download the workbook from the link at the bottom of the page).

Worksheet

The original data is in A23:M79, and the added data, highlighted in blue, is in N23:N79. Cell N23 has this formula:

=OFFSET(A23,0,SelectedItem)
 

and the formula is filled down to N7.

Now the selected series can be added to the chart. Copy the blue range, select the chart, and use Edit menu > Paste Special to add the data to the chart as a new series. Format to suit.

To create a chart without the background series (like the one shown at the top of this post), simply make the chart using column N for the Y values and column A for the X values.

Here is the chart, showing all series in the background gray and the selected Company A highlighted in blue.

Line Chart and Listbox with Highlighted Series A

Clicking another item in the list changes the highlighted series, to Company L below.

Line Chart and Listbox with Highlighted Series L

By Row

For this example I made up data for multiple companies in rows, with each column representing the respective values on a given date; a portion of the data is shown below.

Portion of Data Range

I plotted this data on a single chart, and formatted all series to use a light gray line. This chart comprises the background.

Line Chart with 12 Series

We need to define a couple names to make this work. First, the row headers, the range of cells containing the Company names, is named “TheCompanies”. I selected another nearby cell and named it “TheSelection”. (The names are different than in the first example, because both examples are in the same workbook, and I wanted to avoid naming conflicts.)

I added a listbox from the forms menu to the worksheet, and formatted it to use TheCompanies as the input range and TheSelection as the cell link. This means the list in TheCompanies is displayed in the listbox, and the index of the selected item is displayed in TheSelection.

Format Listbox

The listbox looks like this:

Listbox

A row adjacent to the data range is used to hold the data for the selected company. Here is a pilot’s eye view of the worksheet (for a better view, download the workbook from the link at the bottom of the page).

Worksheet

The original data is in A23:M35, and the added data, highlighted in orange, is in A36:M36. Cell A36 has this formula:

=OFFSET(A23,TheSelection,0)
 

and the formula is filled right to M36.

Now the selected series can be added to the chart. Copy the orange range, select the chart, and use Edit menu > Paste Special to add the data to the chart as a new series. Format to suit.

To create a chart without the background series (like the one shown at the top of this post), simply make the chart using row 36 for the Y values and row 23 for the X values.

Here is the chart, showing all series in the background gray and the selected Company A highlighted in orange.

Line Chart and Listbox with Highlighted Series A

Clicking another item in the list changes the highlighted series, to Company L below.

Line Chart and Listbox with Highlighted Series L

Sample Workbook

Download a workbook that contains these two examples: EasierInteractiveLines.zip

]]>
http://peltiertech.com/WordPress/2008/07/22/easier-interactive-multiple-line-chart/feed/
Interactive Multiple Line Chart http://peltiertech.com/WordPress/2008/07/22/interactive-multiple-line-chart/ http://peltiertech.com/WordPress/2008/07/22/interactive-multiple-line-chart/#comments Tue, 22 Jul 2008 04:46:20 +0000 Jon Peltier http://peltiertech.com/WordPress/?p=158 In the Microsoft charting newsgroup, SKP asked how to make a chart that he could easily change from one series to another. This post will detail the steps to make an interactive chart that allows the user to select from among a number of series using a listbox, and the selected series is displayed in a chart.

Line Chart and Listbox with Highlighted Series A

A similar technique is described in Interactive Parallel Coordinates Chart on my web site, and I used this technique in a workbook that supports my blog post Re: Abortion Ratios 1980-2003.

Update (22 July 2008)

My colleague Dermot Balson read this post and wondered why I was doing it the hard way. Well, he’s right. I’ve built a set of dynamic names that change based on the listbox selection, which is certainly a valid approach. However, for something as “simple” as plotting a column or row of data, it’s overkill. In Easier Interactive Multiple Line Chart I describe an easier approach.

Data by Columns

SKP had data for multiple companies in columns, with each row representing the respective values on a given date. I made up some sine functions for the company data; a portion of the data is shown below.

Portion of Data Range

For many situations a popular visualization approach is to plot one series in a contrasting color, and the rest of the data set is plotted in the background. I plotted this data on a single chart, and formatted all series to use a light gray line. This chart comprises the background.

Line Chart with 12 Series

We need to define some dynamic names to make this work. This process is covered in some detail in Dynamic Charts. First, the column headers, the range of cells containing the Company names, is named “Companies”. The first column, the range of cells containing the dates, is named “Dates”.

The listbox we will add requires a columnar (vertical) list, and the company names are in a horizontal list. I selected a range one column wide and 12 rows high (there are 12 companies in the table), typed this formula

=TRANSPOSE(Companies)
 

and held down CTRL+SHIFT while pressing ENTER to make it an array formula. When an array formula is correctly entered, Excel wraps it in curly braces:

{=TRANSPOSE(Companies)}
 

I named this range “CompanyList”, then selected another nearby cell (cell O2 in the shot below) and named it “SelectedItem”.

Defined Range Names

I added a listbox from the forms menu to the worksheet, and formatted it to use CompanyList as the input range and SelectedItem as the cell link. This means the list in CompanyList is displayed in the listbox, and the index of the selected item is displayed in Selecteditem.

Format Listbox

The listbox looks like this:

Listbox

A couple more names must be defined. Open the Defined Name dialog, add the name “SelectedSeries”, enter the following Refers To formula, and click Add.

=OFFSET(Dates,0,SelectedItem)
 

Add the name “SelectedName”, enter the following Refers To formula, and click Done.

=OFFSET(Dates,-1,SelectedItem,1,1)
 

Now the selected series can be added to the chart. Select the chart, go to the Chart menu, choose Source data, and click on the Series tab. Click Add, then enter the appropriate names for the series name, values, and category labels, prefixed with the sheet name. Click OK.

Add Selected Series

To create a chart without the background series (like the one shown at the top of this post), select an empty cell, run the chart wizard, and in Step 2, click on the Series tab, add the first series, and enter the range names as above.

Here is the chart, showing all series in the background gray and the selected Company A highlighted in blue.

Line Chart and Listbox with Highlighted Series A

Clicking another item in the list changes the highlighted series, to Company L below.

Line Chart and Listbox with Highlighted Series L

By Row

For this example I made up data for multiple companies in rows, with each column representing the respective values on a given date; a portion of the data is shown below.

Portion of Data Range

I plotted this data on a single chart, and formatted all series to use a light gray line. This chart comprises the background.

Line Chart with 12 Series

We need to define some dynamic names to make this work, as described in Dynamic Charts. First, the row headers, the range of cells containing the Company names, is named “TheCompanies”. The first row, the range of cells containing the dates, is named “TheDates”. I selected another nearby cell and named it “TheSelection”. (The names are different than in the first example, because both examples are in the same workbook, and I wanted to avoid naming conflicts.)

I added a listbox from the forms menu to the worksheet, and formatted it to use TheCompanies as the input range and TheSelection as the cell link. This means the list in TheCompanies is displayed in the listbox, and the index of the selected item is displayed in TheSelection.

Format Listbox

The listbox looks like this:

Listbox

A couple more names must be defined. Open the Defined Name dialog, add the name “TheSeries”, enter the following Refers To formula, and click Add.

=OFFSET(TheDates,TheSelection,0)
 

Add the name “TheName”, enter the following Refers To formula, and click Done.

=OFFSET(TheDates,TheSelection,-1,1,1)
 

Now the selected series can be added to the chart. Select the chart, go to the Chart menu, choose Source data, and click on the Series tab. Click Add, then enter the appropriate names for the series name, values, and category labels, prefixed with the sheet name. Click OK.

Add Selected Series

To create a chart without the background series (like the one shown at the top of this post), select an empty cell, run the chart wizard, and in Step 2, click on the Series tab, add the first series, and enter the range names as above.

Here is the chart, showing all series in the background gray and the selected Company A highlighted in orange.

Line Chart and Listbox with Highlighted Series A

Clicking another item in the list changes the highlighted series, to Company L below.

Line Chart and Listbox with Highlighted Series L

Sample Workbook

Download a workbook that contains these two examples: InteractiveLines.zip

]]>
http://peltiertech.com/WordPress/2008/07/22/interactive-multiple-line-chart/feed/
Re: Abortion Ratios 1980-2003 http://peltiertech.com/WordPress/2008/07/21/re-abortion-ratios-1980-2003/ http://peltiertech.com/WordPress/2008/07/21/re-abortion-ratios-1980-2003/#comments Mon, 21 Jul 2008 20:36:30 +0000 Jon Peltier http://peltiertech.com/WordPress/?p=157 In Chart Design: Abortion Ratios 1980-2003 Jorge Camoes shows a nice panel chart of Abortion Ratios vs. Year (1980-2003) for different age groups, taking US Census Bureau data. I reproduce a few panels of Jorge’s chart below; click on the chart to see his entire panel chart.

Section of Jorge Camoes' Panel Chart

Jorge points out the downward trend in the curves from 1980 to 2003, which are evident in all seven age groups in the full panel chart (the “<15″ age group actually has started to increase again after about 1995). What is less obvious is a downward trend from the “<15″ through “30-34″ age groups, which then rises again from “30-34″ through “>40″. Jorge cautions against missing such patterns when planning a display such as this.

The first step to constructing an analysis like Jorge has made, is to examine the data from as many directions as possible. When you have rows and columns of data, the first exploratory charts you must make show the data plotted with series in rows and with series in columns. I made two charts of this sort, not separated yet as a comprehensive panel chart would be. The first chart below shows the data as Jorge has plotted it; the second shows the same data plotted orthogonally.

Abortion Rate vs. Year by Age
Abortion Rate vs. Age by Year

The first chart shows the downward trend Jorge chose to emphasize; the second chart shows the “U” shaped pattern Jorge warns us not to miss. There is no “best way” to show all of this information on a chart. Sometimes the solution is to use more than one chart.

One way to make this easier depends on the ability to provide an interactive chart. In Excel this can be done using worksheet controls that redefine dynamic ranges as they are adjusted by the user. I used this approach on my web site to describe an Interactive Parallel Coordinates Chart. For this exercise, I created an interactive version of each of the charts above in a downloadable zipped workbook. One of these charts is shown below. All series are shown in light gray to provide context, while the series selected in the listbox is shown in a distinct color.

Interactive chart of Abortion Rate vs. Year by Age

Jorge also points out that while the Abortion Rate is highest for the youngest age group, the percentage of abortions by age group is lowest for this age group. Another pair of charts displays this behavior; I will show these below, and suspend my analysis. Jorge has added this data to his panel chart using a thin bar beside each panel. Alternatively, an additional chart adjacent to the first may be used to show this data.

Abortion Percentage vs. Year by Age
Abortion Percentage vs. Age by Year

Some brainstorming could help identify reasons for the observed behavior. For example, the “<15″ age group has the fewest pregnancies, and most of these are terminated by abortions.

In Small Multiples - Abortion Data 1980-2003, Andreas Lipphardt has written about Jorge’s panel chart. Andreas likes the panel (small multiples) chart, but feels that it can be improved. He would leave off the light gray lines showing data from other panels (I actually like them, but Andreas is right, they really aren’t necessary here). Andreas would replace the bars showing the percentage of total abortions by age group (between the panels in Jorge’s plot) and replace them with another row of panels, showing how this data trends with time (Jorge had used a single time point, I believe the last year of the study). Andreas’ added panel corresponds to the first chart of my second pair, above. Following Andreas’ adjustments to Jorge’s chart, it may not be a bad design to include several rows in the panel chart. Here is a first cut, with absolutely minimal labeling.

Abortion Rate Statistics by Age

]]>
http://peltiertech.com/WordPress/2008/07/21/re-abortion-ratios-1980-2003/feed/
Excel Category Axis Types http://peltiertech.com/WordPress/2008/07/21/excel-category-axis-types/ http://peltiertech.com/WordPress/2008/07/21/excel-category-axis-types/#comments Mon, 21 Jul 2008 13:15:38 +0000 Jon Peltier http://peltiertech.com/WordPress/?p=156 In Line Charts vs. XY Charts I described the difference between these two Excel chart types. There is no difference in the ways you can format the series, so perhaps the names of the chart types are confusing. The differences are in the ways their respective X axes treat the X data. I discussed the differences in that post, and in Line-XY Combination Charts I showed how to make a combination Line-XY chart that combines the nice date formatting of a Line chart’s date scale axis with the more flexible plotting that an XY chart allows along the X axis.

In this post I will illustrate the behavior of the different category types in more detail.

Categorical Data

The following data has a column of category labels for X and a column of numerical values for Y.

Categorical X data

The default Line and Column charts are shown below. The categories are completely visible in the chart, because the value (Y) axis is set to cross the category (X) axis between categories, the default setting for line and column charts.

Line Chart - Categorical X Axis Column Chart - Categorical X Axis

Below, the value (Y) axis is set not to cross the category (X) axis between categories, so the first and last categories are only halfway visible.

Line Chart - Categorical X Axis Column Chart - Categorical X Axis

The default Area chart is shown below left. Unlike the Line and Column charts, its default is for the value (Y) axis not to cross the category (X) axis between categories. When the value (Y) axis is set to cross the category (X) axis between categories, there is a gap between the edges of the filled area and the edges of the chart (below right).

Area Chart - Categorical X Axis Area Chart - Categorical X Axis

A default bar chart has its category (X) axis along the vertical axis, and the bars extend horizontally parallel to the value (Y) axis. Note that the vertical axis is the X axis and the horizontal axis is the Y axis, unlike the convention in most charts. This is a common confusion for newcomers to Excel’s charts.

Bar Chart - Categorical X Axis

Here is an XY chart made using text labels for its X values. An XY chart has a value-based X axis, like its Y axis. Excel cannot plot nonnumerical data in a chart, so instead of the text labels, Excel inserts counting numbers, 1 for the first label, 2 for the second, etc. Nonnumerical values used for Y values in any chart are treated as zeros.

XY Chart - Value X Axis

Numerical Data

The following data has a column of numerical values for X and a column of numerical values for Y.

Numerical X data

Here are default Line and Column charts made using numerical values for their X values. The category (X) axis treats the X values as labels, despite their numerical character, so along the X axis points are spaced equally, not spaced according to the numerical values.

Line Chart - Numerical X Axis Column Chart - Numerical X Axis

Here is an XY chart made using numbers for its X values. Of course, this is what XY charts were designed for, so both the X and Y numbers are plotted along the X and Y axes according to their numerical values.

XY Chart - Value X Axis

Dates

The following data has a column of date for X and a column of numerical values for Y.

Date X data

The default Line and Column charts using this data are shown below. Unlike the treatment of text or numbers as nonnumeric category labels, the dates are treated as numerical dates, with the spacing between points proportional to the number of days between points. By default, the X axis stretches from the first date to the last, and Excel has chosen a “nice” X axis spacing of 7 days (one week).

Line Chart - Date-Scale X Axis Column Chart - Date-Scale X Axis

Here is an XY chart made using dates for its X values. Like the Line and Column charts shown above, the spacing of points along the X axis is proportional to the date value of the X data. The axis scale parameters are chosen as for any other value axis. The minimum, 12/29/2007, is day number 39445 in Excel’s date-time system*, the maximum, 2/7/2008, is day number 39485, and the spacing is 5 days. The formatting of the Line chart’s date-scale axis is much nicer.

XY Chart - Date X Axis

* Excel stores dates and times as a mixed number: the whole number part is the number of days since January 1, 1900, and the fractional part is the fraction of the day elapsed since midnight (e.g., noon = 0.5, 6 pm = 0.75).

Weekly Dates

The superiority of Excel’s date-scale axis for a chart’s X axis is better illustrated with a broader range of dates. This table shows Friday dates for the first three months of 2008.

Weekly Date X data

The default Line and Column charts using this data are shown below. The X axis stretches from the first date to the last, and Excel has chosen a “nice” calendar-related X axis spacing of 14 days (two weeks). The column chart illustrates a “problem” people have with using column charts with date-scale axes. The columns are very thin, and there is no way to make them much wider. Even changing the gap width to zero, which makes adjacent columns touch each other, leaves a large gap. This gap is created by the date-scale axis itself, which provides a slot for each day along the axis. Weekly data then consists of one data point followed by six blank slots before the next data point. Since line charts are generally a better tool to illustrate time series data, this is just one more reason not to use a column chart in this context.

Line Chart - Date-Scale X Axis Column Chart - Date-Scale X Axis

The corresponding XY chart is shown below. Its X axis scale is not calendar based, starting on Monday, 12/24/2007 (day 39440), and ending on Wednesday, 4/2/2008 (day 39540), with a tick spacing of 10 days.

XY Chart - Date X Axis

We can clean up the Line chart’s X axis by removing the year and rotating the resulting labels (below left) and fix up the XY chart’s X axis in the same way, and also by incorporating week-based scale parameters (below right). The charts are essentially identical.

Line Chart - Date-Scale X Axis XY Chart - Date X Axis

If we format the date-scale axis to show months, the Line chart does so nicely, with a tick mark at the beginning of each month, regardless of the number of days in the preceding month. The XY chart comes up short, because we have to use a “best-fit” major unit, in this case, 30-1/3 days. January is represented in two tick mark labels and February not at all along the XY chart’s X axis.

Line Chart - Date-Scale X Axis XY Chart - Date X Axis

Taken over a whole year, with a “best-fit” major unit of 30-1/2 days per month (366 days/12 months), the XY chart (shown under the Line chart, below) is even less appealing. January is shown in two tick mark labels, February not at all, and three months (March, May, and July) on the second of the month, not the first.

Line Chart - Date-Scale X Axis
XY Chart - Date X Axis

It is for this reason that I will often use a Line-XY combination chart: I get the benefit of the Line chart’s nice date-scale axis without the Line chart’s requirement that all series use the same X values.

Axis Types (Chart Options)

The axis types shown above for the Line, Column, and Area charts were assigned automatically by Excel, based on the X values data. You can actually tell Excel which type to use. For example, in your chart of stock prices, Excel plots every value by date, and leaves gaps in the chart for Saturdays and Sundays. You can omit the gaps by forcing Excel to use a Category type axis instead of a Date-Scale axis. In Excel 2003 and earlier, you can select Chart Options from the Chart menu, and the Axes tab of the resulting dialog lets you select which axes to use in the chart (in Excel 2007 these options are available on the Format Axis dialog). In the Line chart’s dialog (below left), the three options Automatic, Category, and Time-Scale (correctly renamed “Date-Scale” in Excel 2007) are available for selection. In the XY chart’s dialog (below right) these options are visible but disabled.

Chart Options Axes Tab for Line Chart —- Chart Options Axes Tab for XY Chart

In the following pairs of charts, the left hand one uses the Automatic (Category) axis, while the right hand one uses the Date-Scale type. The left hand charts, repeated from above, treat numerical X data as nonnumerical categories. In the right hand charts, the numbers in the X data are forced to be interpreted numerically, and plotted proportionally, not uniformly. The right hand charts are horizontally compressed because Excel leaves room for the longer axis tick labels which may extend beyond the plot area. The dates begin with day 1 (January 1, 1900).

Line Chart - Category X Axis Line Chart - Date-Scale X Axis

Column Chart - Category X Axis Column Chart - Date-Scale X Axis

The Line chart (above right) can almost be converted into an XY chart, by changing the X axis number format from a date format to a numerical format (such as “General”), setting the value axis not to cross between categories, and choosing appropriate scale parameters. Of course, it’s not perfect; since the first day in Excel’s date-time system is 1/1/1900, the smallest value that can be used as the X axis minimum is 1, not 0.

Line Chart - Date-Scale X Axis

This technique comes in handy when combining an XY chart with an area chart, to fill the area under or between XY chart series.

XY Area Chart: Fill Below an XY Series

In the following pairs of charts, the left hand one uses the Automatic (Date-Scale) axis, while the right hand one uses the Category type. The left hand charts, repeated from above, plot the dates in their X values proportionally. In the right hand charts, the dates are plotted uniformly, not proportionally.

Line Chart - Date-Scale X Axis Line Chart - Category X Axis

Column Chart - Date-Scale X Axis Column Chart - Category X Axis

This technique is useful to plot stock data while omitting gaps for weekends. Frankly I prefer the time scale axis; the gaps where the weekends occur give me a better sense for the date values.

Stock Chart - Date-Scale Axis Stock Chart - Category Axis

]]>
http://peltiertech.com/WordPress/2008/07/21/excel-category-axis-types/feed/
California Majority Party by County http://peltiertech.com/WordPress/2008/07/18/california-majority-party-by-county/ http://peltiertech.com/WordPress/2008/07/18/california-majority-party-by-county/#comments Fri, 18 Jul 2008 14:41:04 +0000 Jon Peltier http://peltiertech.com/WordPress/?p=155 Nathan Yau of FlowingData asks Can You Improve this Mediocre Statistical Graphic?

Mediocre Statistical Graph

So what’s wrong with this chart?

1. Image Clarity. Nathan’s screen shot of the original chart was pretty fuzzy, so I went to the source and captured it again, and that’s what I show above. I don’t thing a sharper image of this chart is what Nathan was thinking.

2. Chart type? The data points are measured discretely every four years, so a line chart is less imperative than for most time series. If a line chart is used, it should have markers for the points to emphasize their discrete nature, and the lines should be straight, not smoothed. Otherwise the chart implies that the data series are continuous.

3. Horizontal Axis. The 5-year tick spacing along the horizontal axis is confusing and misleading. It must be redrawn to accurately label the years where the measurements were made.

4. Color Scheme. In recent campaigns, the colors red and blue have become synonymous with the Democrat and Republican parties, so the use of green shades in this chart misses an opportunity to add understanding.

5. Labeling. The chart title and axis titles were misleading or nonexistent. The series were unlabeled.

I’ve produced the following two charts, the first a clustered column chart, the second a line chart. These may not be perfect, but they are a substantial improvement over the chart Nathan wants to fix.

Column Chart of California Registered Voters by County

Line Chart of California Registered Voters by County

Update (7/18/2008):

What else is wrong with the chart? National elections are not decided on a county-by-county basis. The statewide percentages of registered Democratic to Republican voters has not changed as much as the county weightings have changed, and the parties have not switched places in the ranks. Both parties have declined slowly, with Democrats always being around 8-10 percentage points higher. “Other” has remained essentially unchanged, and interestingly enough “No Answer” has doubled during the time period shown.

Line Chart of Statewide California Registered Voters

Update (7/19/2008):

What is wrong with the voters? A closer look at the numbers shows that in the majority of the years surveyed, more eligible voters were unregistered than were registered with any one party. The first chart shows actual numbers of voters, and we see that the raw numbers of voters who admit to being registered as either Republican or Democrat have held roughly steady over the five primary seasons. Those unregistered and those declining to answer have steadily increased. There must have been a voter registration effort before the 1996 primary season, when nearly 2.5 million people left the ranks of unregistered voters. (Part of the jump may also be due to a revision in the census of total eligible voters.)

Line Chart of Statewide California Eligible Voters by number

Line Chart of Statewide California Eligible Voters by Pct

Update (7/19/2008):

Jorge Camoes has proposed a sparkline chart to show the county majority party data. Jorge Camoes' Sparkline of California Registered Voters by County Jorge’s chart shows the difference between the percentage of Democrat-majority counties and 50%. I find his chart potentially confusing because (a) there’s no indication of vertical scale, (b) the difference from 50% requires extra mental processing, (c) mixing of colors for a single series makes in unclear, particularly when one of the colors (red) is often used to denote the party which is not the one shown in the chart.

I made a simple stacked column sparkline, which works better for me. Column Chart Sparkline of California Registered Voters by CountyYou get a sense of scale, at least, that the full height of the graphic is the full number of counties. The colors are also the conventional Democrat blue and Republican red. I would not want to stack more than two series, especially in a sparkline. Also, thee problem with a sparkline is that a more detailed analysis (as in my updates to this post) requires more series to explain.

]]>
http://peltiertech.com/WordPress/2008/07/18/california-majority-party-by-county/feed/
A Gauge that Works? http://peltiertech.com/WordPress/2008/07/18/a-gauge-that-works/ http://peltiertech.com/WordPress/2008/07/18/a-gauge-that-works/#comments Fri, 18 Jul 2008 11:48:41 +0000 Jon Peltier http://peltiertech.com/WordPress/?p=151 In A Gauge Chart That Works?, Clint describes his efforts to come up with a dial-type chart that isn’t as terrible as most. He comments that Stephen Few’s Bullet Graphs are unfamiliar to most people, which is true, ans they’ve only been around for three or four years. Bullet graphs and most gauge-type charts are tricky to create and maintain, since they rely on a melange of chart types and additional chart elements to produce unusual visual effects. Clint’s boss wanted a gauge, but Clint didn’t want to work with ugly, bulky dial gauge replicas. Long story short, Clint designed the following gauge to show page views in a web site he was watching:

Clint's Gauge Chart

I’m not wild about the new gauge, but it isn’t totally awful. I’m not sure that a bullet-style graph with this color scheme couldn’t have been used (shown below without the text elements), but I’ll leave that discussion alone. I also won’t dwell on the observation that a bullet chart is really a gauge at heart.

Bullet-Style Graph

On the positive side, Clint’s graph is linear instead of circular. Also, the new Excel 2007 feature is nice that allows arrowheads on series lines and error bars. (One of the few nice things about Excel 2007 charting, and not worth putting up with the problems.)

On the negative side, it’s a gauge. Gauges like this only show one point in time; there’s no historical context, and you can’t tell if your month to date numbers are on target to hit the total per month target. Also, what happens if the value goes to 11? Seriously, there is no provision for an out-of-scale measurement.

I’ve sworn off gauges myself. I’ve removed a speedometer tutorial from my web site, for at least a couple of reasons. First, it is a poor display device, for all the reasons stated above and elsewhere. Second, I would receive too many questions from people who didn’t understand enough math to customize it. It’s algebra and a little trig: find a tenth grader to help, people!

To overcome these issues, I returned to an old standby, the line chart. I use a category value to show days elapsed during the month, and vertical measures of page view targets and measurements. Colored backgrounds are made using stacked columns to provide a bad-medium-good scale across the chart, and dual scales, showing values and percentage of target, decorate the vertical sides of the chart. I also stuck with colors similar to Clint’s. Here is my non-gauge chart:

Line Chart Showing Performance Against Monthly Target

This chart takes up about as much space as Clint’s, but it adds the missing time component. I can visually extrapolate the line forward to the end of the month and estimate whether we’ll hit our target. Since Clint’s chart has some empty space, it can be shrunk; so can the line chart without too much difference in legibility:

Shrunken Line Chart

Through the use of (ahem!) clever formulas, these charts can be made to adapt when the value exceeds the target:

Line Chart Goes to Eleven

When I have a chance to pretty it up, I’ll post a tutorial showing how I created this chart.

]]>
http://peltiertech.com/WordPress/2008/07/18/a-gauge-that-works/feed/
2008 East Coast Excel User Conference http://peltiertech.com/WordPress/2008/07/17/2008-east-coast-excel-user-conference/ http://peltiertech.com/WordPress/2008/07/17/2008-east-coast-excel-user-conference/#comments Thu, 17 Jul 2008 14:10:38 +0000 Jon Peltier http://peltiertech.com/WordPress/?p=150 Come to Atlantic City, New Jersey, on September 24-26, 2008 for the Microsoft Excel User Conference (to be held at the Trump Taj Mahal).

The conference will feature working sessions and classes designed to expand a user’s working knowledge of the dominant spreadsheet software. These sessions will be led by respected leaders in the Microsoft Excel community. Some are respected authors and consultants, and all have the MVP designation - Microsoft Most Valuable Professional (MVP). The Microsoft Office gurus are Bernard Liengme, Damon Longworth, Bob Umlas and myself. I’ll be holding my two charting classes: Advanced Charting Techniques and Excel Charting with VBA.

For information and registration, follow the link below. Register early for a discounted fee.

2008 US East Coast Excel User Conference
Atlantic City, New Jersey - Sept 24-26, 2008
Excel User Conferences Home Page

]]>
http://peltiertech.com/WordPress/2008/07/17/2008-east-coast-excel-user-conference/feed/
Update Regular Chart when Pivot Table Updates http://peltiertech.com/WordPress/2008/07/16/update-regular-chart-when-pivot-table-updates/ http://peltiertech.com/WordPress/2008/07/16/update-regular-chart-when-pivot-table-updates/#comments Thu, 17 Jul 2008 03:23:37 +0000 Jon Peltier http://peltiertech.com/WordPress/?p=153 A reader named Julie has a regular chart that is linked to a pivot table. When the pivot table is pivoted or updated, it may have different numbers of rows and columns, and the chart must be updated manually. Julie asked whether a procedure could be developed to update the chart automatically.

I’ve done this in a number of projects, so I thought I’d illustrate it with a simple example. Let’s start with this dummy data in a list (I’m using Excel 2003).

Pivot Table Source Data

Insert a pivot table using this data. Drag the Item field to the Rows area, the Category field to the Columns area, and the Value field to the Data area. Simple enough.

Pivot Table

Now create a regular chart from this pivot table, using series in columns, one series per item in the Category field, Category entries (alpha and beta) as series names, and the item names as category (X) axis labels.

Regular Chart from Pivot Data

In order to determine which ranges to use for the chart’s source data, it helps to understand what parts of a pivot table are designated as certain ranges. This color coded pivot table illustrates the RowRange, the ColumnRange, the DataBodyRange, and the DataLabelRange. Several of these will be used in the procedure below.

Definitions of Ranges in a Pivot Table

I have set up the macro to put series in columns unless the pivot table DataBodyRange has only one row, in which case there is only one series, and it is plotted by row.

Here is the VBA procedure. Implement it using How To: Use Someone Else’s Macro.

Sub UpdateChartFromPivotTable()
  Dim rValues As Range
  Dim rCats As Range
  Dim rTitles As Range
  Dim cht As Chart
  Dim pt As PivotTable
  Dim chttype As XlChartType
  Dim iSrsIx As Long
  Dim iSrsCt As Long
  Dim iCols As Long
  Dim iRows As Long

  Set cht = ActiveSheet.ChartObjects(1).Chart
  Set pt = ActiveSheet.PivotTables(1)

  Set rValues = pt.DataBodyRange
  On Error Resume Next
  iRows = pt.RowRange.Rows.Count
  iCols = pt.ColumnRange.Columns.Count
  On Error GoTo 0

  If iRows > 0 Then
    Set rCats = Intersect(rValues.EntireRow, pt.RowRange.EntireColumn)
    If iCols > 0 Then
      Set rTitles = Intersect(rValues.EntireColumn, pt.ColumnRange.EntireRow)
      Set rTitles = rTitles.Offset(1).Resize(rTitles.Rows.Count - 1)
    End If
    iSrsCt = rValues.Columns.Count
  ElseIf iCols > 0 Then
    Set rCats = Intersect(rValues.EntireColumn, pt.ColumnRange.EntireRow)
    Set rCats = rCats.Offset(1).Resize(rCats.Rows.Count - 1)
    iSrsCt = rValues.Rows.Count
  Else
    MsgBox "Pivot Table has no fields in Rows area or Columns area.  ", _
        vbCritical + vbOKOnly
    GoTo ExitSub
  End If

  If cht.SeriesCollection.Count > iSrsCt Then
    For iSrsIx = cht.SeriesCollection.Count To iSrsCt + 1 Step -1
      With cht.SeriesCollection(iSrsIx)
        chttype = .ChartType
        .ChartType = xlColumnClustered
        .Delete
      End With
    Next
  ElseIf cht.SeriesCollection.Count < iSrsCt Then
    For iSrsIx = cht.SeriesCollection.Count + 1 To iSrsCt
      cht.SeriesCollection.NewSeries
    Next
  End If

  For iSrsIx = 1 To cht.SeriesCollection.Count
    With cht.SeriesCollection(iSrsIx)
      chttype = .ChartType
      .ChartType = xlColumnClustered
      .XValues = rCats
      If iRows > 0 Then
        .Values = rValues.Columns(iSrsIx)
        If iCols > 0 Then
          .Name = rTitles.Columns(iSrsIx)
        Else
          .Name = "Data"
        End If
      Else
        .Values = rValues.Rows(iSrsIx)
        .Name = "Data"
      End If
      .ChartType = chttype
    End With
  Next

ExitSub:

End Sub

 

Whenever the pivot table changes you can run this procedure to update the chart. To make it run automatically when the pivot table updates, you could put this event procedure into the code module behind the sheet (to open the sheet’s code module, right click the sheet tab, click View Code).

Private Sub Worksheet_Calculate()
  Application.EnableEvents = False

  UpdateChartFromPivotTable

  Application.EnableEvents = True
End Sub

 

This procedure runs every time the worksheet calculates, whether or not the pivot table is involved. To redraw the chart only when mandated by pivot table updates, in Excel 2003 and later you can use this event procedure instead:

Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
  Application.EnableEvents = False

  If Target.Name = Me.PivotTables(1).Name Then
    UpdateChartFromPivotTable
  End If

  Application.EnableEvents = True
End Sub

 

You could further modify the code to update different charts which are based on different pivot tables. Modify the indexes in these lines, instead of using “1″.

  Set cht = ActiveSheet.ChartObjects(1).Chart
  Set pt = ActiveSheet.PivotTables(1)

 

I have run through some permutations of the pivot table and chart:

Pivot Table Regular Chart from Pivot Data

Pivot Table Regular Chart from Pivot Data

 

Pivot Table Regular Chart from Pivot Data

Pivot Table Regular Chart from Pivot Data

 

Pivot Table

Regular Chart from Pivot Data

 

Pivot Table

Regular Chart from Pivot Data

 

]]>
http://peltiertech.com/WordPress/2008/07/16/update-regular-chart-when-pivot-table-updates/feed/
Nice Dashboard Examples http://peltiertech.com/WordPress/2008/07/16/nice-dashboard-examples/ http://peltiertech.com/WordPress/2008/07/16/nice-dashboard-examples/#comments Wed, 16 Jul 2008 16:13:24 +0000 Jon Peltier http://peltiertech.com/WordPress/?p=152 XL Cubed (parent company of BonaVista Systems, maker of the MicroCharts add-in for Excel) has shown some very effective dashboard report examples in a couple of recent posts.

In 2008 Excel Dashboard Competition Winners the winners of the 2008 Excel Dashboard Competition are announced:

1. Wade Stokes – International Bank Dashboard

Displaying many disparate Banking Key Performance Indicators, and designed as the basis for the Management review of business performance, it truly achieves More Information per Pixel.

2. Jim Uden – Outpatient Surgery Center Dashboard

Developed for Meridian Surgical Partners, as a one page snapshot for the review and presentation of partnership level business operations and trends. Jim also includes probably the best associated description of dashboard content and the thought processes involved which we’ve seen.

3. Hitesh Patel – Pharmaceutical Sales Dashboard

Developed by Hitesh Patel and Mike Askew of Data Intelligence, for Bristol Myers Squibb. A key report for the Regional Sales Managers, containing the information required to run the business in terms of cash, growth, share, and competitive performance.

In More Information per Pixel!, they display a very nice report by Professor Rolf Hichert:

Rolf's Dashboard

Rolf very effectively uses the technique of small multiples with sparing colors to highlight high and low performers among a portfolio of organizations.

These MicroCharts guys are really onto something.

]]>
http://peltiertech.com/WordPress/2008/07/16/nice-dashboard-examples/feed/