Volume 3: Programming with the Visio Object Model disclaimer



Download 0.78 Mb.
Page24/36
Date29.01.2017
Size0.78 Mb.
#11974
1   ...   20   21   22   23   24   25   26   27   ...   36

Lab 3.6: Data Graphics


During this lab, you will create a data graphic item to represent a pie chart and then create two data graphics to test the data bar item.

Estimated time to complete this lab: 60 minutes


Before You Begin

To complete this lab, you will need:

  • Participants should have completed the Try This! Sections of this module before completing this lab.

  • Visio 2007 or higher installed and configured.

  • Lab files needed:

    • ScheduleBuilder.vss
What You Will Learn

After completing this lab, you will be able to:

19.Exercise : Create a Pie Chart data graphic item

Scenario


You need to include a pie chart in a data graphic, but the standard data bar items do not include a pie chart. You will have to create a new pie chart data bar data graphic item.

Tasks


  1. Create a new blank drawing.

  2. A basic pie chart shape is needed. You don’t need to create one from scratch because we’ll start with a variation of an existing Visio Pie Chart shape and turn it into a data bar item. It has the basic pie chart features needed. Open the stencil from the Labs folder (from the Shapes window More Shapes > Open Stencil and then traverse to the Labs folder and open ScheduleBuilder.vss.

  3. Drag the New Pie Chart shape to the page. Use the RMA commands to set Number of Slices and Slice Sizes.

This is a modified version of the Pie Chart shape from the Charts and Graphs stencil. It is limited to 5 sections. Enter a value for each slice. The value is “normalized” to be a percentage of the total of the five slices.

Note: The shape is “themed”. Browse through some of the subshapes of the group and look at the FillForegnd cells. They have Theme formulas that reference the different accent colors of the Theme.

  1. Open the ShapeSheet for the Pie Chart group shape. Look at the User-defined section and the Shape Data section. Note that there are Shape Data cells to contain the values for each slice. There are User-defined cells that calculate normalized values for the cells. These User-defined cells are referenced from the group’s subshapes.

  2. Turn this shape into a data bar data graphic item by editing the master in the Document Stencil. Add the User-defined cell User.msvCalloutType. Set its value to “Data Bar”. Close the Master editing window and save the changes.

  3. Check if it worked. In the Data Graphics task pane create a new Data Graphic. Add a new graphic item of type Data Bar. The New Pie Chart shape should show as a new data bar option to choose from.

  4. Now you need to set up the fields that are to be displayed on the data graphic by turning the existing shape data fields into data graphic fields. Edit the New Pie Chart master from the Document Stencil window. Open the ShapeSheet for the New Pie Chart group shape.

    1. In the Shape Data section delete the row Prop.Slices. This will be driven from the data graphic, not by user choice.

    2. Change the name of Prop.Pie1 to Prop.msvCalloutField and set the following column values:

Label=No Formula

Value=0


Invisible=True

    1. Change the name of Prop.Pie2 to Prop.msvCalloutPropField2 and set the following column values:

Prompt=”Field”

Value=0


Invisible=True

    1. Change the name of Prop.Pie3, Prop.Pie4, Prop.Pie5 to msvCalloutPropField3, msvCalloutPropField4, and msvCalloutPropField5 respectively. Set the Prompt, Value, and Invisible fields the same as msvCalloutPropField2.

    2. Delete the Actions section from the ShapeSheet. This is no longer needed.

    3. In the User-defined section delete the row User.Pies. This is no longer needed.

    4. Close the master window and save the changes.

  1. Check if it worked. In the Data Graphics task pane create a new Data Graphic. Choose a Data field. Any field will do for the moment so choose More Fields…>Geometry>Width. Set Displayed as: to be Data Bar. Select the New Pie Chart graphic item. The New Item dialog should look like the following. You should see Pie2 through Pie5 in the Details section and the values are displayed as [Not Used].



  1. Make the new master graphic item hidden. You can create a macro for this or use the Immediate Window in VBA. From the Immediate Window type:

activedocument.Masters("New Pie Chart").Hidden=true

The master can still be seen from the Drawing Explorer window, but not from the Document Stencil.


20.Exercise 2: Test the New Pie Chart data graphic item

Scenario


To test the new graphic item you will link a shape to a row in an external data set and then create a data graphic and apply it to the shape.

Tasks


  1. Choose Data > Link Data to Shapes and choose the file ScheduleBuilder.xls from the Labs folder. Specify the Sections worksheet in the Excel file. The Sections data will appear in the External Data window. Accept all defaults to finish the wizard.

  2. Draw a rectangle on the page and link it to the first row of data. Note that a default data graphic is assigned to the shape.

  3. Choose Data > Data Graphics > Create New Data Graphic . Add a New Item.

  4. Set the Data Field to 9. This is the number of students in grade 9.

  5. Set Displayed as to Data Bar and set the Style to New Pie Chart.

  6. Set the following:

Pie2=10

Pie3=11


Pie4=12

Leave Pie5 unchanged.



  1. Set the callout position of the data graphic item to Center and Middle.

  2. Apply the data graphic to the shape. Does the data graphic appear the right size for the shape? By default it scales to the size of the shape.

  3. From the Drawing Explorer window edit the New Pie Chart master. Open the ShapeSheet and set these formulas into the Width and Height cells.

Width=Guard(0.5 in*DropOnPageScale)

Height=Guard(Width)



  1. Close the master editing window and save the changes.

  2. The data graphic will not update on the shape automatically so apply the None data graphic and then reapply the new data graphic. It should now appear in a fixed size of 0.5 inches.

  3. Rename this data graphic to “DG Pivot”

21.Exercise 3: Add a data bar to the Data Graphic that totals the 9th, 10th, 11th, and 12th grade slots for a class section.

Scenario


Create a new data graphic based on “DG Pivot” and add a data bar item.

Tasks


  1. Create a duplicate of “DG Pivot”. Choose Data > Data Graphics. Right click the data graphic and choose Duplicate.

  2. Rename the new data graphic “DG Section”.

  3. Edit “DG Section”. Add a New Item.

  4. Under Data Fields choose More Fields… and then Custom Formula. In the Custom formula text field enter ={9}+{10}+{11}+{12}

  5. Set the Displayed as field to Data Bar and set the Style to Data Bar 3.

  6. Set the callout position to Right – Bottom.

  7. Set the Maximum value to 35.

  8. Set the Label to “Total”. Close the Data Graphic dialog.

    1. Draw a rectangle

    2. Link it to a row of data

    3. Apply the data graphic

    4. You should see something similar to the image below.



  1. Save the drawing. You will use the data graphics just created in the next module.


Download 0.78 Mb.

Share with your friends:
1   ...   20   21   22   23   24   25   26   27   ...   36




The database is protected by copyright ©ininet.org 2024
send message

    Main page