The Chart Sheet Interface

This chapter teaches you how to program Excel's Chart object so the interface for the project is built from a chart. Specifically, a chart sheet consisting of a bubble chart will serve to display the images.

The requirements state that the game must involve a 10 by 10 grid of 100 images. To satisfy this requirement I will create the chart from ten data sets consisting of ten x,y-value pairs. The data is charted as ten different series in the chart. Each data set must use the same set of values for the x-axis variable to ensure vertical alignment of the images (for example, if x=2 for one element in each series, then their corresponding data markers are vertically aligned across the y-axis). In addition, the values for the x-axis variable must have a uniform increment for homogeneous spacing of the images. To ensure the images are aligned horizontally the y-values must be equivalent within a data series (for example, if y=2 for every element in a series, then the corresponding data markers are aligned horizontally across the x-axis), and the difference in the y-values between data series must also be uniform. The magnitude of the numbers doesn't really matter since the data is static, but I will keep it simple and use 0-9 for the x-axis variable, and 0-9 for the y-axis series (that is, the first y-axis data series is all 0's, the second is all 1's, and so on). The third variable in a bubble chart is expressed by the size of the data marker. I don't need this variable, but I need it to be identical for all data points such that the images are uniform in size. Figure 9.13 shows the chart sheet interface for the Alienated Game and how the chart sheet appears before any images are added to the data markers. Note that I formatted the chart to include a background image simulating a starry night sky.

As can be seen in Figure 9.13 a new game is started from the click of a button. The button must come from the Forms toolbar because you cannot place ActiveX controls on a chart sheet. The button is assigned to a public VBA procedure that initializes the chart with new images and clears the score so a new game can begin.

Displaying the score and help messages to the user is a bit more difficult than usual. In previous projects, I have used merged cells or Label controls to display text, but neither of these options is available with a chart sheet. The best way to display text on a chart is to use the axis and chart titles—that's what you see in Figure 9.13.

The Alienated Game chart sheet interface prior to filling the markers with images.

The Alienated Game chart sheet interface prior to filling the markers with images.

Refedit Excel
|tfjiT^ For a more advanced version of the Alienated Game, check out the ALienated_ Embedded.xls project on the Book's CD-ROM. This version of the game uses an embedded chart for the user interface; so a class module is required to enable the event procedures of the Chart object.
Biorhythm Awareness

Biorhythm Awareness

Who else wants to take advantage of biorhythm awareness to avoid premature death, escape life threatening diseases, eliminate most of your life altering mistakes and banish catastrophic events from your life.

Get My Free Ebook


Post a comment