Nevron Vision for SharePoint Documentation
Code Injection

The chart and gauge web parts allow for users with development experience to inject custom C# or VB.NET code, which is compiled and executed at runtime.

Some familiarity with the Nevron Chart for .NET API is required.

The code injection feature helps you utilize the wide range of additional customization options, which are exposed by the Nevron Chart for .NET API. The compilation produces an in-memory assembly, which means that there are no deployment issues when you exchange or deploy templates with embedded code across different SharePoint Servers.

The code injection feature is exposed by the editors located in the Code main tab (for both the chart and the gauge). It contains three sub-tabs:

Referenced Assemblies

The referenced assemblies editor lets you edit the assemblies that you want your custom code to reference. By default the injected code is configured to use the following assemblies:

Code Parameters

Code parameters are name-value pairs that allow you to define custom pivot properties. Since the custom code is executed after the pivot has been processed this allows you to define named expressions, the evaluated values of which can later be used by your custom code.

For example - suppose that in your code you want to know how many records were contained in the data source. To do this you can create a code parameter with Name:RecordsCount and Expression:=Global.Fields![RowCount]. The custom code method that gets called (see Code_Editor) always receives a context argument, from which you can get the evaluated values for the code parameters that you have declared at design time:

C#
Copy Code
int rowCount = context.GetInt32Parameter("RecordsCount");
VB.NET
Copy Code
Dim rowCount As Integer = context.GetInt32Parameter("RecordsCount")

It is important to know that the code parameters that you define are recorded in the pivot properties. This means that the default evaluation scope for the code parameters expressions is the Pivot Scope - see Pivot Processing for more information.

Code Editor

The code editor lets you type the code that you want to execute at runtime. The code is compiled according to the language that you choose from the Language combo box. To inspect the code for errors you can click on the Compile... button - the compilation results will appear in the status field.

The code can use the types declared in the assemblies that you referenced in the Referenced_Assemblies tab page. There must be at least one class in the code, which contains a static RSMain method with the following signature:

Product Entry Point Method
Nevron Chart for SharePoint
C#
Copy Code
public static void RSMain(NRSChartCodeContext context)
VB.NET
Copy Code
Public Shared Sub RSMain(ByVal context As NRSChartCodeContext)
Nevron Gauge for SharePoint
C#
Copy Code
public static void RSMain(NRSGaugeCodeContext context)
VB.NET
Copy Code
Public Shared Sub RSMain(ByVal context As NRSGaugeCodeContext)

Both code contexts share a set of common methods, which help you get the evaluated values for the code parameters that you declared in the Code_Parameters tab. Following is a summary:

Function Description
GetBooleanParameter Returns a named parameter, converted to boolean
GetInt32Parameter Returns a named parameter, converted to Int32
GetInt64Parameter Returns a named parameter, converted to Int64
GetSingleParameter Returns a named parameter, converted to Single
GetDoubleParameter Returns a named parameter, converted to Double
GetStringParameter Returns a named parameter, converted to String
 

Also common for both contexts is the Document property, which returns the Nevron Chart for .NET document, that was created by the pivot processor.

See Also

 

 


©2016. Nevron Software LLC.

Send Feedback