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

Gauge chart doesn't refresh dynamically ranges

1 Answer 190 Views
Gauge
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Anatoly Chekh
Top achievements
Rank 1
Anatoly Chekh asked on 22 May 2012, 08:55 PM
Hello!

I have an issue. I try to change scale ranges dynamically, but it doesn't changed (old range is shown).
This is simple app where it doesn't work:

Xaml:

<StackPanel>
            <telerik:RadRadialGauge Width="220" Height="220">
                <telerik:RadialScale Name="scale" 
                                         RangeLocation="Outside"
                                         RangeOffset="-0.015"
                                         MajorTickOffset="-0.015"
                                         MiddleTickOffset="-0.015"
                                         MinorTickOffset="-0.015"
                                         LabelRotationMode="None">
                    <telerik:RadialScale.Ranges>
                        <telerik:GaugeRange Min="0" Max="20" StartWidth="0.015" EndWidth="0.015" Background="Green"  />
                    </telerik:RadialScale.Ranges>
                </telerik:RadialScale>
            </telerik:RadRadialGauge>
            <Button Content="Click" Click="ButtonBase_OnClick" />
        </StackPanel>

Click action is very simple:
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
     scale.Ranges.Clear();
     scale.Ranges.Add(new GaugeRange() { Min = 20, Max = 40, StartWidth = 0.015, EndWidth = 0.015, Background = new SolidColorBrush(Colors.Green) });
}

After buttin click I see old range from 0 to 20. If I call scale.InvalidateMeasure(); then I get new range from 20 to 40, but also I still see old range from 0 to 20.

Is is a bug or I'm doing something wrong?

Thanks, Anatoly Chekh.

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 25 May 2012, 02:16 PM
Hello Anatoly,

We are aware of a problem with Clear method. The problem is in the implementation of this method in the standard DependencyObjectCollection and code in the gauge control which relies on it. We created a fix for this problem already. We extended the collection which implements the IList interface with RemoveAll method which should be used instead of Clear method. Note, the extension is included into the Telerik.Windows.Controls.Map namespace in the same Telerik.Windows.Controls.DataVisualization.dll assembly.
The sample code is below.
using System.Windows;
using System.Windows.Controls;
using Telerik.Windows.Controls.Gauge;
using Telerik.Windows.Controls.Map;
using System.Windows.Media;
 
namespace GaugeRangeVisibility
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }
 
        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            scale.Ranges.RemoveAll();
            scale.Ranges.Add(new GaugeRange()
            {
                Min = 20,
                Max = 40,
                StartWidth = 0.015,
                EndWidth = 0.015,
                Background = new SolidColorBrush(Colors.Green)
            });
 
            scale.InvalidateMeasure();
        }
    }
}


Kind regards,
Andrey Murzov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
Gauge
Asked by
Anatoly Chekh
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or