圖表 (報表產生器及 SSRS)Charts (Report Builder and SSRS)

閱讀有關使用圖表資料區域的詳細資訊,以協助您的 Reporting ServicesReporting Services 分頁報表讀者一眼便了解大量的彙總資料。Read about using chart data regions to help readers of your Reporting ServicesReporting Services paginated reports understand large volumes of aggregated data at a glance.

您在建立圖表之前花越多時間仔細準備及了解您的資料,便越容易迅速而有效率地設計圖表。The more time you spend carefully preparing and understanding your data before you create a chart, the easier it will be to design your charts quickly and efficiently. 如需協助選擇要使用哪一個圖表,請參閱圖表類型要立即開始使用圖表來實驗,請參閱報表產生器教學課程中的列、資料行、走勢圖和圓形圖教學課程。For help choosing which chart to use, see Chart Types To start experimenting with charts immediately, see the bar, column, sparkline, and pie chart tutorials in Report Builder Tutorials.

下圖顯示圖表中使用的許多不同元素。The following illustration shows many of the different elements used in the chart.

圖表項目圖Chart elements diagram

您可以與報表分開發行圖表,作為「報表組件」。You can publish charts separately from a report as report parts. 如需詳細資訊,請參閱報表組件For more information, see Report Parts.

設計圖表Designing a Chart

將圖表資料區加入至設計介面之後,您可以將數值和非數值資料的報表資料集欄位拖曳到圖表的 [圖表資料] 窗格。After you add a chart data region to the design surface, you can drag report dataset fields for numeric and non-numeric data to the Chart Data pane of the chart. 當您在設計介面按一下圖表時,[圖表資料] 窗格隨即出現,其中包含三個區域:[類別目錄群組]、[數列群組] 和 [值]。When you click the chart on the design surface, the Chart Data pane appears, with three areas—Category Groups, Series Groups, and Values. 如果報表有共用或內嵌資料集,資料集中的欄位會出現在 [報表資料] 窗格中。If the report has a shared or embedded dataset, the fields in the dataset appear in the Report Data pane. 將欄位從資料集拖曳至 [圖表資料] 窗格的適當區域中。Drag fields from the dataset into the appropriate area of the Chart Data pane. 根據預設,當欄位加入到圖表的其中一個區域時, Reporting ServicesReporting Services 會計算該欄位的彙總。By default, when a field is added to one of the areas of the chart, Reporting ServicesReporting Services calculates an aggregate for the field. 您也可以使用數列群組動態產生數列。You can also use series grouping to dynamically generate series. 圖表的組織類似矩陣A chart is organized like a matrix.

rs_chartwSeriesCategoriesrs_chartwSeriesCategories

注意

圖表在設計階段的資料與圖表在報表處理時的資料不同。The data in the chart at design time is different from the data in the chart when the report is processed. 它不是您實際的資料。It is not your real data. 它會產生已經加入的資料,讓您可以利用圖表外觀的概念,設計您的圖表。It is generated data that has been added so that you can design your chart with an idea of what the chart will look like.

圖表與矩陣的相似處How a Chart is like a Matrix

考慮圖表如何運作的其中一種方法是比較圖表與矩陣。One way to think about how charts work is to compare them to matrices.

從工具箱新增選取的新矩陣New Matrix added from Toolbox, selected

在概念上,組織是相同的:Conceptually, their organization is identical:

  • 矩陣中的 [資料行] 群組與圖表中的 [類別目錄群組] 區域類似。The Columns group in the matrix is like the Category Groups area in the chart.

  • 矩陣中的 [資料列] 群組與圖表中的 [數列群組] 區域類似。The Rows group in the matrix is like the Series Groups area in the chart.

  • 矩陣中的 [資料] 區域與圖表中的 [值] 區域類似。The Data area in the matrix is like the Values area in the chart.

將資料加入到圖表中Adding Data to the Chart

假設您所擁有的報表會依名稱顯示銷售額。Suppose you have a report that shows Sales by Name. 您會將 Full Name 欄位放到 [類別目錄群組] 區域,並將 Sales 欄位放到 [值] 區域。You drop the Full Name field to the Category Groups area and the Sales field to the Values area.

