This is a migrated thread and some comments may be shown as answers.

Ranges and needle not always redrawing correctly

2 Answers 49 Views
Gauge
This is a migrated thread and some comments may be shown as answers.
Zero Gravity Chimp
Top achievements
Rank 2
Zero Gravity Chimp asked on 22 Jun 2010, 04:52 AM
Greetings,

I'm experiencing some problems which I can describe as follows:

Ranges:

Setting the Min and Max of a range (linearrange or radialrange) to the same value will cause the range to remain in the same place.
This is ok but if you change the Min, Max, or tick marks of the gauge as a whole, the rendered ranges no longer correlate to the gauge correctly.
By contrast, if you set the ranges to a different value, they will redraw and the correlation will be maintained when any of the Min/Max/tick marks of the gauge change.

To demonstrate this problem:

I have a value, step 1, and step 2. I have 3 ranges: green, yellow, and red.

If you set the following 3 valuesets one after the other the error will be evident:

1st valueset:
step1 = 4, step2 = 6, value =3
0-4 would be green
4-6 Yellow
6-9 (calculated max) would be red
the needle falls inside these ranges, so max is calculated to 9

second valueset:
step1 = 4, step2 = 6, value = 85
0-4 would be green
4-6 Yellow
6-100 (calculated max) would be red
the needle falls outside the normal ranges, so max is calculated to 100

third valueset:
step1 = 4.0001, step2= 6.0001, value=85
0-4.0001 would be green
4.0001-6.0001 would be yellow
6.0001-100  (calculated max as before) would be red


Taking the above valuesets into account, the gauge would draw correctly for valueset 1. When you insert valueset 2, the gauge will increase to count from 0 to 100 instead of 0 to 9, based on some calculations. At this point, the first 2 ranges will appear to span up over 2/3 of the gauge, but their values are less than 10% of the gauge.

Implementing valueset 3 would solve this problem, so it would seem that there is some kind of 'propertychanged' event handler which must be called for these values to render correctly. I've modified my own code, adding the following:

        private void setGreenMax(double e) 
        { 
            if (Green.Max == e) 
                e = e + 0.00001; 
            GreenRange.Max = e;
        }
 
        private void setGreenMin(double e) 
        { 
            if (Green.Min == e) 
                e = e - 0.00001; 
            GreenRange.Min = e;
        }

This ensures that the property always changes, albeit slightly, so that I do not experience the problems described above.

Please let me know if I'm doing something wrong or if this is not easy to understand, I can always compile a sample app for you to demonstrate the problem.

Second problem, Needle:
  • Setting the Needle.Value of the radial gauge needle indicator to 0.0 causes it to fall outside the gauge area. I can't recreate this now after about 10 minutes, but I am sure it was happening for 0.0 value on the needle. I can try to make a sample app to demonstrate this if I have enough time, might be some strange combination of factors.

Thanks in advance for your replies,

Paul
Ranges:

2 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 22 Jun 2010, 08:22 AM
Hi Paul,

Thank you for the feedback.
We are aware about these problems. They would be solved within the following PITS issue:
http://www.telerik.com/support/pits.aspx#/public/silverlight/2477

I think there is more correct workaround for ranges without using delta like 0.00001.
You can invalidate ranges and indicators when the Max property of the scale is changed using the following code:

foreach (IndicatorBase indicator in scale.Indicators)
{
    indicator.InvalidateArrange();
}

foreach
(RangeBase range in scale.Ranges)
{
    range.InvalidateMeasure();
}

I believe that this code also solves a problem with the needle.

Kind regards,
Andrey Murzov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Zero Gravity Chimp
Top achievements
Rank 2
answered on 23 Jun 2010, 01:27 AM
Hi again,

Thanks so much for your reply.

I am pleased that this workaround exists and much happier implementing this  rather than my previous workaround for the problem. :)

Regards,

Paul
Tags
Gauge
Asked by
Zero Gravity Chimp
Top achievements
Rank 2
Answers by
Andrey
Telerik team
Zero Gravity Chimp
Top achievements
Rank 2
Share this question
or