Dundas Gauge – Setting pointer values

I was having trouble getting Dundas Gauge for ASP.NET to reflect the value that I was assigning it. For some reason, the needle always pointed to the default 0. I was using this code:

//create circular gauge
GaugeContainer gauge = new GaugeContainer();
CircularGauge circleGauge = new CircularGauge();
gauge.CircularGauges.Add(circleGauge);

//scale
CircularScale scale = new CircularScale();
scale.Minimum = -100;
scale.Maximum = 100;
circleGauge.Scales.Add(scale);

//pointer
CircularPointer pointer = new CircularPointer();
pointer.Type = CircularPointerType.Needle;
pointer.Value = 10;
circleGauge.Pointers.Add(pointer);

//display
gauge.ImageType = ImageType.Png;
gauge.Width = new Unit(200);
gauge.Height = new Unit(200);
gauge.Page = Page;
gauge.RenderType = Dundas.Gauges.WebControl.RenderType.BinaryStreaming;
gauge.RenderControl(writer);

So "pointer.Value = 10;" was not working. After looking at some examples, I figured out that this worked:

gauge.CircularGauges[0].Pointers[0].Value = 10;

I'm not sure what the difference is, but give it a try if you're having a similar problem.


Posted

in

by

Tags:

Comments

2 responses to “Dundas Gauge – Setting pointer values”

  1. Graham Evans Avatar
    Graham Evans

    The reason I think you got the problem was because you added the circular gauge to the gauge container before adding the scale and pointer to the circular gauge.

    I think gauge.CircularGauges.Add(circleGauge); should have been one of the last instructions.

    The code you used…
    gauge.CircularGauges[0].Pointers[0].Value = 10;

    can only be used when you already have a pointer created, if you have no pointers the index will be out of bounds.

    Regards

    Graham

  2. Anwar Avatar
    Anwar

    Thanks for the code. This has helped me in getting started with Gauges.

Leave a Reply

Your email address will not be published. Required fields are marked *