Bug: Switching from normal to Logarithmic scale breaks y-axis

12 posts, 0 answers
  1. Daniel
    Daniel avatar
    8 posts
    Member since:
    Jul 2010

    Posted 29 Oct 2010 Link to this post

    If you render a chart with a non-logarithmic auto-ranged y-axis, and then set IsLogarithmic on that same axis and regenerate the chart, the y-axis is not correctly scaled and all datapoints are added at the 1 line even though their values appear correct in the tooltip and label. Switching from IsLogarithmic = true to IsLogarithmic = false causes the y-axis range to be regenerated correctly. If you set IsLogarithmic = true before the _first_ time the series is rendered, it displays correctly; but only for that first time.

    In addition, forcing the axis scale to be regenerated by setting AutoRange false and then true again causes all y-axis labels to show "Infinity". Relevant code below.

    see: http://i.imgur.com/F75hz.png

    Update: Actually looks like I'm just encountering the bug where series with all zeroes breaks the log scale autorange. Curiously, this only arises when RE-generating a chart. The first render works fine.

    Chart.DefaultView.ChartArea.AxisY.AutoRange = false;
     
    // Set y-axis to log scale if checkboxLogScale is checked
    Chart.DefaultView.ChartArea.AxisY.IsLogarithmic = Convert.ToBoolean(CheckBoxLogScaleSubpage.IsChecked);
                 
    // Clear previous data
    Chart.DefaultView.ChartArea.DataSeries.Clear();
    _domainContext.SeriesDataPoints.Clear();
     
    Chart.DefaultView.ChartArea.AxisY.AutoRange = true;
  2. Ves
    Admin
    Ves avatar
    2926 posts

    Posted 03 Nov 2010 Link to this post

    Hi Daniel,

    I am not sure I was able to implement your scenario. I have attached a small example, which shows that toggling IsLogarithmic property of AxisY works as expected. Can you please extend it, so that the issue is reproduced and send it back to us for further investigation? Thank you. In addition, please make sure you have tested it with the latest available version -- currently 2010.Q2 SP2.

    Best regards,
    Ves
    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
  3. Courouble Damien
    Courouble Damien avatar
    54 posts
    Member since:
    Aug 2009

    Posted 28 Dec 2010 Link to this post

    Hey, 

    I've download your sample because I was facing the same issue, it's working fine for the toggle logaryhtmic, I add a dropdown to change the base and it's also work.

    But on a project that I'm developping (Let's call it "Chart configurator") dynamically change from non-Logaritmic to Logarithmic, or switch bases when enable failed on thoses chart :

    - Horizontal Bar ( With several series)
    - Lines (With several series)
    - Bar (With several series)

    It's working great for :

    - Scatter (tested with one serie)
    - Bubble (Also one serie)
    - Area (Two series)

    I don't know what happen, here the scenerio :
     1) the Chart is add dynamically to the UI but it'snot the issue (i've modified your sample to test and it works)
     2) Series and Mapping are done code behind by doing :

    ' For each Serie in properties
           For Each tSerieNode As XElement In pProperties.Root.Element("Series").Elements()
     
               ' Create a new serie, setup legend
               Dim tSerie As New SeriesMapping()
               tSerie.LegendLabel = tSerieNode.Element("LegendLabel").Value()
     
               ' For Each ItemMapping of the current tSerieNode
               For Each tItemNode As XElement In tSerieNode.Element("ItemMappings").Elements()
                   ' Create an item mapping, set datapoint, fieldname and add it to the current serie
                   Dim tImemMapping As New ItemMapping()
                   tImemMapping.DataPointMember = tItemNode.Element("DataPointMember").Value
                   tImemMapping.FieldName = tItemNode.Element("FieldName").Value
                   tSerie.ItemMappings.Add(tImemMapping)
               Next
     
               ' Set serie type
               SetSerieDefinitionFromSerieType(tSerie, tSerieNode.Element("SerieDefinition"))
     
               ' Display lables or not
               tSerie.SeriesDefinition.ShowItemLabels = CBool(tSerieNode.Element("ShowItemLabels").Value)
     
               ' Hide DataPointMarks
               If tSerieNode.Element("DisplayPointMarks") IsNot Nothing Then
                   If Not CBool(tSerieNode.Element("DisplayPointMarks").Value) Then
                       tSerie.SeriesDefinition.Appearance.PointMark.Stroke = New SolidColorBrush(Colors.Transparent)
                       tSerie.SeriesDefinition.Appearance.PointMark.StrokeThickness = 0
                       tSerie.SeriesDefinition.Appearance.PointMark.Fill = New SolidColorBrush(Colors.Transparent)
                   End If
               End If
     
               ' Activate HoverScope if defined and not none
               If tSerieNode.Element("HoverScope") IsNot Nothing AndAlso tSerieNode.Element("HoverScope").Value <> 0 Then
                   tSerie.SeriesDefinition.InteractivitySettings.HoverScope = InteractivityScope.Item
                   tSerie.SeriesDefinition.InteractivitySettings.SelectionScope = InteractivityScope.Item
                   tSerie.SeriesDefinition.InteractivitySettings.SelectionMode = ChartSelectionMode.Single
               End If
     
               ' Add Serie to chart
               tChart.SeriesMappings.Add(tSerie)
           Next

    3) ItemSource is set code behind with binding an ObservableCollection of a custom object
    4) Chart is always accessible in memory, i can modify everything in 'live' like titles, fonts ... here is how i modify the logaritmic / base

    _Chart.DefaultView.ChartArea.AxisY.IsLogarithmic = CBool(pEventArgs.PropertyValue)

    ' pEventArgs.PropertyValue could be 2, 5, 10 ..
     
    _Chart.DefaultView.ChartArea.AxisY.LogarithmBase = pEventArgs.PropertyValue

    my questions are : 
    - Have you tried to change logaritmic enable / disable  on multiples series and data bind with itemmapping like me ? 
    - Do I need to rebuild the chart series / item mapping ? (It looks like it's regenerating better, but I've still have a an issue between base 5 and 10 if i'm doing that)
    - Is there a function to force the chart to repaint, rebuild ? 

    Thanks for your answer, this is an emergency

    D,

  4. Evgeni "Zammy" Petrov
    Admin
    Evgeni "Zammy" Petrov avatar
    168 posts

    Posted 29 Dec 2010 Link to this post

    Hello Courouble,

    Onto your questions:

    • Indeed we must admit we were able to reproduce the problematic behavior in the described scenario. We have forwarded your feedback to our developers so they can address it for the service pack release scheduled for mid-January.
    • Generally this should not be needed. Just changing the IsLogarithmic property should be enough. There is problem with logarithmic scaling with Y axis and we are working on it.
    • You can call the RadChart.Rebind( ) method and that will cause the control to rebuild / repaint.

    Kind regards,
    Evgeni "Zammy" Petrov
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  5. André
    André avatar
    3 posts
    Member since:
    Jul 2010

    Posted 25 Jan 2011 Link to this post

    I created a RadChart with normal Y-Bar (see attached Picture "RadChart_normal.jpg").

    After calling the following code, all Bars disappear within my RadChart (see attached Picture "RadChart_log.jpg"):

    RadChartStatistic_Traffic.DefaultView.ChartArea.AxisY.IsLogarithmic = Convert.ToBoolean(RadioButtonLogarithm.IsChecked);
      
    RadChartStatistic_Traffic.Rebind();

    Switching back to IsLogarrithmic = false will bring back the Bars, but the Y-Bar is not shown correctly anymore (see attached Picture "RadChart_normal_again.jpg").

    So the mentioned RadChart.Rebind() makes it a little bit better, as before the control does not do anything after changing the IsLogarithmic property, but it does not solve the problem completly. Any sugestions?

    Thanks
    André
  6. Ves
    Admin
    Ves avatar
    2926 posts

    Posted 28 Jan 2011 Link to this post

    Hello André,

    I am afraid I will need a runnable example, demonstrating the issue. I have attached another example -- this time with multiple series. It works correctly on my side with bars, horizontal bars, line, spline, area and bubble series. Please, update it, so that it matches your scenario and send it back to us for review. Thank you.

    Regards,
    Ves
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  7. Stumple
    Stumple avatar
    5 posts
    Member since:
    May 2011

    Posted 18 May 2011 Link to this post

    Has this been fixed? We have the most recent download and I am seeing a similar issue.

    When I initially set the data it shows a scale of 0 to 80. Then I set the logarithmic scale option and use base Math.E.
    Then the scale jumps to range of 1 to 22.03k. I have seen it jump all the way up to over 1 trillion.
  8. Stumple
    Stumple avatar
    5 posts
    Member since:
    May 2011

    Posted 20 May 2011 Link to this post

    Picture that shows how scrwed up the chart is. This happens a lot. The top half of the chart doesn't event show a range. This time the range went up to 10 trillion. My data only goes to about 300.

    I scraped some of the areas of the chart because we have client data in it.
  9. Ves
    Admin
    Ves avatar
    2926 posts

    Posted 23 May 2011 Link to this post

    Hello,

    I just tested the  example attached to my previous reply and it worked as expected for me. Can you please provide more details about your scenario or provide us with an example, which would help us to reproduce the problem. In addition, please specify the version of the assemblies you are  using. Thank you.

    Best regards,
    Ves
    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
  10. Stumple
    Stumple avatar
    5 posts
    Member since:
    May 2011

    Posted 23 May 2011 Link to this post

    Here is one bug which I didn't see before because we do not have lablels on our chart. This bug was fixed by uncommenting the debind in the button click event. I thought that we always have to rebind the chart when making changes. I guess I can't send you zips so here is the .cs file for this one. More to come as I figure out how to get these issues to show. 

    Version 2011.1.419.1040

     

     

    using
      
       
      
       
      
      
    System; 
      
       
      
      
       
    using
      
       
      
       
      
      
    System.Collections.Generic; 
      
       
      
      
       
    using
      
       
      
       
      
      
    System.Linq; 
      
       
      
      
       
    using
      
       
      
       
      
      
    System.Net; 
      
       
      
      
       
    using
      
       
      
       
      
      
    System.Windows; 
      
       
      
      
       
    using
      
       
      
       
      
      
    System.Windows.Controls; 
      
       
      
      
       
    using
      
       
      
       
      
      
    System.Windows.Documents; 
      
       
      
      
       
    using
      
       
      
       
      
      
    System.Windows.Input; 
      
       
      
      
       
    using
      
       
      
       
      
      
    System.Windows.Media; 
      
       
      
      
       
    using
      
       
      
       
      
      
    System.Windows.Media.Animation; 
      
       
      
      
       
    using
      
       
      
       
      
      
    System.Windows.Shapes; 
      
       
      
      
       
    using
      
       
      
       
      
      
    Telerik.Windows.Controls.Charting; 
      
       
      
      
       
    using
      
       
      
       
      
      
    Telerik.Windows.Controls; 
      
       
      
      
       
    namespace
      
       
      
       
      
      
    RadControlsSilverlightApp1 
      
       
       
      
       
      
    {
      
       
      
       
      
      
       
      
      
    public partial class MainPage : 
      
    UserControl 
      
       
      
      
       
    {
      
       
      
       
      
    public 
      
    MainPage() 
      
       
       
      
       
      
    {
      
       
      
    InitializeComponent();
      
       
      
       
      
      
       
      
      
    this.Loaded += new RoutedEventHandler 
      
    (MainPage_Loaded); 
      
       
       
      
       
      
    }
      
       
      
       
      
      
       
      
      
    void MainPage_Loaded(object sender, RoutedEventArgs 
      
    e) 
      
       
       
      
       
      
    {
      
       
      
       
      
      
       
      
      
    this 
      
    .RadChart1.DefaultView.ChartArea.AxisX.LabelRotationAngle = 45; 
      
       
       
      
       
      
    RadChart1.DefaultView.ChartArea.AxisY.AutoRange = 
      
      
       
      
      
    false 
      
      
       
       
      
       
      
    RadChart1.DefaultView.ChartArea.AxisY.MinValue = 0;
      
       
      
    RadChart1.DefaultView.ChartArea.AxisY.MaxValue = 80;
      
       
      
    RadChart1.DefaultView.ChartArea.AxisY.Step = 10;
      
       
      
    RadChart1.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = 
      
      
       
      
      
    ScrollMode 
      
    .ScrollAndZoom; 
      
       
       
      
       
      
       
      
      
       
      
      
      
    //RadChart1.DefaultSeriesDefinition = new BarSeriesDefinition(); 
      
       
      
      
       
    SetMappings(RadChart1);
      
    BindChart();
      
    }
      
       
      
       
      
    private void SetMappings(RadChart 
      
    chart) 
      
       
       
      
       
      
    {
      
       
      
    AddSeriesMapping(chart, 
      
      
       
      
      
    "Value1" 
      
    ); 
      
       
       
      
       
      
       
      
      
       
      
      
      
    //AddSeriesMapping(chart, "Value2"); 
      
       
      
      
       
       
      
       
      
      
    //AddSeriesMapping(chart, "Value3"); 
      
       
      
      
       
       
      
       
      
      
    //AddSeriesMapping(chart, "Value4"); 
      
       
      
      
       
    }
      
       
      
       
      
    private void AddSeriesMapping(RadChart chart, string 
      
    propertyPath) 
      
       
       
      
       
      
    {
      
       
      
       
      
      
       
      
      
    SeriesMapping seriesMapping = new SeriesMapping 
      
    (); 
      
       
       
      
       
      
    seriesMapping.SeriesDefinition = 
      
      
       
      
      
    new LineSeriesDefinition 
      
    (); 
      
       
       
      
       
      
    seriesMapping.ItemMappings.Add(
      
      
       
      
      
    new ItemMapping(propertyPath, DataPointMember 
      
    .YValue)); 
      
       
       
      
       
      
    seriesMapping.ItemMappings.Add(
      
      
       
      
      
    new ItemMapping("Date", DataPointMember 
      
    .XCategory)); 
      
       
       
      
       
      
    chart.SeriesMappings.Add(seriesMapping);
      
       
      
    }
      
       
      
     
      
       
      
     
      
       
      
       
      
      
       
      
      
    private void 
      
    BindChart() 
      
       
       
      
       
      
    {
      
       
      
       
      
      
       
      
      
    Random r = new Random 
      
    (); 
      
       
       
      
       
      
       
      
      
       
      
      
    List<MyObject> list = new List<MyObject 
      
    >(); 
      
       
       
      
       
      
       
      
      
       
      
      
    for (int 
      
    i = 0; i < 60; i++) 
      
       
       
      
       
      
    {
      
       
      
    list.Add(
      
      
       
      
      
    new MyObject() { Value1 = r.Next(1, 60), Date = DateTime 
      
    .Now.AddDays(i).ToShortDateString(), Value2=r.Next(1, 1000), Value3 = r.Next(1, 1000), Value4=r.Next(1, 10000) }); 
      
       
       
      
       
      
    }
      
       
      
       
      
      
       
      
      
    for (int 
      
    i = 30; i < 35; i++) { 
      
       
       
      
       
      
    list[i].Value1 = 
      
      
       
      
      
    null 
      
      
       
       
      
       
      
    list[i].Date = 
      
      
       
      
      
    null 
      
      
       
       
      
       
      
    }
      
       
      
    RadChart1.ItemsSource = list;
      
       
      
    }
      
       
      
       
      
      
       
      
      
    private void Button_Click(object sender, RoutedEventArgs 
      
    e) 
      
       
       
      
       
      
    {
      
       
      
    RadChart1.DefaultView.ChartArea.AxisY.IsLogarithmic = 
      
      
       
      
      
    Convert 
      
    .ToBoolean(isLogarithmic.IsChecked); 
      
       
       
      
       
      
    RadChart1.DefaultView.ChartArea.AxisY.LogarithmBase = 
      
      
       
      
      
    Math 
      
    .E; 
      
       
       
      
       
      
       
      
       
      
       
      
      
       
      
      
      
    //RadChart1.Rebind(); 
      
       
      
      
       
    }
      
    }
      
     
      
       
      
       
      
    public class 
      
    MyObject 
      
       
      
      
       
    {
      
       
      
       
      
    public double? Value1 { get; set 
      
    ; } 
      
       
       
      
       
      
       
      
      
       
      
      
    public double Value2 { get; set 
      
    ; } 
      
       
       
      
       
      
       
      
      
       
      
      
    public double Value3 { get; set 
      
    ; } 
      
       
       
      
       
      
       
      
      
       
      
      
    public double Value4 { get; set 
      
    ; } 
      
       
       
      
       
      
       
      
      
       
      
      
    public string Date { get; set 
      
    ; } 
      
       
      
       
      
    }
      
       
      
     
      
       
      
    }
      
      
      

     

     

     

     

     

  11. Stumple
    Stumple avatar
    5 posts
    Member since:
    May 2011

    Posted 23 May 2011 Link to this post

    Here is something similar to the other issue we are seeing. With this example it shows how the axis-y range increases by about 10 everytime you toggle the log scale.

    This happens wheather you 

    RadChart1.Rebind();

    or not.  Just do the toggle twice and  the range will go to 90, then 100, then 110, and so on. What we are seeing is more serious where our range goes up to 1trillion.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using Telerik.Windows.Controls.Charting;
    using Telerik.Windows.Controls;
      
    namespace RadControlsSilverlightApp1
    {
        public partial class MainPage : UserControl
        {
            public MainPage()
            {
                InitializeComponent();
                this.Loaded += new RoutedEventHandler(MainPage_Loaded);
            }
      
            void MainPage_Loaded(object sender, RoutedEventArgs e)
            {
                this.RadChart1.DefaultView.ChartArea.AxisX.LabelRotationAngle = 45;
                RadChart1.DefaultView.ChartArea.AxisY.AutoRange = false;
                RadChart1.DefaultView.ChartArea.AxisY.MinValue = 0;
                RadChart1.DefaultView.ChartArea.AxisY.MaxValue = 80;
                RadChart1.DefaultView.ChartArea.AxisY.Step = 10;
                RadChart1.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = ScrollMode.ScrollAndZoom;
                RadChart1.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "dd-MMM";
                RadChart1.DefaultView.ChartArea.AxisX.IsDateTime = true;
                RadChart1.DefaultView.ChartArea.EnableAnimations = false;
                RadChart1.DefaultView.ChartArea.EnableStripLinesAnimation = false;
                RadChart1.DefaultView.ChartArea.EnableTransitionAnimations = false;
                  
      
                //radChart1.DefaultView = new ChartDefaultView();
                //radChart1.DefaultView.ChartArea.AxisY.AutoRange = false;
      
      
      
                RadChart1.DefaultView.ChartArea.AxisY.StripLinesVisibility = System.Windows.Visibility.Collapsed;
                RadChart1.DefaultView.ChartArea.AxisX.StripLinesVisibility = System.Windows.Visibility.Collapsed;
      
                //RadChart1.DefaultSeriesDefinition = new BarSeriesDefinition();
                SetMappings(RadChart1);
                BindChart();
            }
      
            private void SetMappings(RadChart chart)
            {
                AddSeriesMapping(chart, "Value1");
                //AddSeriesMapping(chart, "Value2");
                //AddSeriesMapping(chart, "Value3");
                //AddSeriesMapping(chart, "Value4");
            }
      
            private void AddSeriesMapping(RadChart chart, string propertyPath)
            {
                SeriesMapping seriesMapping = new SeriesMapping();
                seriesMapping.SeriesDefinition = new LineSeriesDefinition();
                seriesMapping.SeriesDefinition.ShowItemLabels = false;
                seriesMapping.ItemMappings.Add(new ItemMapping(propertyPath, DataPointMember.YValue));
                seriesMapping.ItemMappings.Add(new ItemMapping("Date", DataPointMember.XCategory));
                chart.SeriesMappings.Add(seriesMapping);
            }
      
      
      
            private void BindChart()
            {
      
                Random r = new Random();
                List<MyObject> list = new List<MyObject>();
                for (int i = 0; i < 60; i++)
                {
                    list.Add(new MyObject() { Value1 = r.Next(1, 60), Date = DateTime.Now.AddDays(i), Value2=r.Next(1, 1000), Value3 = r.Next(1, 1000), Value4=r.Next(1, 10000) });
                }
      
                for (int i = 30; i < 35; i++) {
                    list[i].Value1 = null;
                    list[i].Date = null;
                }
                RadChart1.ItemsSource = list;
            }
      
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                RadChart1.DefaultView.ChartArea.AxisY.IsLogarithmic = Convert.ToBoolean(isLogarithmic.IsChecked);
                RadChart1.DefaultView.ChartArea.AxisY.LogarithmBase = Math.E;
                  
                RadChart1.Rebind();
            }
        }
      
      
        public class MyObject
        {
            public double? Value1 { get; set; }
            public double Value2 { get; set; }
            public double Value3 { get; set; }
            public double Value4 { get; set; }
            public DateTime? Date { get; set; }
        }
      
      
    }
  12. Ves
    Admin
    Ves avatar
    2926 posts

    Posted 27 May 2011 Link to this post

    Hello,

    It seems the issue is reproduced when AutoRange is set to false. Please, use the built-in automatic range calculation (i.e. AutoRange = true) when using logarithmic axis.  I have forwarded this issue to our developers for investigation.

    Kind regards,
    Ves
    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
Back to Top