當您將 Sales 欄位加入到 [值] 區域時,資料欄位的文字會出現在圖例中,而此數值欄位中的資料將會彙總為一個值。When you add the Sales field to the Values area, the text of the data field appears in the legend, and the data from this numeric field will be aggregated into one value. 根據預設,此值會使用內建函數 Sum 進行彙總。By default, the value is aggregated using the built-in function Sum. [圖表資料] 窗格將會包含一個適用於您欄位的簡單運算式。The Chart Data pane will contain a simple expression for your field. 在範例中,欄位運算式 [Sum(Sales)]=Sum(Fields!Sales.Value)將會出現。In our example, [Sum(Sales)] will appear for the field expression =Sum(Fields!Sales.Value). 如果沒有指定任何群組,圖表僅會顯示一個資料點。If no groups are specified, the chart will only show one data point. 若要顯示多個資料點,您必須加入群組欄位來為資料分組。In order to show multiple data points, you must group your data by adding a grouping field. 當您將 Name 欄位加入到 [類別目錄群組] 區域時,與欄位名稱相同名稱的群組欄位會自動加入到圖表中。When you add the Name field to the Category Groups area, a grouping field of the same name as the name of the field is automatically added to the chart. 加入定義 x 和 y 軸之值的欄位時,圖表擁有足夠的資訊可以正確繪製資料。When fields that define the values along the x and y axes are added, the chart has enough information to plot the data correctly.

rs_chartwNoSeriesrs_chartwNoSeries

當 [數列群組] 區域留空時,數列的數目會在設計階段修正。When the Series Groups area is left empty, the number of series is fixed at design time. 在此範例中,銷售額是出現在圖表上的唯一數列。In this example, Sales is the only series that appears on the chart.

圖表中的類別目錄和數列群組Category and Series Groups in a Chart

圖表支援巢狀類別目錄和數列群組。A chart supports nested category and series groups. 圖表不會顯示詳細資料。Charts do not display detail data. 將資料集欄位拖曳到所選圖表的類別目錄和數列放置區,藉以在圖表中加入群組。Add groups to a chart by dragging dataset fields to the category and series drop zones for a selected chart.

圓形圖之類的形狀圖支援類別目錄群組和巢狀類別目錄群組。Shape charts such as pie charts support category groups and nested category groups. 長條圖之類的其他圖表支援類別目錄群組和數列群組。Other charts such as bar charts support category groups and series groups. 您可以建立巢狀群組,但是必須確定類別目錄或數列的數目不會遮住圖表中相關資訊的呈現。You can nest groups, but make sure that the numbers of categories or series do not obscure the presentation of information in the chart.

將數列群組加入至圖表Adding Series Grouping to a Chart

如果您將某個欄位加入到 [數列群組] 區域,數列的數目則視該欄位中包含的資料而定。If you add a field to the Series Groups area, the number of series depends on the data that is contained in that field. 在先前的範例中,假設您將 Year 欄位加入到 [數列群組] 區域。In our earlier example, suppose you add a Year field to the Series Groups area. 在 Year 欄位中,值的數目將會決定有多少數列會出現在圖表上。The number of values in the Year field will determine how many series will appear on the chart. 如果 Year 欄位包含 2004、2005 和 2006 年,圖表將會在 [值] 區域中,為每個欄位顯示三個數列。If the Year field contains the years 2004, 2005, and 2006, the chart will display three series for every field in the Values area.

建立圖表前的資料集考量Dataset Considerations Before Creating a Chart

圖表提供資料的摘要檢視。Charts provide a summary view of your data. 不過,資料集如果很大,則圖表上的資訊可能會變得不易辨認或無法判讀。However, with large datasets, the information on a chart can become obscured or unreadable. 資料點遺失或為 Null、資料類型不適於圖表類型,以及將圖表與資料表結合等進階應用,都可能會影響圖表的可讀性。Missing or null data points, data types ill-suited to the type of chart, and advanced applications such as combining charts with tables can all affect the readability of a chart. 您應該在設計圖表之前小心地準備及了解資料,如此就可以快速而有效地設計圖表。Before designing a chart, you should carefully prepare and understand your data so that you can design your charts quickly and efficiently.

報表中的圖表數可依您的需要而定。You can have as many charts in your report as you want. 圖表會繫結至單一資料集,這與矩陣或資料表等任何其他資料區類似。A chart, like any other data region such as a matrix or table, is bound to a single dataset. 如果您想要在同一圖表上顯示多個資料集,可以在 SQL 查詢中使用 JOIN 或 UNION 陳述式建立其他資料集,然後再將資料加入到圖表。If you want to display multiple datasets on the same chart, you can create an additional dataset that uses a JOIN or UNION statement in your SQL query before adding data to the chart. 如需有關 JOIN 和 UNION 陳述式的詳細資訊,請參閱《線上叢書》或其他 SQL 參考資訊。For more information about the JOIN and UNION statement, see Books Online or another SQL reference.

