Include Annotations when automatically calculating axis range

4 posts, 0 answers
  1. Alexander
    Alexander avatar
    77 posts
    Member since:
    Apr 2013

    Posted 14 Apr 2014 Link to this post

    Hello,

    is there a way to automatically include the chart annotations (e.g. grid lines) into the calculation of the axis minimum/maximum?
    I want these annotations always to be visible, but I don't want to calculate minimum/maximum on my own if not necessary.
    Something like "MaxMinimum" and "MinMaximum" (similar to MaxWidth/MinWidth) would be ideal...

    Alex
  2. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 16 Apr 2014 Link to this post

    Hello Alexander,

    There is no out-of-the-box means that will allow you to specify such an annotation's behavior. Perhaps you will find the ActualVisibleRange property of the axes useful (LinearAxis, LogarithmicAxis and DateTimeContinuousAxis). If you need further assistance I will ask that you send us a screenshot (drawing of some sort) that depicts the results you are after. You can also give us more details so we can suggest a work-around for this.

    Regards,
    Petar Marchev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Alexander
    Alexander avatar
    77 posts
    Member since:
    Apr 2013

    Posted 17 Apr 2014 in reply to Petar Marchev Link to this post

    Thanks for your answer.

    I have changed the way in which I manage my data that I want to be drawn.
    I tried to use some viewmodel approach as I have to prepare the data to be drawn. However, this means a lot of extra work to be done (I have to somehow synchronize the viewmodel data with the raw data - which in turn has to be synchronized with the Chart - leading to a lot of plumbing code and wasted computing time).

    This is why I preferred to went back to the scheme that we used with our previous charting solution: we simply generate the data points manually. And now it is not a problem to calculate the minimum/maximum for the resulting chart. (Additionally, I found the TickOrigin property with which we can avoid ugly tick positions).

    The only stumbling block is that the DataPoint.DataItem property is readonly, the underlying field is internal and there is no constructor taking a data item! However, I have to set the additional information on the data point to bind in the point template. At the moment I am using reflection to generate a delegate to initialize the field - however this seems a littly bit hacky.

    Alex
  5. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 21 Apr 2014 Link to this post

    H Alex,

    I am not sure that I understand you very well. Perhaps you can use the approach in the attached project. You can create a custom utilities class with attached properties and ensure that an annotation is in the visible area while zooming.

    I can suggest other solutions as well. Another would be not to use annotations but instead use your own visuals. You can place the visuals in a Canvas and lay the Canvas over the chart. Then you can find the coordinates for a value (DateTime value) from the conversion api of the chart (ConvertDataToPoint method). After you find the absolute position (take into consideration the PanOffset) you can set the Left and Top of the custom visual.

    Both of these approaches do not require that you use unbound mode. And I suggest you adopt one of them, because I do not see a very good reason not to use the chart data binding capabilities.

    The DataItem is set internally and is only set when the chart is in a databound mode. Let us know if we can assist you further.

    Regards,
    Petar Marchev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top