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

Labels disappear

2 Answers 123 Views
Gauge
This is a migrated thread and some comments may be shown as answers.
Grtjn
Top achievements
Rank 1
Grtjn asked on 14 Apr 2010, 09:18 AM
Hi all,

I just created a halfcircle radgauge using the Q1 2010 version.
The problem I have is that my labels get stuck in the border of this gauge (shown in the attached image)

This is the code for my radgauge:
RadGauge radgauge = (FindName((e.Result as RadGaugeData).XAMLNaam) as RadGauge);  
 
                if ((e.Result as RadGaugeData).Visible)  
                {  
                    radgauge.Visibility = System.Windows.Visibility.Visible;  
                }  
                else  
                {  
                    radgauge.Visibility = System.Windows.Visibility.Collapsed;  
                }  
 
 
                RadialGauge gauge = new RadialGauge()  
                {  
                    MaxHeight = 100,  
                    MaxWidth = 175                      
                };  
                radgauge.Content = gauge;  
                RadialScale scale = new RadialScale()  
                {  
                    Min = (e.Result as RadGaugeData).ScaleMin,  
                    Max = (e.Result as RadGaugeData).ScaleMax,  
                    //StartAngle = 180,  
                    //SweepAngle = 180,  
                    IsLogarithmic = false,  
                    MajorTickStep = (e.Result as RadGaugeData).TickStep,  
                    //MiddleTicks = 5,  
                    LabelRotationModeLabelRotationMode = LabelRotationMode.None,  
                    Location = ScaleObjectLocation.OverInside  
                };  
                scale.MiddleTick.Length = 0.08;  
                scale.MajorTick.Length = 0.1;  
                gauge.Items.Add(scale);  
 
                ColorConverter converter = new ColorConverter();  
                SolidColorBrush lowcol = converter.getSolidColorBrushFromString((e.Result as RadGaugeData).ColorLow);  
                SolidColorBrush medcol = converter.getSolidColorBrushFromString((e.Result as RadGaugeData).ColorMed);  
                SolidColorBrush highcol = converter.getSolidColorBrushFromString((e.Result as RadGaugeData).ColorHigh);  
 
                scale.Ranges.Add(new RadialRange()  
                {  
                    Min = (e.Result as RadGaugeData).ScaleMin,  
                    Max = (e.Result as RadGaugeData).LowTresHold,  
                    Location = ScaleObjectLocation.Inside,  
                    StartWidth = 0.05,  
                    EndWidth = 0.1,  
                    Background = lowcol 
                });  
                scale.Ranges.Add(new RadialRange()  
                {  
                    Min = (e.Result as RadGaugeData).LowTresHold,  
                    Max = (e.Result as RadGaugeData).HighTresHold,  
                    Location = ScaleObjectLocation.Inside,  
                    StartWidth = 0.1,  
                    EndWidth = 0.15,  
                    Background = medcol 
                });  
                scale.Ranges.Add(new RadialRange()  
                {  
                    Min = (e.Result as RadGaugeData).HighTresHold,  
                    Max = (e.Result as RadGaugeData).ScaleMax,  
                    Location = ScaleObjectLocation.Inside,  
                    StartWidth = 0.15,  
                    EndWidth = 0.2,  
                    Background = highcol 
                });   
 
                Needle ndl = new Needle()  
                {  
                    Location = ScaleObjectLocation.CenterInside,  
                    IsAnimated = true,  
                    Value = (e.Result as RadGaugeData).Waarde,  
                    //Background = new SolidColorBrush(Colors.Red),  
                    TooltipFormat = "{0:F2}" 
                };  
                var uri = new Uri("/Telerik.Windows.Controls.Gauge;component/Themes/generic.xaml", UriKind.Relative);  
                var dictionary = new ResourceDictionary();  
                dictionary.Source = uri;  
                if (dictionary.Contains("RadialGaugeHalfCircleNStyle"))  
                {  
                    gauge.Style = dictionary["RadialGaugeHalfCircleNStyle"] as Style;  
                }  
                if (dictionary.Contains("RadialScaleHalfCircleNStyle"))  
                {  
                    scale.Style = dictionary["RadialScaleHalfCircleNStyle"] as Style;  
                }  
                scale.Indicators.Add(ndl);  
 
                String RGTitel = (e.Result as RadGaugeData).XAMLNaam;  
                TextBlock TargetBlock = new TextBlock();  
                if (RGTitel == "rg1")  
                    TargetBlock = tb1;  
                else if (RGTitel == "rg2")  
                    TargetBlock = tb2;  
                else if (RGTitel == "rg3")  
                    TargetBlock = tb3;  
                else if (RGTitel == "rg4")  
                    TargetBlock = tb4;  
                else if (RGTitel == "rg5")  
                    TargetBlock = tb5;  
                TargetBlock.Text = (e.Result as RadGaugeData).Titel; 
And Location = ScaleObjectLocation.OverInside did not do the trick...

Any help ?

Kind regards,

Gertjan

2 Answers, 1 is accepted

Sort by
0
Accepted
Sia
Telerik team
answered on 16 Apr 2010, 01:42 PM
Hi Grtjn,

The default values for some properties doesn't fit in you scenario. There are several possible solutions of the problem:
  • set smaller Radius to the RadialScale = 1.15 or less
  • change the Location of the Labels to Inside and make the Location=Outside for all RadialRange elements
  • set FontSize=8 and Offset=-0.07 for the Labels
Just play with some of these properties and find the solution which is the most appropriate for your case.

Hope this helps.
Best wishes,
Sia
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
Grtjn
Top achievements
Rank 1
answered on 19 Apr 2010, 07:57 AM
Thanks Sia, this did solve my problem !

Kind regards,

Gertjan
Tags
Gauge
Asked by
Grtjn
Top achievements
Rank 1
Answers by
Sia
Telerik team
Grtjn
Top achievements
Rank 1
Share this question
or