Is There A Way To Use A Value Converter

2 posts, 0 answers
  1. Travis
    Travis avatar
    8 posts
    Member since:
    Nov 2010

    Posted 11 Jan 2011 Link to this post

    I am trying to graph a property of a class using some sort of a converter.  It is really hard to explain so let me try with this pseudo-code example (note I'm not working with Files or even Sizes -- this is just the easiest example I could think of):

    class FileSize {
      ulong SizeInBytes{get;set;}
      DateTime Date{get;set;}
    }

    I then have a SeriesMapping which maps the Date (XValue) to the SizeInBytes (YValue).  However, I would want the Y Scale to be in MB, not B.  Unfortunately the object is being returned from a WebService so the class is auto-generated, and Silverlight does not have extension properties, so I am unable to add a Property to the class which does the conversion for me.  Is there a way to have the Chart perform the conversion for me?  I could only think of three ways:
    1) Inside the ItemMapping there is a place for something such as an IValueConverter (couldn't find that).
    2) Inside the AxisY have something there which makes the values convert. (Didn't find anything here either).
    3) Some sort of styling of the Vertical Axis to convert the value only on the Axis labels, not on the values themselves (most ideal for performance reasons).  I couldn't drill down far enough to find anything I could add converters to a style for the 2D Y Axis.

    Is there any way to achieve what I am looking for?  Ideally I would like to format/convert the labels of the Axis.  I really don't want to have to create a new object and iterate over thousands of objects in the list just so I can show a ulong as a float with decimals.


    Travis
  2. Evgenia
    Admin
    Evgenia avatar
    1437 posts

    Posted 14 Jan 2011 Link to this post

    Hello Travis,

    After carefully reading your problem I got up with the idea that your suggestion 3) is the best and here is how you can achieve it:
    Use Custom Numeric Format Strings to represent the values in MB and remain the Values of the Bars unchanged:
    radChart1.DefaultView.ChartArea.AxisY.DefaultLabelFormat = "0,,";
    The "," will divide the Axis Value by 1000 so add 2 "," to gain the MB representation.


    Kind regards,
    Evgenia
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Back to Top