Add Annotations in the Chart for SQL Reporting Services

Applies to: Nevron Chart for Reporting Services (SSRS 2005 and 2008)

How to add Annotations in the Chart for SQL Reporting Services?

Annotations are panels that also poses an anchor (pivot) point. The anchor is calculated at runtime and depends on the position of the scene item to which the annotation is attached.



You can add annotations in Nevron Chart for SQL Reporting Services by using the Custom Code injection feature.



The following code example shows how to add and modify several different annotations in the Chart:

[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(NRSChartCodeContext context)
            {
                NChart chart = context.Document.Charts[0];
                NBubbleSeries bubble = chart.Series[0] as NBubbleSeries;
                 
                NRectangularCallout rectangularCallout = new NRectangularCallout();
                rectangularCallout.ArrowLength = new NLength(14, NRelativeUnit.ParentPercentage);
                rectangularCallout.ArrowBasePercent = 10;
                rectangularCallout.FillStyle = new NGradientFillStyle(Color.FromArgb(125, Color.White), Color.FromArgb(125, Color.Blue));
                rectangularCallout.UseAutomaticSize = true;
                rectangularCallout.Orientation = 115;
                rectangularCallout.Anchor = new NDataPointAnchor(bubble, 5, ContentAlignment.MiddleCenter, StringAlignment.Center);
                rectangularCallout.Text = "Rectangular Callout at index 1";
                rectangularCallout.TextStyle.TextFormat = TextFormat.XML;
                chart.ChildPanels.Add(rectangularCallout);
                 
                NRoundedRectangularCallout roundedRectangularCallout = new NRoundedRectangularCallout();
                roundedRectangularCallout.ArrowLength = new NLength(10, NRelativeUnit.ParentPercentage);
                roundedRectangularCallout.ArrowBasePercent = 10;
                roundedRectangularCallout.SmoothEdgePercent = 35;
                roundedRectangularCallout.FillStyle = new NGradientFillStyle(Color.FromArgb(125, Color.White), Color.FromArgb(125, Color.LightGreen));
                roundedRectangularCallout.UseAutomaticSize = true;
                roundedRectangularCallout.Orientation = 220;
                roundedRectangularCallout.Anchor = new NModelPointAnchor(chart, new NVector3DF(-20, -20, 0));
                roundedRectangularCallout.Text = "Rounded Rectangular Callout<br />attached to a model point";
                roundedRectangularCallout.TextStyle.TextFormat = TextFormat.XML;
                chart.ChildPanels.Add(roundedRectangularCallout);
                 
                NCutEdgeRectangularCallout cutEdgeRectangularCallout = new NCutEdgeRectangularCallout();
                cutEdgeRectangularCallout.FillStyle = new NGradientFillStyle(Color.FromArgb(125, Color.White), Color.FromArgb(125, Color.LightBlue));
                cutEdgeRectangularCallout.ArrowLength = new NLength(15, NRelativeUnit.ParentPercentage);
                cutEdgeRectangularCallout.ArrowBasePercent = 8;
                cutEdgeRectangularCallout.UseAutomaticSize = true;
                cutEdgeRectangularCallout.Orientation = 320;
                cutEdgeRectangularCallout.Anchor = new NDataPointAnchor(bubble, 3, ContentAlignment.MiddleCenter, StringAlignment.Center);
                cutEdgeRectangularCallout.Text = "Rounded Rectangular<br />Callout";
                cutEdgeRectangularCallout.TextStyle.TextFormat = TextFormat.XML;
                chart.ChildPanels.Add(cutEdgeRectangularCallout);
                 
                NOvalCallout ovalCallout = new NOvalCallout();
                ovalCallout.FillStyle = new NColorFillStyle(Color.FromArgb(200, Color.AliceBlue));
                ovalCallout.ArrowLength = new NLength(15, NRelativeUnit.ParentPercentage);
                ovalCallout.ArrowBasePercent = 8;
                ovalCallout.UseAutomaticSize = true;
                ovalCallout.Orientation = 220;
                ovalCallout.Anchor = new NScalePointAnchor(chart,
                    (int)StandardAxis.PrimaryX,
                    (int)StandardAxis.PrimaryY,
                    (int)StandardAxis.Depth,
                    AxisValueAnchorMode.Clip, new NVector3DD(25000, 94.50, 0));
                 
                ovalCallout.Text = "Oval Callout attached<br />to a scale point";
                ovalCallout.TextStyle.TextFormat = TextFormat.XML;
                chart.ChildPanels.Add(ovalCallout);
            }
      }
}

Article ID: 193, Created On: 7/18/2011, Modified: 7/18/2011