Wednesday, November 16, 2005

Bob's SQL Reporting Services Blog

Link
How to create an inline bar chart

Here's a neat trick a co-worker and I discovered this afternoon for creating an inline bar chart (an inline data visualization in a table or other data region).

1. Add an embedded image to your report that will serve as the "bar" (a simple horizontal gradient usually looks nice)

2. Add a column to your table, and place an Image report item in the detail row cell.

3. Select the embedded image from step 1 as the source for the Image report item.

4. Set the padding on the Image report item to adjust the size and position of the bar within the cell

5. [Here's the kicker] Create an expression for the right (or left) padding that divides a field value by some maximum value, clamps it to a given range if necessary using Math.Min/Max, and then multiplies by the total size of the bar.

Example: image1.Padding.Right=((1.0-(Math.Min(Math.Max(Fields!TotalSales.Value,0),100000)/100000))*72) & "pt"">Bob's SQL Reporting Services Blog: "How to create an inline bar chart

Here's a neat trick a co-worker and I discovered this afternoon for creating an inline bar chart (an inline data visualization in a table or other data region).

1. Add an embedded image to your report that will serve as the 'bar' (a simple horizontal gradient usually looks nice)

2. Add a column to your table, and place an Image report item in the detail row cell.

3. Select the embedded image from step 1 as the source for the Image report item.

4. Set the padding on the Image report item to adjust the size and position of the bar within the cell

5. [Here's the kicker] Create an expression for the right (or left) padding that divides a field value by some maximum value, clamps it to a given range if necessary using Math.Min/Max, and then multiplies by the total size of the bar.

Example: image1.Padding.Right=((1.0-(Math.Min(Math.Max(Fields!TotalSales.Value,0),100000)/100000))*72) & 'pt'"

No comments: