SSRS Custom Drawing

In my last post I showed some tricks with reporting services charts. As I mentioned, the possibilities are almost endless.For example, Jason Thomas created an excellent step-by-step instruction of how to create overlapping bar charts . So, I can just encourage everybody to be creative with these chart properties. It’s really amazing what kind of charts can be created this way.

But with the ability to use code behind a report, SSRS is even more powerful. In an early post, Jason Thomas reported about a method of rotating text in SSRS 2005 . As SSRS 2005 has no property to rotate text, the solution was to write custom code that actually returns a bitmap as a byte array. This bitmap can then be placed on the report. Just imagine what this means for you: You can create a .Net drawing function, pass parameters from the report (maybe from a data set) to the function and place the resulting imagine on the report! Being able to use the powerful System.Drawing functions gives us almost unlimited power to create interesting graphical representations. This post shows just two examples.

In the following screenshot of a Reporting Services report I used this technique to create a custom KPI representation (the “sliders” in the last column).

In order to create this graphical element, I used two functions. The first function returns a System.Drawing.Bitmap, the second function converts this bitmap to a byte array. I removed the simple drawing code itself here to focus on the idea. This is how the two functions look like: