Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
75
how to set major and minor tickmarks for radial gauge programatically
posted

Hello ALL,

 I have to create a half radial gauge . I used one of the preset and removed markers and used it .

now I want to add a  scale and tickmarks ( major and minor ) programmatically using .net c#.

I want to calculate values at run time and fine a suitable a  scale and tickmarks ( major and minor ) for gauge chart.

Like if my value( int or double) should always come in the middle   scale.

and then neddle value need to set with second value (int  or double).

  • 195
    posted

    Hi Neetuchamling,

    I have done this recently for the first time so I'm not sure if the answer I have is a good one, but it works. Maybe someone else can give it a quick review. Firstly I wrap the IG gauge in a usercontrol and then I load the controls in the page_init of the containing page. The wrapper usercontrol has a method called "SetProperties" which I pass in an object containing the data to set up the gauge (Probably this should just be a constructor). When the control loads I can set things like tickmarks and scales in Page_Load()

    ------------------------------------------------
    protected void Page_Load(object sender, EventArgs e)

    {

    try

    {

    if (!Page.IsPostBack)

    {

    lblGaugeHeading.Text = GaugeHeading;


    UltraGauge1.DeploymentScenario.ImageType = GaugeImageType.Jpg;
    UltraGauge1.DeploymentScenario.ImageURL = "~/images/SalesForce/Gauges/TargetPax/Gauge_#SEQNUM(100).#EXT";
    UltraGauge1.DeploymentScenario.FilePath = "~/images/SalesForce/Gauges/TargetPax";


    // departed sales range
    ((RadialGauge)UltraGauge1.Gauges[0]).Scales[0].Ranges[0].StartValue = 0; // RANGE IS A BACKGROUND LINE ON RADIAL DIAL
    ((RadialGauge)UltraGauge1.Gauges[0]).Scales[0].Ranges[0].EndValue = DepartedSales;

    // forward sales range
    ((RadialGauge)UltraGauge1.Gauges[0]).Scales[0].Ranges[1].StartValue = DepartedSales;
    ((RadialGauge)UltraGauge1.Gauges[0]).Scales[0].Ranges[1].EndValue = DepartedSales + ForwardSales;

    // target Pax - axis max value
    ((RadialGauge)UltraGauge1.Gauges[0]).Scales[0].Axis.SetEndValue(Target);

    // total pax sales - needle marker
    ((RadialGauge)UltraGauge1.Gauges[0]).Scales[0].Markers[0].Value = DepartedSales + ForwardSales; // this is number of pax sold
    ((RadialGauge)UltraGauge1.Gauges[0]).Scales[0].Markers[0].Precision = 0;

    // tickmarks
    ((RadialGauge)UltraGauge1.Gauges[0]).Scales[0].MinorTickmarks.Frequency = 5;
    ((RadialGauge)UltraGauge1.Gauges[0]).Scales[0].MajorTickmarks.Frequency = 10;
    Double tickmarkInterval = 100;
    if (Math.Log10(Convert.ToDouble(Target)) >= 4.3) // gets a good separation of tick marks on the dial for targets > 15000. nothing more.
    tickmarkInterval = 500;
    ((RadialGauge)UltraGauge1.Gauges[0]).Scales[0].Axis.SetTickmarkInterval(tickmarkInterval);
    }
    }
    catch ()
    {
    // code left out
    }
    ----------------------------------------------------------------------

    Hope that helps (if you haven't already found a solution). If anyone has any comments about this I'd love to hear it .

    James.

     

  • 28496
    Offline posted

    This is all possible using the gauge control.  Do you have any questions, or did you want help with part of this?