This is a migrated thread and some comments may be shown as answers.

Include Annotations when automatically calculating axis range

3 Answers 62 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 14 Apr 2014, 08:51 AM
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

3 Answers, 1 is accepted

Sort by
0
Petar Marchev
Telerik team
answered on 16 Apr 2014, 07:13 AM
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.

 
0
Alexander
Top achievements
Rank 1
answered on 17 Apr 2014, 08:25 AM
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
0
Petar Marchev
Telerik team
answered on 21 Apr 2014, 03:04 PM
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.

 
Tags
ChartView
Asked by
Alexander
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
Alexander
Top achievements
Rank 1
Share this question
or