How do I move the Position of Custom Value Field Using C#


https://www.nevron.com/Forum/Topic8900.aspx
Print Topic | Close Window

By Andrew Soper - 9 Years Ago
Hello,

I am new to C# and was wondering how I can move the x and y position of the Value Field so it is easier to read.  I appreciate any help.  Below is my 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;

             double target = context.GetDoubleParameter("Target");

            // 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;

            NCustomValueLabel customValueLabel = new NCustomValueLabel(target, "Target - "+ target);

            customValueLabel.Style.KeepInsideRuler = false;

            customValueLabel.Style.TextStyle.FillStyle = new NColorFillStyle(Color.Black);

            customValueLabel.Style.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 0);

            scale.CustomLabels.Add(customValueLabel);

        }

    }

}

Thanks!
By Nevron Support - 9 Years Ago
Hi Andrew,
Please elaborate - what do you mean by "move the x and y position of the Value Field " - is this the value of an indicator or something else?
By Andrew Soper - 9 Years Ago
No problem.  By moving the X and Y, I mean how to move the position that the Value label is displayed within the SharePoint Gauge.

Thanks!

Andrew
By Nevron Support - 9 Years Ago
Hi Andrew,

You cannot freely move a custom axis value label - it is anchored to a specified value on the scale. You can only change the way the custom axis value label is aligned relative to its origin point using the ContentAlignment property - for example:

customValueLabel.Style.ContentAlignment = ContentAlignment.BottomLeft;

If you want to create labels that you can freely move around the gauge control you can use a label panel for this purpose:

   NLabel labelPanel = new NLabel();

   double value = 10;
   labelPanel.Text = "Target" + value.ToString();

   labelPanel.Location = new NPointL(new NLength(10, NGraphicsUnit.Pixel), new NLength(10, NGraphicsUnit.Pixel));

   nChartControl1.Panels.Add(labelPanel);
The above code displays a label at [10, 10] pixels from the left top corner. Hope this helps - let us know if you meet any problems or have any questions.