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

6 posts, 0 answers
  1. AndreasW
    AndreasW avatar
    13 posts
    Member since:
    Jul 2011

    Posted 19 Oct 2011 Link to this post

    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?

  2. Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 24 Oct 2011 Link to this post

    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 >>

  3. DevCraft banner
  4. AndreasW
    AndreasW avatar
    13 posts
    Member since:
    Jul 2011

    Posted 31 Oct 2011 Link to this post

    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?
  5. Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 03 Nov 2011 Link to this post

    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 >>

  6. Guy
    Guy avatar
    46 posts
    Member since:
    Nov 2008

    Posted 17 Jan 2012 Link to this post

    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,
  7. Yavor
    Admin
    Yavor avatar
    401 posts

    Posted 20 Jan 2012 Link to this post

    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 >>

Back to Top
DevCraft banner