GET.CHART.ITEM XLM Function

Microsoft's macrofun.hlp file documents the XLM function GET.CHART.ITEM, which is useful for finding the vertical and horizontal positions for selected chart items. This function is further explained in Professional Excel Development.

From Microsoft's macrofun.hlp, below is the documentation for GET.CHART.ITEM:

GET.CHART.ITEM returns the vertical or horizontal position of a point on a chart item. Use these position numbers with FORMAT.MOVE and FORMAT.SIZE to change the position and size of chart items. Position is measured in points; a point is 1/72nd of an inch.

Syntax

GET.CHART.ITEM(x_y_index, point_index, item_text)

X_Y_index is a number specifying which of the coordinates you want returned.

X_Y_index Coordinate returned:

  • 1 - Horizontal coordinate.
  • 2 - Vertical coordinate.

Point_index is a number specifying the point on the chart item. These indexes are described later. If point_index is omitted, it is assumed to be 1. If the specified item is a point, point_index must be 1. If the specified item is any line other than a data line, use the following values for point_index.

Point_index and Chart item position:

  • 1 - Lower or left.
  • 2 - Upper or right.

If the selected item is a legend, plot area, chart area, or an area in an area chart, use the following values for point_index.

Point_index and Chart item position:

  • 1 - Upper left.
  • 2 - Upper middle.
  • 3 - Upper right.
  • 4 - Right middle.
  • 5 - Lower right.
  • 6 - Lower middle.
  • 7 - Lower left.
  • 8 - Left middle.

If the selected item is an arrow in Microsoft Excel 4.0, use the following values for point_index. In Microsoft Excel 5.0, arrows are named lines, and the arrowhead position returned is equivalent to the end of a line where the arrowhead begins.

Point_index and Chart item position:

  • 1 - Arrow shaft.
  • 2 - Arrowhead.

If the selected item is a pie slice, use the following values for point_index.

Point_index and Chart item position:

  • 1 - Outermost counterclockwise point.
  • 2 - Outer center point.
  • 3 - Outermost clockwise point.
  • 4 - Midpoint of the most clockwise radius.
  • 5 - Center point.
  • 6 - Midpoint of the most counterclockwise radius.

Item_text is a selection code that specifies which item of a chart to select. See the chart form of SELECT for the item_text codes to use for each item of a chart.

If item_text is omitted, it is assumed to be the currently selected item.

If item_text is omitted and no item is selected, GET.CHART.ITEM returns the #VALUE! error value.

Remarks

If the specified item does not exist, or if a chart is not active when the function is carried out, the #VALUE! error value is returned.

Examples

The following macro formulas return the horizontal and vertical locations, respectively, of the top of the main-chart value axis:

GET.CHART.ITEM(1, 2, "Axis 1")

GET.CHART.ITEM(2, 2, "Axis 1")

You could then use FORMAT.MOVE to move a floating text item to the position returned by these two formulas.

Posted on June 24, 2007 | Filed under: Charts | Comments (5) | Permalink
Page 1 of 1 pages

Comments

Have you tried this in Excel 2007 yet? I haven’t, because I’ve never really used it much.

Posted by Jon Peltier  on  06/24  at  06:04 AM

Hi Jon,

I’ve not tested it in Excel 2007 yet as I’ve really not used it very much either.  I do think it’s an interesting function though.  I think it’s a good charting function to at least be aware of in case the need ever does occur.   

John Mansfield

Posted by John Mansfield  on  06/24  at  07:01 PM

In Professional Excel Development, Stephen Bullen shows how to use it to determine where an arrow’s endpoint should be to touch the corner of a column in a column chart. I use VBA that calculates the coordinates using the number of categories, the number of series, the gap width and overlap. It feels somehow “nicer” to use VBA, but the XLM is so much faster.

Posted by Jon Peltier  on  06/24  at  08:58 PM

I use this code to find the location to draw a circle around a spceific point on a scatter chart.

Posted by .(JavaScript must be enabled to view this email address)  on  04/22  at  06:32 AM

This is the Microsoft macrofun.hlp documentation for the Excel 4 XLM function SELECT which lists the values that can be used in the GET.CHART.ITEM item_text parameter.

SELECT (Syntax 3)

Selects a chart object as specified by the selection code item_text. There are three syntax forms of SELECT. Use syntax 3 to select a chart item to which you want to apply formatting; use one of the other syntax forms to select cells or objects on a worksheet or macro sheet.

Syntax

SELECT(item_text, single_point)

item_text  is a selection code from the following table which specifies which chart object to select.

item_text       To select

“Chart”          Entire chart  
“Plot”          Plot area  
“Legend”        Legend  
“Axis 1”        Primary chart value axis  
“Axis 2”        Primary chart category axis  
“Axis 3”        Secondary chart value axis or 3-D series axis  
“Axis 4”        Secondary chart category axis  
“Title”          Chart title  
“Text Axis 1”      Label for the primary chart value axis  
“Text Axis 2”      Label for the primary chart category axis  
“Text Axis 3”      Label for the primary chart series axis  
“Text n”        nth floating text item  
“Arrow n”        nth arrow  
“Gridline 1”      Major gridlines of value axis  
“Gridline 2”      Minor gridlines of value axis  
“Gridline 3”      Major gridlines of category axis  
“Gridline 4”      Minor gridlines of category axis  
“Gridline 5”      Major gridlines of series axis  
“Gridline 6”      Minor gridlines of series axis  
             
“Dropline 1”      Primary chart droplines  
“Dropline 2”      Secondary chart droplines  
“Hiloline 1”      Primary chart hi-lo lines  
“Hiloline 2”      Secondary chart hi-lo lines  
“UpBar1”        Primary chart up bar  
“UpBar2”        Secondary chart up bar  
“DownBar1”        Primary chart down bar  
“DownBar2”        Secondary chart down bar  
“Seriesline1”      Primary chart series line  
“Seriesline2”      Secondary chart series line  
“Sn”            Entire series  
“SnPm”          Data associated with point m in series n if single_point is TRUE  
“Text SnPm”      Text attached to point m of series n  
“Text Sn”        Series title text of series n of an area chart  
“Floor”          Base of a 3-D chart  
“Walls”          Back of a 3-D chart  
“Corners”        Corners of a 3-D chart  
             
“SnTm”          Trend line  
“SnEm”          Error bars  
“Legend Marker n”  Legend Marker  
“Legend Entry n”    Legend Entry  

For trend lines and error bars, the value m can be X or Y, depending on which point you want to select. If m is blank, selects both.

single_point is a logical value that determines whether to select a single point. Single_point is available only when item_text is “SnPm”.

* If single_point is TRUE, Microsoft Excel selects a single point.
* If single_point is FALSE or omitted, Microsoft Excel selects a single point if there is only one series in the chart or selects the entire series if there is more than one series in the chart.
* If you specify single_point when item_text is any value other than “SnPm”, SELECT returns an error value.

Examples

SELECT(“Chart”) selects the entire chart.
SELECT(“Dropline 2”) selects the droplines of an overlay chart.
SELECT(“S1P3”, TRUE) selects the third point in the first series.
SELECT(“Text S1”) selects the series title text of the first series in an area chart.

Posted by .(JavaScript must be enabled to view this email address)  on  04/23  at  07:03 AM
Page 1 of 1 pages

Comment Entry

Name:

Email:

Location:

URL:

Remember my personal information

Notify me of follow-up comments?

Statistics

  • Total Entries - 136
  • Current Viewers - 27

Categories

Entries by Day

Sep - 2010
S M T W T F S
29 30 31 1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 1 2

Recent Comments

Syndicate