Add custom value and range labels to the Gauge in SharePoint

Applies to: Nevron Gauge for SharePoint (WSS3.0, SharePoint 2007/2010/2013)

How to add custom value and range labels to the Gauge in SharePoint?

 

You can set custom labels to the Gauge in SharePoint. Use the following code in the Code tab of the Gauge designer to programmatically add custom value and range labels to the gauge axis scale:

[C#]
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;
              
            // get the first gauge
            NGaugePanel gauge = context.Document.Gauges[0] as NGaugePanel;
            if (gauge.Indicators.Count == 0)
                return;
              
            // adding custom range labels
            NLinearScaleConfigurator scale = ((NGaugeAxis)gauge.Axes[0]).ScaleConfigurator as NLinearScaleConfigurator;
              
            NCustomRangeLabel customRangeLabel = new NCustomRangeLabel();
              
            customRangeLabel = new NCustomRangeLabel(new NRange1DD(0, 30), "Range Label");
            customRangeLabel.Style.WrapText = false;
            customRangeLabel.Style.KeepInsideRuler = false;
            customRangeLabel.Style.StrokeStyle.Color = Color.Red;
            customRangeLabel.Style.TextStyle.FillStyle = new NColorFillStyle(Color.White);
            customRangeLabel.Style.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 0);
            customRangeLabel.Style.TickMode = RangeLabelTickMode.Center;
              
            scale.CustomLabels.Add(customRangeLabel);
              
            NCustomValueLabel customValueLabel = new NCustomValueLabel(50, "Value Label");
              
            customValueLabel.Style.KeepInsideRuler = false;
            customValueLabel.Style.TextStyle.FillStyle = new NColorFillStyle(Color.White);
            customValueLabel.Style.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 0);
              
            scale.CustomLabels.Add(customValueLabel);
        }
    }
}

[VB.NET]
Imports System
Imports System.Drawing
Imports Nevron.GraphicsCore
Imports Nevron.Chart
Imports Nevron.ReportingServices
  
Namespace MyNamespace
    ''' <summary>
    ''' Sample class
    ''' </summary>
    Public Class [MyClass]
        ''' <summary>
        ''' Main entry point
        ''' </summary>
        ''' <param name="context"></param>
        Public Shared Sub RSMain(context As NRSGaugeCodeContext)
            ' check if gauge document contains gauges
            If context.Document.Gauges.Count = 0 Then
                Return
            End If
  
            ' get the first gauge
            Dim gauge As NGaugePanel = TryCast(context.Document.Gauges(0), NGaugePanel)
            If gauge.Indicators.Count = 0 Then
                Return
            End If
  
            ' adding custom range labels
            Dim scale As NLinearScaleConfigurator = TryCast(DirectCast(gauge.Axes(0), NGaugeAxis).ScaleConfigurator, NLinearScaleConfigurator)
  
            Dim customRangeLabel As New NCustomRangeLabel()
  
            customRangeLabel = New NCustomRangeLabel(New NRange1DD(0, 30), "Range Label")
            customRangeLabel.Style.WrapText = False
            customRangeLabel.Style.KeepInsideRuler = False
            customRangeLabel.Style.StrokeStyle.Color = Color.Red
            customRangeLabel.Style.TextStyle.FillStyle = New NColorFillStyle(Color.White)
            customRangeLabel.Style.Angle = New NScaleLabelAngle(ScaleLabelAngleMode.Scale, 0)
            customRangeLabel.Style.TickMode = RangeLabelTickMode.Center
  
            scale.CustomLabels.Add(customRangeLabel)
  
            Dim customValueLabel As New NCustomValueLabel(50, "Value Label")
  
            customValueLabel.Style.KeepInsideRuler = False
            customValueLabel.Style.TextStyle.FillStyle = New NColorFillStyle(Color.White)
            customValueLabel.Style.Angle = New NScaleLabelAngle(ScaleLabelAngleMode.Scale, 0)
  
            scale.CustomLabels.Add(customValueLabel)
        End Sub
    End Class
End Namespace

Article ID: 105, Created On: 10/30/2010, Modified: 1/29/2013