The component allows you to modify every aspect of the visualized gauge image through custom C# code. This feature is useful when the settings exposed through the designer are not enough to produce the desired gauge appearance. This topic describes how to take advantage of this feature. Note that the code used here uses the Nevron Chart for .NET API, so some familiarity with it is recommended.
The component designer contains a tab called "Code" that allows you to type code, configure custom parameters and add referenced assemblies that can be used by your code. The following sections describe how to achieve these goals. The sample code below assumes that your are working with the Code Embedding example shipped with the control.
Adding Code with Entry Point
The easiest way to start using the code embedding feature is to load an entry point template:
1. Go to the Code tab
2. Select File\New
3. Select "Entry Point" from the templates list and click Ok.
The designer will load a simple C# code that contains an entry point that the component will call at runtime:
C# |
Copy Code
|
---|---|
using System; namespace MyNamespace |
Adding Custom Parameters
Custom parameters are name/value pairs that allow you to associate a name with a SSRS expression. Adding custom parameters is explained in the chart Code Embedding topic and is essentially the same as with the chart report item.
Extending the Code
1. Extend the code with the following:
C# |
Copy Code
|
---|---|
using System; namespace MyNamespace // the needle indicator is inserted after the range NValueIndicator indicator = gauge.Indicators[1] as NValueIndicator; NRange1DD range = new NRange1DD(80, 100); |
The "context" parameter passed to the main entry point has a property called Document. This property allows you to access the chart document generated by the SSRS gauge template. The document fully exposes the Nevron Chart for .NET API and allows for full control over the gauge appearance.