如果詳細資料沒有必要或沒有用處,請考慮在資料集查詢中預先彙總資料。Consider pre-aggregating data in the dataset query if detail data is not necessary or useful. 若要更清楚地顯示每個資料點,請減少資料集中的類別目錄數目。To display each data point more clearly, reduce the number of categories in your dataset. 您可以篩選資料集或將條件加入至查詢,以減少傳回的資料列數目。You can filter the dataset or add a condition to your query that reduces the number of rows returned.

在圖表中顯示資料的最佳作法Best Practices When Displaying Data in a Chart

當顯示的元素數目能以清楚的影像顯示基礎資訊時,圖表最為有效。Charts are most effective when the number of elements that are displayed presents a clear image of the underlying information. 有些圖表 (例如散佈圖) 的資料點數越多越好,有些圖表 (例如圓形圖) 則在資料點較少時比較有效。Some charts, like scatter graphs, benefit from numerous data points, while others, like pie charts, are more effective with fewer data points. 根據資料集中的值,小心地選擇圖表類型以及您想要以何種方式顯示這項資訊。Choose a chart type carefully based on the values in your dataset and how you want this information to be shown. 如需詳細資訊,請參閱 圖表類型 (報表產生器及 SSRS)For more information, see Chart Types (Report Builder and SSRS).

您可以使用數種方法來合併圖表上的資料:There are several ways you can consolidate data on a chart:

  • 在使用圓形圖時,將小扇區收集成稱為「其他」的單一扇區。When using a pie chart, collect small slices into one slice called "Other." 這樣可以減少圓形圖上的扇區數目。This will reduce the number of slices on your pie chart. 如需詳細資訊,請參閱 收集圓形圖上的小配量 (報表產生器及 SSRS)For more information, see Collect Small Slices on a Pie Chart (Report Builder and SSRS).

  • 請避免在資料點很多時使用資料點標籤。Avoid using data point labels when there are numerous data points. 資料點標籤在圖表上只有幾個點時最有效。Data point labels are most effective when there are only a few points on the chart.

  • 請篩選不想要或不相關的資料。Filter unwanted or irrelevant data. 這樣有助於強調您想要在圖表上顯示的關鍵資料。This helps you highlight the key data that you are trying to show on the chart. 若要篩選圖表中的資料點,請針對類別目錄群組或數列群組設定篩選。To filter data points in a chart, set a filter on a category group or a series group. 依預設,圖表會使用內建函數 Sum,將屬於相同群組的值彙總成數列中的個別資料點。By default, the chart uses the built-in function Sum to aggregate values that belong to the same group into an individual data point in the series. 如果您變更數列的彙總函式,則必須同樣變更篩選運算式中的彙總函式。If you change the aggregate function of a series, you must also change the aggregate function in the filter expression. 如需詳細資訊,請參閱 篩選、分組和排序資料 (報表產生器及 SSRS)(將互動式排序加入資料表或矩陣 (報表產生器及 SSRS))。For more information, see Filter, Group, and Sort Data (Report Builder and SSRS).

  • 若要在資料表或矩陣範本中顯示比例資料,請考慮使用線性量測計,而不要使用橫條圖。To display ratio data in a table or matrix template, consider using a linear gauge instead of a bar graph. 量測計較適合用來顯示資料格內的單一值。Gauges are better suited for showing a single value inside a cell. 如需詳細資訊,請參閱 巢狀資料區 (報表產生器及 SSRS)For more information, see Nested Data Regions (Report Builder and SSRS).

從圖表的資料欄位彙總值Aggregating Values from a Data Field on the Chart

根據預設,當欄位加入到圖表的 [值] 區域時, Reporting ServicesReporting Services 會計算該欄位的彙總。By default, when a field is added to the Values area of the chart, Reporting ServicesReporting Services calculates an aggregate for the field. 如果您將某個欄位拖曳到圖表上,而不將該欄位放到特定的區域中,該圖表將會根據欄位的資料類型,判斷此欄位屬於類別目錄 (x) 軸或值 (y) 軸。If you drag a field onto the chart without dropping the field into a specific area, the chart will determine whether this field belongs on the category (x) axis or value (y) axis based on the data type of the field. 放在 [值] 區域的數值欄位會使用 SUM 函數進行彙總。Numeric fields that are dropped in the Values area are aggregated using the SUM function. 如果值欄位的資料類型在 [值] 區域中為字串,即使欄位中有數字,圖表也無法顯示數值,因此圖表會顯示 COUNT 函數。If the data type of your value field is String in the Values area, the chart cannot display a numeric value, even if there are numbers in the fields, so the chart displays the COUNT function. 若要避免發生這個問題,請確定您使用的欄位具有數值資料類型,而不是包含格式化數字的字串。To avoid this behavior, make sure that the fields that you use have numeric data types, instead of Strings that contain formatted numbers. 您可以使用 Visual Basic 運算式,利用 CDblCInt 常數將 [字串] 值轉換為數值資料類型。You can use a Visual Basic expression to convert String values to a numeric data type using the CDbl or CInt constant. 例如,下列複雜運算式會轉換包含格式化為字串之數值的 MyField 欄位。For example, the following complex expression converts a field that is named MyField that contains numeric values that are formatted as Strings.

