This is a migrated thread and some comments may be shown as answers.
CartesianGridLineAnnotation showing at the wrong value
6 Answers 27 Views
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 17 Nov 2015, 10:45 AM

I'm having a problem adding CartesianGridLineAnnotation to series of square cartesian plots. I have four square charts, each going from x to -x in each axis with 0,0 in the middle. I want to add a dark gridline to the 0, 0 point and CartesianGridLineAnnotation looked like the perfect thing for this. I added the following code :

  

<telerik:RadCartesianChart.Annotations>
  
    <telerik:CartesianGridLineAnnotation Axis="{Binding AxisX}" Value="0" />
  
    <telerik:CartesianGridLineAnnotation Axis="{Binding AxisY}" Value="0" />
  
</telerik:RadCartesianChart.Annotations>​

However when I view my charts the annotation appears ​1 pixel left of the 0 value on the horizontal axis and 1 pixel above the 0 value on the vertical axis. This is true for the first two charts, the second two the vertical axis line seems to be in the perfect position yet they are being drawn with the exact same code. 

Whenever the window size of the app is changed the charts are resized to maintain a square charting area. I notice as I resize the charts the annotations move from being one side of the 0 value, to being on the 0 value, then being the other side of the 0 value. 

I am currently using an older version of the Telerik dlls (2013.3.1204.40), is there a fix/workaround that will ensure that the annotation lines are drawn exactly on the specified value? 

I've attached a picture of the four charts in question on their initial display. You can see that the black annotations do not line up with the gray grid lines.

Thanks for the help.

6 Answers, 1 is accepted

Sort by
0
Andrew
Top achievements
Rank 1
answered on 17 Nov 2015, 10:49 AM
The forum errored when I tried to post the images so I will try adding them again. 
0
Evgenia
Telerik team
answered on 18 Nov 2015, 09:16 AM
Hi Andrew,

I was able to reproduce the displacement of the CartesianGridlineAnnotation based on your information provided. The problem is caused by the fact that the annotation does not snap to the tick of the axis by default. We have a public feedback item where you might vote for this visual glitch to be fixed -- here is link to it. Please stay tuned for any changes. 

Unfortunately there is not an easy workaround for this. The onliest thing we can suggest is that you render a custom UI element on the top of the chart and use our Conversion API to position it. Let me know if you need this workaround and we'll provide you with a code sample demonstrating it.

We are sorry for any inconvenience caused.

Regards,
Evgenia
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Andrew
Top achievements
Rank 1
answered on 18 Nov 2015, 09:55 AM

Hi Evgenia, 

Thanks for the reply. I have up voted the feedback item. Would you be able to provide an example of the suggested work around? 

0
Evgenia
Telerik team
answered on 19 Nov 2015, 01:52 PM
Hi Andrew,

You might find attached a project that demonstrates the workaround I mentioned. Here's in brief what we did -- we add Canvas on top of the chart's PlotArea. It will be used to position two UIElement-s -- Rectangle-s in our case at the place where we had our vertical and horizontal annotations. Now we need to wire to LayoutUpdated event of the chart and do the needed calculations to position our Rectangles at the 0 tick of the Horizontal and Vertical Axes and add them to the PlotArea. 
Since we want this to work in every case where the axes range might change like zooming and panning behavior for example we wire to VisibleRangeChanged event of the axes and call ScheduleUIUpdate method there as well.

Regards,
Evgenia
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Andrew
Top achievements
Rank 1
answered on 23 Nov 2015, 12:01 PM

Hi Evgenia,

The example project you gave me works great, however it is using a much newer dll version (2016.1.1119.40) than I am (2013.3.1204.40). Your fix requires ActualVisibleRangeChanged and NumericalRangeChangedEventArgs which are not available in the dll version I'm using. I have tried to adapt the code you gave me using properties I have available but the annotations are always displayed far out of position. Could you suggest a fix that works on the 2013.3.1204.40 version of the dlls? 

Thanks again for the help,

Ewan. 

0
Evgenia
Telerik team
answered on 23 Nov 2015, 03:18 PM
Hello Andrew,

Unfortunately these events were not yet shipped with 2013.3.1204.40 binaries version. The onliest one you can use is LayoutUpdated as demonstrated in the attached project and it should be absolutely sufficient for you if you don't use Zoom and Pan Behavior of the Chart or dynamic series (series that get added/removed dynamically) or any other feature that might cause the axes range to be recalculated.
For any other case where those events are needed I recommend that you upgrade to our latest binaries like Q3 SP1 2015 for example. Actually we highly encourage our clients to use the latest binaries that we ship so that they are up-to-date with our present bug fixes, new features and have full support for them.

Regards,
Evgenia
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Asked by
Andrew
Top achievements
Rank 1
Answers by
Andrew
Top achievements
Rank 1
Evgenia
Telerik team
Share this question
or