Display 1 values with logarithmic scale

5 posts, 0 answers
  1. Massimo
    Massimo avatar
    26 posts
    Member since:
    Apr 2013

    Posted 10 Aug Link to this post

    Hi, I'm struggling with a small display issue:

    I have a bar chart with logarithmic Y scale. Evetyng is ok but if a bar has the value of 1 is not displayed. And this is correct because the logarithm of 1 is 0.
    So there is no difference between a bar is not present and a bar with value 1.

    I tried to set the minimum value of 0.5 but it's only displayed a gap between the X axis and the bars.

    Is there a way to display small Bar when the values is 1? Like setting a small border or a padding?

  2. Martin Ivanov
    Admin
    Martin Ivanov avatar
    1410 posts

    Posted 15 Aug Link to this post

    Hello Massimo,

    To achieve your requirement you can set a MinHeight for the Border elements representing the data points. You can do that via the DefaultVisualStyle property of the series.
    <telerik:BarSeries.DefaultVisualStyle>
        <Style TargetType="Border">
            <Setter Property="MinHeight" Value="1" />
            <Setter Property="Background" Value="Green" />
        </Style>
    </telerik:BarSeries.DefaultVisualStyle>

    Or you can set the OriginValue property of the bar series. The property determines the start value from where to bar will start drawing.

    Regards,
    Martin Ivanov
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  3. Massimo
    Massimo avatar
    26 posts
    Member since:
    Apr 2013

    Posted 18 Aug Link to this post

    Thanks for your help, but I'm not able to make it works.

    The min height works, but the bar is below the axis and it's not visible.

    Eventhe border is always transparent.. I think is an issue with VisualStudio2013 style

  4. Martin Ivanov
    Admin
    Martin Ivanov avatar
    1410 posts

    Posted 23 Aug Link to this post

    Hello Massimo,

    The chart doesn't depend much on the applied theme and the described behavior probably is not because of the theme. The bar is positioned under the axis because it is drawn starting from its value to the origin value which in this case should be 1. When you set the MinHeight, the bar will be draw from its value (in your case 1) to the MinHeight value in down direction. The bar is not displayed because it is clipped to the plot area (the area between the axes).

    In order to resolve this you could set the Minimum of the axis to a lower value. However, in your scenario you can't do this because the axis is logarithmic. In this case I could suggest you to apply a small margin in the default visual style for the bars with value 1. You can do that via the DefaultVisualStyleSelector property of the series. Or using an IValueConverter. You can see this approach demonstrated in the attached project. I hope it helps.

    Regards,
    Martin Ivanov
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  5. Massimo
    Massimo avatar
    26 posts
    Member since:
    Apr 2013

    Posted 23 Aug in reply to Martin Ivanov Link to this post

    thanks, it works perfectly!
Back to Top