PTS Blog

Custom Solutions | Commercial Utilities | Training | Charts and Tutorials | PTS Blog

 

Main menu:

 
Peltier Tech
Chart Utilities

PTS Waterfall Chart Utility
PTS Cluster-Stack Column Chart Utility
PTS Box and Whisker Chart Utility
PTS Marimekko Chart Utility

Subscribe

Site search

Subscribe

Site search


Recent Posts

Recently Commented

Popular Posts

Archive


 

Categories


 

Buy me a coffee

If this topic or the whole blog has been helpful, support further development by treating me to a cup of coffee.


Privacy Policy

Creative Commons License
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.

Easier Interactive Multiple Line Chart

by Jon Peltier
Peltier Technical Services, Inc., Copyright © 2009.
Licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.

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

Possibly Related Posts:

Bookmark and share this entry:
  • Digg
  • del.icio.us
  • Facebook
  • Technorati
  • TwitThis
  • StumbleUpon
  • Google Bookmarks
  • Reddit
  • MySpace
  • Slashdot
  • LinkedIn
  • Yahoo! Buzz

Learn how to create Excel dashboards.

Comments


Comment from Alvaro Ledesma
Time: Wednesday, July 23, 2008, 11:59 am

Jon, in the “by row” example, the listbox format window shows as cell link “TheSelection” and the offset formula to capture the selected row data uses “TheSelected”.

Regards

Alvaro


Comment from Alvaro Ledesma
Time: Wednesday, July 23, 2008, 12:06 pm

Jon, I am a bit curious: I am learnig about “keep it at the minimum” reading you, the guys at microchart and others in the field. With that in mind I really like tha idea of keeping, let’s say, 5 or 6 series in gray and the one being analized in color… it gives you a quick overview and provides background, reference and very brief “ranking” idea to begin with.

However, in your example, the gray lines are too many, so the only purpose I can see is a “background” based on data, with no analytical value (or very little value at most). Am I missing something?

Regards

Alvaro


Comment from Jon Peltier
Time: Wednesday, July 23, 2008, 12:14 pm

Alvaro -

Oops! Thanks for pointing out my mistake. Both should be “TheSelection”. I’ve made the correction.


Comment from Jon Peltier
Time: Wednesday, July 23, 2008, 12:18 pm

Alvaro - “Do as I say, don’t do as I do.”

In hindsight, I should have taken more time to find or create a better sample data set. Or I could have made this example with only three or four series instead of a dozen. Perhaps when I get a chance I should rewrite these examples with better illustrative data.


Comment from Colin Banfield
Time: Thursday, July 24, 2008, 6:34 pm

Alvaro’s got a point - I was thinking the same thing when I read your original post. Incidentally, the Few article you mentioned shows an equally indecipherable background - a real distraction when you consider the efforts one take to tone down or eliminate gridlines. Now, there’s actually one useful application for such a jumble, and that is to filter out all but a few selected series for comparison!


Pingback from The Missing Link (Part 1) | More Information per Pixel
Time: Monday, July 28, 2008, 10:22 am

[...] Peltier showed us in recent posts techniques to dynamically provide details in Excel in the form of a detail chart. The problem with [...]

Write a comment

I welcome comments from my readers. If you have an opinion on this post, if you have a question or if there is anything to add, I want to hear from you. Whether you agree or disagree, please join the discussion.

If you want to include an image in your comment, post it on your own site or on one of the many free image sharing sites, and include a link in your comment. I'll download your image and insert the necessary html to display the image inline.

Read the PTS Blog Comment Policy.





Subscribe without commenting

PTS Waterfall Chart Utility PTS Cluster-Stack Column Chart Utility PTS Box and Whisker Chart Utility PTS Marimekko Chart Utility

Create Excel dashboards quickly with Plug-N-Play reports.