[ABC home]    [ABC Archives by Issue]   [ABC Archives by Author]  [Search]  [Privacy]

 

ABC Home Page
ABC Home

 

Advertise in ABC

 

Learn more
about
Ray Blake
Ray Blake

Read
Ray's Archives

Ray's Archives

Ray's
Website
Ray's Website, GR Business Process Solutions

 

 

ABC ~ All 'Bout Computers
The Online Web-azine for Computer Enthusiasts
-- brought to you by
Visit Linda's Computer Stop

contents page for this issue

Highlighting a Single Data Point in an Excel Chart
~~Ray Blake,
GR Business Process Solutions

Excel’s charting tools are quite comprehensive, but I’ve written before (see my archived articles) about some notable omissions in functionality. One of those is less control than a user might like over the colour of individual data points. It is possible to set the colour for an entire data series, or to set the colour to vary by point. The charts below illustrate these options:

entire data series the same color color varied by point

This choice is controlled through the Format Data Series dialog, as below:

Format Data Series dialog box

At first, I thought I’d be able to make progress with VBA, but it is not possible to change the colour of a single data point, even from VBA code, when you want the colour to change based on the data that produces that column.

It’s time perhaps to explain why I wanted to be able to highlight just one point. Let’s do it by looking at the data on which the example charts above are based.

data the chart is based on

It concerns a multiple choice test based on 4 questions, each with 4 possible answers (A, B, C, D) only one of which is correct.  Column C indicates which option is correct and columns D-G show what percentage of the test candidates selected each option.

oroginal chartWhen charting these numbers, I wanted a way of highlighting which option was the right answer. Consider the chart we saw at the top of this article, shown again to the left.

It relates to question 1 in the data table, of course, and the right answer is B.
The data source for this table is D3:G4, which includes both the axis labels in row 3 and the actual chart values for the series in row 4. The other charts for questions 2-4 are based on ranges which include rows 3 for the axis labels and respectively 5, 6 and 7 for the series data.

Given that B is the right answer, the chart shows a test question performing very well, for a number of reasons. It shows:

  • The majority of candidates are getting it right (so it’s not too hard)

  • Not all candidates are getting it right (so it’s not too easy)

  • Candidates are choosing all 3 of the wrong answers, which we call ‘distractors’ (so all the distractors are to some extent credible and candidates cannot get the answer right just by eliminating obviously false alternatives.)

It is easy to come to these conclusions simply from the chart, but only if you know the right answer is B. Look at the chart again and consider how the story it tells is different if the right answer were actually A.

Hopefully, you can see why I was so keen to highlight on the chart one data point.

A method which my business partner, Graham Barrow, suggested is to provide a text key. A little-known ability of Excel charts is to link the title or other text box in the chart to an Excel cell value. You can’t actually get it to calculate a formula, but you can get it to show the content of a given cell. Here is how I implemented this idea on my chart.

chart showing text at the top

What looks like a single text box at the top of the chart is actually 2. The one on the right is the title box and here simply says ‘B’. It’s linked to cell C4, so if the data changes, it will change too.  Immediately to the left is another text box which just contains the text "Correct answer:"

To link the right hand text box to the cell, I simply went to the chart options and said I wanted title text (I typed a few letters of nonsense into the box, just to get something on the chart.)

"xyz" added as chart title

Then, with the title box selected, I entered the cell reference in the formula bar:

cell reference added to title

After that, it was simply a matter of inserting another text box in the chart area, and matching its font and style to the chart title box.

This was a good solution, and in a mono printing situation would probably be preferable to varying the bar colour in any case. But I just couldn’t walk away from the challenge of recolouring just a single data point, so I worked on and eventually cracked the problem.

It actually turned out to be very easy, although very sneaky, and required no VBA at all.

Here’s what I did.

First, I realised I would need to extend the data table to create a second data series for each line. I did this by inserting a row below each line of data, thus:

added rows to the data

The formula I entered in cell D5 was: =IF(D$3=$C4,D4,0)
I dragged this across cells E5, F5 and G5. The result is shown below:

You can see in row 5 that the value for the right answer is carried down and all the others are given as zero. This row of cells will be a second series which we will chart on top of the first.

Through setting the references as relative in the formula (all those $ signs are carefully placed!) I was able to copy and paste this single formula into all the new cells without amendment, not only in Row 5, but also in the 3 new rows below. Note that I can hide these rows if I want to, or turn the text colour to white. It won’t affect this chart technique if I do.

Now, I turned to the chart to make some amendments.

First, I selected my original chart and viewed its source data (available from the right-click menu of the chart area). Currently, you’ll recall that the source data is based on the range D3:G4. Row 3 contains the axis labels – A, B, C and D. Row 4 contains the data we want to chart – how many candidates chose each option.

Here is the source data dialog as it stood initially:

original source data

What I did was to extend the data range so as to include the third row, row 5:

updated source data

Notice that the second series is now showing in the preview, but that because 3 of the four values are zero, only the correct option has any bar showing. I clicked OK.

Then, I double-clicked on any of the data bars to get this dialog:
Note that the ‘overlap’ value is set to zero. I’m going to change this.

overlap value

Now look what happens when I increase the Overlap to 100%:

overlap value increased to 100%

And that’s it!
Returning to my worksheet, I appeared now to have done the impossible: created a chart with just a single data point highlighted a different colour. Of course, I created new charts for the other 3 data sets, too. Look at the four of them below, and see of you agree that colouring the right answer makes a visual analysis easier:

four charts showing different answers where colors update automatically

Ray Blake lives in England and spent 15 years training people in the financial services industry there. He had always used PCs in his work, and gradually realized he might make a career out of them. He and his business partner set up GR Business Process Solutions (www.grbps.com) which specializes in innovative IT to support knowledge testing and skills assessment. Although he spends a lot of time these days developing in VB and Access, Excel remains his favorite development tool, because, as he says, 'It can do everything; there's no computer application you can think of that you couldn't develop in Excel.'

 


 Support ABC

 

Linda's Ebooks
Ebooks on Access, Excel, Outlook, PowerPoint, Publisher, and Word

Linda's CD
Order Linda's CD and learn all of the Office programs

The Newbie Club
Learn all about computers the easy way

Online classes
at Eclectic Academy
 Instructor led online courses at Eclectic Academy

My Newest Book
Excel 2003 Study Guide

published by Wiley
get it at Amazon,
at Barnes & Noble,
or at Borders

FrontLook
Add-ins
& Screen Capture

Great FrontPage addins and other software

WinBackup
SpeedUpMyPC
WinTasks5Pro

great Windows utilities


 

 

 Privacy Policy, Disclaimer, and Legal Stuff
This page was last updated on Monday, December 31, 2007 . copyright © 2000 - 2008, Linda F. Johnson, Linda's Computer Stop, ABC ~ All 'Bout Computers. All rights reserved.
[SEARCH THIS SITE]