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.
2 Responses to “Dundas Gauge - Setting pointer values”
Leave a Reply
You must be logged in to post a comment.
July 30th, 2008 at 2:15 am
Thanks for the code. This has helped me in getting started with Gauges.
October 8th, 2008 at 8:00 am
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