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

Y-axis not shown correct when disabling and enabling logarithmic scale

5 Answers 104 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
AndreasW
Top achievements
Rank 1
AndreasW asked on 19 Oct 2011, 08:10 AM
Hi,
I got a line chart which can show data with both linear and logarithmic y-axis. The user can show and hide data series using checkboxes bound to seriesvisibility properties in the ViewModel.

When in linear mode a function finds the largest value of the visible series and sets the Y-axis range using the AddRange() function.
When in logarithmic mode AutoRange decide the Y-axis range. Both the AutoRange and IsLogaritmic properties of the chart are bound to bools in the ViewModel.

By default the chart are set to logarithmic. My problem are when the user disables logarithmic and enables it again. When this happens the the dataseries are drawn as expected, but the Y-axis values are wrong. Instead of values 1/10/100/1000 etc. they range from -0.5/0.0.5/1 etc. See attached images.


My code for switching between log/lin :

public RelayCommand IsLogCommand{
                 get
                    {
                        if (_IsLogCommand == null)
                        {
                            _IsLogCommand = new RelayCommand(() =>
                            {
                                AutoRange = !AutoRange;
                                IsLog = !IsLog;
                                MaxRange = FindMaxInVisible();
                            });
                        }
                        return _IsLogCommand;
                    }
            }


Where MaxRange are sent to the code behing using mvvmlight messenging :
Messenger.Default.Register<PropertyChangedMessage<double>>(
                this,
           (action) =>
           {
               if ((MyChart!= null))
               {
                   AxisY = MyChart.DefaultView.ChartArea.AxisY;
 
                   MaxRange = (int)(action.NewValue);
 
                   if (!AxisY.IsLogarithmic)
                   {
                       MaxRange = Math.Round(MaxRange * 1.1);
                       AxisY.AddRange(-Math.Round(0.1 * MaxRange), (int)MaxRange, (int)MaxRange / 10);
                   }
               }
           });


My AxisY are set in xaml as :
<telerik:ChartArea.AxisY>  
         <telerik:AxisY
                  x:Name="AxisY"
                  IsLogarithmic="{Binding IsLog,Mode=OneWay,Source={StaticResource VM}}"
                  AutoRange="{Binding AutoRange,Mode=OneWay,Source={StaticResource VM}}"   
                  LogarithmBase="10" 
                  MinValue="0"             
                   MinorTicksVisibility="Collapsed" 
                   MajorTicksVisibility="Collapsed"
                   ExtendDirection="None">  
               </telerik:AxisY>
    </telerik:ChartArea.AxisY>

Any idea why this is happening?

5 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 24 Oct 2011, 12:20 PM
Hello Andreasw,

We reproduced successfully the problem you are describing just by binding IsLogarithmic and AutoRange properties and changing them with the IsLogCommand. It seams that the order in which these properties are toggled matters, because if you set first IsLog the labels start to work correctly (more or less). Your code can look like this:

_IsLogCommand = new RelayCommand(() =>
{
    IsLog = !IsLog;
    AutoRange = !AutoRange;
    ...
});

I have logged this regression in our internal bug tracking system and notified the responsible team for further investigation on the issue. Your telerik points have been updated.

Regards,
Yavor
the Telerik team

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

0
AndreasW
Top achievements
Rank 1
answered on 31 Oct 2011, 12:18 PM
Thanks for the reply!

When changing the order which AutoRange and IsLogaritmic are toggled, as you suggest, I encounter another issue.
After toggling the disable/enable once my Y-axis are filled with value INF for all steps, and all dataseries are drawn to zero.

You got any suggestion on how to fix this issue?
0
Yavor
Telerik team
answered on 03 Nov 2011, 10:27 AM
Hello Andreasw,

You are right, it seams that this workaround won't work. Another possible workaround can be to set isLogarithmic and AutoRange separately. We have tried this approach and it works as expected in our tests.

All the best,
Yavor
the Telerik team

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

0
Guy
Top achievements
Rank 1
answered on 17 Jan 2012, 09:49 PM
Hi Yavor ,

I have the same problem when I switch between Logarithmic Scale and linear scale using a boolean value in the ViewModel. Sometimes when switch to  the logarithmic scale,  either  the Y-Axis is  wrong or the series in the chart diseappear and the chart look like empty. The reverse cause sometimes the Y-Axis all scaled by infinity.
I m using telerik version 2011.3.1205.1040. I need your suggest  to solve  this misbehaviour.

Best regards,
0
Yavor
Telerik team
answered on 20 Jan 2012, 01:37 PM
Hello Guy,

Can you please share more details on your scenario so that we can investigate it in our labs? A sample application that reproduces it can be very helpful.

All the best,
Yavor
the Telerik team

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

Tags
Chart
Asked by
AndreasW
Top achievements
Rank 1
Answers by
Yavor
Telerik team
AndreasW
Top achievements
Rank 1
Guy
Top achievements
Rank 1
Share this question
or