Friday, February 28, 2014

Creating a Simple Pie Chart

To work with the pie chart, create a new, blank report and call it “Chapter5Report2”.

Step 1: Create a pie chart report

Add a Chart.Pie element to the Body element in the report, and set the Chart Title attribute to a meaningful description (i.e. “Top 10 Customers”). An ID is not required for a chart.

Figure 5.11: Definition Editor Panel after adding Chart element

Step 2: Define the table data layer

Every Chart.Pie element requires a child DataLayer element. In this example, we’ll add a DataLayer.SQL element. 

Figure 5.12: Definition Editor Panel after adding DataLayer element

In this example, set the Connection ID to “connNorthwind” and use the following SQL query as the Source:

SELECT TOP 10 CustomerID, COUNT(CustomerID) AS OrderCount
FROM Orders
GROUP BY CustomerID
ORDER BY COUNT(CustomerID) DESC

This SQL query creates a summary of the top 10 customers in the database based on number of orders. 

Step 3: Define the column to display on the x-axis and y-axis

Set the Data Column Y-axis attribute to display the “OrderCount” column data and set the Label Column X-axis attribute to display the “CustomerID” column data. 


Figure 5.13: Attributes Panel after setting initial Chart element attributes   

Step 4: Format the pie chart report

All that remains is to format the chart. In most cases, the default formatting is not accepta-ble. In the example below, the following presentation attributes are changed:
  • Set the Height and Width attributes to display a 400 X 400 chart.
  • Set the 3-Dimensional property to a value of “8” to control the depth of the pie.  
  • Set the Top Border and Left Border attributes to provide room for the title and axis labels. 
Figure 5.14: Attributes Panel after setting Chart element attributes 
The resulting pie chart is presented as shown below.

Figure 5.15: The Pie Chart example 

No comments:

Post a Comment