Applies to: Nevron Gauge for Reporting Services (SSRS 2005 and 2008)
How to add custom value and range labels to the Gauge in SSRS?
You can set custom labels to the Gauge in Reporting Services. 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);
}
}
}
Article ID: 104, Created On: 10/30/2010, Modified: 7/18/2011