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

CartesianCustomAnnotation with Zoom ability

6 Answers 132 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Majid
Top achievements
Rank 1
Majid asked on 06 Jan 2014, 08:47 AM

I

 have a problem with CartesianCustomAnnotation. there is a RadCartesianChart with zoom ability,

<telerik:RadCartesianChart x:Name="chart"   Zoom="{Binding Zoom, Mode=TwoWay}" >
         <telerik:RadCartesianChart.Behaviors >
                       <telerik:ChartPanAndZoomBehavior ZoomMode="Both" PanMode="Horizontal" MouseWheelMode="Zoom" />
       </telerik:RadCartesianChart.Behaviors>
<!--some codes-->
</<telerik:RadCartesianChart >
then I programmatically added a triangle as CartesianCustomAnnotation
System.Windows.Shapes.Polygon triangle = new Polygon();
//some codes
 chart.Annotations.Add(new Telerik.Windows.Controls.ChartView.CartesianCustomAnnotation
            {  HorizontalValue = somePointX,//DateTime
                VerticalValue=.somePointY,
                Content =  triangle
            } );
As the below figure shows, the problem is  when I changed the chart's zoom, the shape size does not change, actually I want the vertexes of triangles sticks to their initial coordinates, and triangle resize itself with changing zoom.

6 Answers, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 07 Jan 2014, 12:49 PM
Hello,

The annotation is a visual element positioned on the chart plot area. The Cartesian Custom Annotation renders its Content starting at the specified (HorizontalValue, VerticalValue) position. It cannot change its size according to the area you have zoomed. This behavior of the annotation is not supported out of the box. It will always have the size that is initially set. You will need to calculate the size of your annotation element depending on your calculations and the way it best works for you.

Regards,
Peshito
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Majid
Top achievements
Rank 1
answered on 07 Jan 2014, 01:58 PM

I used chartZoomChanged event and now the shape can resize itself, thanks. But now I encounter another weird problem. sometimes after panning, such that part of certain annotations gone out of box, suddenly  some of the annotations disappeared while half of it should be visible, (take a look the following image) and when I panned back the annotations appear again. is there a bug related to annotations?







0
Peshito
Telerik team
answered on 08 Jan 2014, 04:38 PM
Hi,

This does not seem like a bug. The custom annotation is a singular point representation which will change its place on the plot area depending on the panning you have performed. This is why this annotation is not positioned next to the other. The plot area has changed as well as the annotation's place on the plot area.

Regards,
Peshito
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Majid
Top achievements
Rank 1
answered on 21 Jan 2014, 08:04 AM

My problem relating to sunndenly disappearing

CustomAnnotaion doesn't solve. moreover,  I encounter the problem in some new cases. when I pan through horizontal axis, and stop in certain points, the whole of customAnnotaion disappears,while the whole shape is in view box and should be visible, What shoud I do?  I used

DateTimeCategoricalAxis, may be the problem is related to horizontal axis.

<chart:RadCartesianChart.HorizontalAxis>
     <chartView:DateTimeCategoricalAxis   PlotMode="OnTicksPadded"  GapLength="0.4"     LabelTemplate="{StaticResource             axisLabelTemplate}"       DateTimeComponent="Date"          MajorTickInterval="15" >
           <telerik:CategoricalAxis.MajorTickStyle>
                       <Style TargetType="Rectangle">
                           <Setter Property="Fill" Value="Orange"/>
                       </Style>
                   </telerik:CategoricalAxis.MajorTickStyle>
               </chartView:DateTimeCategoricalAxis>
           </chart:RadCartesianChart.HorizontalAxis>


0
Majid
Top achievements
Rank 1
answered on 21 Jan 2014, 11:27 AM

I found some issues,:

First of all, when I replace DateTimeContinuousAxis to DateTimeCategoricalAxis, the occurrences of Annotation's disappearing, due to panning, reduced, actually only when the point where annotation sticks to (HorizontalValue, VerticalValue) go out of the view box such action happens. I guess in this situation, some behind codes changes the visibility of annotation to collapsed, is there any way to disable this action?



second: In the horizontal axis I have data include 4 days of week, when I use DateTimeContinuousAxis instead of DateTimeCategoricalAxis, a gap appears on the chartIs there a way to force DateTimeContinuousAxis to don't show these days where does not include any useable data?



0
Peshito
Telerik team
answered on 23 Jan 2014, 09:59 AM
Hi,

When using DateTimeCategorical axis along with annotations you need to be sure that the value of the annotation match the exact same category value used for creating the chart. To solve this, you can attach for the Loaded annotation's event like shown below:
private void customAnnotation_Loaded(object sender, RoutedEventArgs e)
{
    
var customAnnotation = sender as Telerik.Windows.Controls.ChartView.CartesianCustomAnnotation;
            customAnnotation.HorizontalValue = new DateTime(2013, 11, 12, 04, 30, 00);

}
and set its value there.

Onto your other issue, the DateTimeContinuous axis is like a numerical axis but the axis value range consists of DateTime values which are always sorted chronologically. You can use use MajorStepUnit and MajorStep properties to further customize it.

Regards,
Peshito
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
ChartView
Asked by
Majid
Top achievements
Rank 1
Answers by
Peshito
Telerik team
Majid
Top achievements
Rank 1
Share this question
or