isLogarithmic & Zero

10 posts, 1 answers
  1. Richard
    Richard avatar
    72 posts
    Member since:
    Feb 2009

    Posted 19 Sep 2012 Link to this post

    Good morning all, 

    Hopefully this is a quick one, I have a chart that uses the isLogarithmic property, it works perfectly when none of the data series have a 0, but it goes a but crazy when one of them does have 0. 

    Is this a simple setting that I'm missing ? 

    p.s. are we not allowed to post attachments any more ? 

    Cheers,
    Richard


    With Zero

    Without Zero

  2. Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 21 Sep 2012 Link to this post

    Hi Richard,

    The main problem is that logarithm of zero or of a smaller number (no matter what is the logarithm base) is not defined for real numbers.

    However the RadChart handles this in a different way than your result in the attached image. We could not reproduce your result , based on the information you have provided.

    I have attached our test project. We need some additional information so we can track-down the problem locally. It would be helpful if you could modify it so that it reproduces your results.

    Regards,

    Petar Kirov
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

  3. DevCraft banner
  4. Richard
    Richard avatar
    72 posts
    Member since:
    Feb 2009

    Posted 04 Oct 2012 Link to this post

    Hi Petar 

    I was not able to open your solution directly as it's using Silverlight v5 and I'm limited to v4 in my current environment. However I was able to open the solution in notepad and recreate your code in a v4 project.

    The results where the same as my own tests were the graph was using crazy ranges. 

    Is this an issue with the telerik SL v4 controls that was fixed in v5 ? and if so will this fix make it in to the v4 controls ? 

    with zero
    with out zero

    Cheers,
    Richard
  5. Evgenia
    Admin
    Evgenia avatar
    1406 posts

    Posted 09 Oct 2012 Link to this post

    Hi Richard,

    The issue is not related to the version of Silverlight. I tested it and the results are the same (as the screenshots attached in your second post). Here is the project  I sent before made under Silverlight 4. The bar with 0 value has 0 label. Is there anything else you are setting in the code? Could you please open a formal support thread and send us your runnable sample where this reproduces so that we can inspect it locally?

    Regards,
    Evgenia
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Richard
    Richard avatar
    72 posts
    Member since:
    Feb 2009

    Posted 09 Oct 2012 Link to this post

    Hi Evgenia,

    That's very strange, I have downloaded and ran your project and the scale is still all wrong. Going up to 10 billion. 
    So I'd assume it's the version of the toolkit I have on my machine (2012.2.709.1040), but I downloaded the latest internal build (2012.2.1001.1040) and the results were the same. Your project did not have the dll's locally in the project so I don't know which version you were on or if they would have worked on my machine. 

    Thanks for your help, I'll raise a formal ticket.

    Thanks,
    Richard
  7. Evgenia
    Admin
    Evgenia avatar
    1406 posts

    Posted 09 Oct 2012 Link to this post

    Hello Richard,

    Follow up on the problem you have.
    First, please accept my apologies for the misleading my last post caused. I double checked the code and I should unfortunaly admit that what you receive as result on the YAxis when one of the values in your datasource is 0 is a bug in RadChart. It reproduced on my side. Our developers are notified about this issue.
    What I can suggest as a workaround is that you filter any potential 0-s in your data. For the purpose you may choose from one of the following approaches:

    1. Use our RadChart's Filtering feature:

    private void InitChart()
            {
                chart.DefaultView.ChartArea.AxisY.IsLogarithmic = true;
                chart.DefaultView.ChartArea.AxisY.LogarithmBase = 10;
                chart.SeriesMappings.Add(new SeriesMapping());           
                chart.SeriesMappings[0].SeriesDefinition = new HorizontalBarSeriesDefinition();
                chart.SeriesMappings[0].ItemMappings.Add(new ItemMapping("Value", DataPointMember.YValue));
                chart.SeriesMappings[0].ItemMappings.Add(new ItemMapping("Cat", DataPointMember.XCategory));
                chart.ItemsSource = GetData();
      
                ChartFilterDescriptor descriptor = new ChartFilterDescriptor();
                descriptor.Member = "Value";
                descriptor.Operator = FilterOperator.IsNotEqualTo;
                descriptor.Value = 0;
                this.chart.FilterDescriptors.Add(descriptor);          
            }

    2. Filter your datasource before giving it to the chart via Linq query for example. More information on filtering with Linq can be found here.

    P.S. You may find your Telerik points updated as a sign of gratitude for pointing this problem out.

    Kind regards,
    Evgenia
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  8. Richard
    Richard avatar
    72 posts
    Member since:
    Feb 2009

    Posted 09 Oct 2012 Link to this post

    Thanks Evgenia , I have been putting a check in my code that if any of my datapoints = 0 then the isLogarithmic gets set to false. 

    I didn't know that filter descriptors could be applied directly to the chart. That's a good tip!

    Cheers,
    Richard

  9. Richard
    Richard avatar
    72 posts
    Member since:
    Feb 2009

    Posted 22 Jul 2013 Link to this post

    Hi ,

     I just wanted to follow up on this issue, I'm using the latest official release of the tools and it still seems to have an issue when one of the data series is 0. Is there any work around other than removing the series  ? 

    Cheers,
    Richard
  10. Answer
    Evgenia
    Admin
    Evgenia avatar
    1406 posts

    Posted 25 Jul 2013 Link to this post

    Hello Richard,

     Recently we focused on the development and improvements of our newest Charting control - RadChartView. RadChartView is a control that addresses some of the limitations and deficiencies that we have identified in the RadChart implementation over the years (we chose to implement a separate control in order not to break backwards compatibility). We highly recommend our users to switch to this new chart wherever possible because of its proven exceptional performance and improvements.
    Althought there is no straightforward migration path between RadChart and RadChartView (migration is possible but some concepts are implemented differently) you can find a great topic comparing both controls features here.

    RadChartView also supports Logarithmic axis as you might see in our documentation. I prepared a sample with RadChartView and the data from your images and I should happily say that even though there is 0 value in the data, the chart handles it and everything is shown as expected. Below is my test code and the attachment is a snapshot of the result I get:

    public MainPage()
       {
           InitializeComponent();
           RadCartesianChart chart = new RadCartesianChart();
           chart.VerticalAxis = new CategoricalAxis() ;
           chart.HorizontalAxis = new LogarithmicAxis() { LogarithmBase = 10 };
           BarSeries bar = new BarSeries();
           bar.ShowLabels = true;
           bar.DataPoints.Add(new CategoricalDataPoint() { Value = 80 });
           bar.DataPoints.Add(new CategoricalDataPoint() { Value = 8800 });
           bar.DataPoints.Add(new CategoricalDataPoint() { Value = 5 });
           bar.DataPoints.Add(new CategoricalDataPoint() { Value = 0 });
           bar.DataPoints.Add(new CategoricalDataPoint() { Value = 300 });
           bar.DataPoints.Add(new CategoricalDataPoint() { Value = 2500 });
           bar.DataPoints.Add(new CategoricalDataPoint() { Value = 5000 });
           bar.DataPoints.Add(new CategoricalDataPoint() { Value = 100 });
           bar.DataPoints.Add(new CategoricalDataPoint() { Value = 10 });
           chart.Series.Add(bar);           
           this.LayoutRoot.Children.Add(chart);
       }


    To summarize - I suggest that you switch to RadChartView your custom scenario and use it in any future charting projects if possible. Regards,
    Evgenia
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  11. Richard
    Richard avatar
    72 posts
    Member since:
    Feb 2009

    Posted 26 Jul 2013 Link to this post

    Thanks Evgenia , using the ChartView as worked very nicely. 

    Cheers,
    Richard

Back to Top
DevCraft banner