=Sum(CDbl(Fields!MyField.Value))

如需彙總運算式的詳細資訊,請參閱彙總函式參考 (報表產生器及 SSRS)For more information about aggregate expressions, see Aggregate Functions Reference (Report Builder and SSRS).

本節內容In This Section

將圖表加入至報表 (報表產生器及 SSRS)Add a Chart to a Report (Report Builder and SSRS)
描述將圖表加入至報表的第一個步驟。Describes the first steps in adding a chart to your report.

圖表類型 (報表產生器及 SSRS)Chart Types (Report Builder and SSRS)
描述 Reporting ServicesReporting Services提供的所有圖表類型及圖表子類型,包括使用各種圖表類型時的考量及最佳作法。Describes all of the chart types and sub-types available in Reporting ServicesReporting Services, including considerations and best practices for using various chart types.

格式化圖表 (報表產生器及 SSRS)Formatting a Chart (Report Builder and SSRS)
使用來改善整體外觀,並反白顯示圖表的關鍵資料點。Use formatting to improve the overall appearance and highlight key data points of your chart.

圖表中的空白和 Null 資料點 (報表產生器及 SSRS)Empty and Null Data Points in Charts (Report Builder and SSRS)
描述根據包含空白或 Null 值使用圖表時的考量。Describes considerations when working with charts based on fields with empty or null values.

將包含多個資料範圍的數列顯示在圖表上 (報表產生器及 SSRS)Displaying a Series with Multiple Data Ranges on a Chart (Report Builder and SSRS)
描述如何將刻度分欄加入到包含一個以上資料範圍的數列中。Describes how to add scale breaks to a series that contains more than one range of data.

圖表上的多個數列 (報表產生器及 SSRS)Multiple Series on a Chart (Report Builder and SSRS)
描述在相同圖表上顯示多個數列的數個方法,包括結合圖表類型、使用副座標軸、指定不同的圖表類型,以及使用多個圖表區域。Describes several methods of showing multiple series on the same chart, including combining chart types, using the secondary axis, specifying different chart types and using multiple chart areas.

將多個資料區連結至相同的資料集 (報表產生器及 SSRS)Linking Multiple Data Regions to the Same Dataset (Report Builder and SSRS)
提供相同報表資料集的不同資料檢視。Provide different views of data from the same report dataset.

在圖表中加入或刪除群組 (報表產生器及 SSRS)Add or Delete a Group in a Chart (Report Builder and SSRS)
描述將群組和巢狀群組加入至圖表。Describes adding groups and nested groups to a chart.

將移動平均加入至圖表 (報表產生器及 SSRS)Add a Moving Average to a Chart (Report Builder and SSRS)
描述如何使用 [移動平均] 公式計算數列中資料的平均值。Describes using the Moving Average formula to calculate the average of the data in your series.

疑難排解圖表 (報表產生器及 SSRS)Troubleshoot Charts (Report Builder and SSRS)
描述使用圖表的秘訣。Describes tips for working with charts.

另請參閱See Also

影像、文字方塊、矩形和線條 (報表產生器及 SSRS) Images, Text Boxes, Rectangles, and Lines (Report Builder and SSRS)
互動式排序、文件引導模式及連結 (報表產生器及 SSRS) Interactive Sort, Document Maps, and Links (Report Builder and SSRS)
巢狀資料區 (報表產生器及 SSRS) Nested Data Regions (Report Builder and SSRS)
教學課程:將直條圖新增至報表 (報表產生器) Tutorial: Add a Column Chart to Your Report (Report Builder)
教學課程:將圓形圖新增至報表 (報表產生器) Tutorial: Add a Pie Chart to Your Report (Report Builder)
教學課程:將橫條圖新增至報表 (報表產生器)Tutorial: Add a Bar Chart to Your Report (Report Builder)