Lets assume that you have created a radial gauge with a single pointer. Let the data source has a single column - Value and lets assume that the gauge axis is scaled from Value min to Value max and the gauge pointer displays the average Value.
The code example colorizes the pointer in green if the pointer value is below the Median, otherwise it colorizes the pointer in red. To get the median value of the values in the set we use the following code parameter:
Name:Median, Expression:=MEDIAN(Fields!Value)
C# |
Copy Code
|
---|---|
using System; using System.Drawing; using Nevron.GraphicsCore; using Nevron.Chart; using Nevron.ReportingServices; namespace MyNamespace { /// <summary> /// Sample class /// </summary> public class MyClass { /// <summary> /// Main entry point /// </summary> /// <param name="context"></param> public static void RSMain(NRSGaugeCodeContext context) { // check if gauge document contains gauges if (context.Document.Gauges.Count == 0) return; // the first gauge panel NGaugePanel gauge = context.Document.Gauges[0] as NGaugePanel; if (gauge.Indicators.Count == 0) return; // get the first pointer NValueIndicator pointer = gauge.Indicators[0] as NValueIndicator; if (pointer == null) return; double median = context.GetDoubleParameter("Median"); if (pointer.Value < median) { pointer.Shape.FillStyle = new NColorFillStyle(Color.Green); } else { pointer.Shape.FillStyle = new NColorFillStyle(Color.Red); } } } } |