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

Lineseries PointTempate strech width and height

3 Answers 94 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Sivakumar
Top achievements
Rank 1
Sivakumar asked on 17 Mar 2016, 09:22 AM

My chart having step line series along with data point highlighting based on conditions.I would like stretch height and width of point template to occupy all the space.I am facing issue With the rectangle fixed size height and width , it is not aligning properly during zooming.Please see attached..

1.I need to auto adjust or stretch height and width of point template to along with particular line height and width. 

2.How can i access relative parent point template ?

 

 

 

3 Answers, 1 is accepted

Sort by
0
Sivakumar
Top achievements
Rank 1
answered on 21 Mar 2016, 02:00 AM

Hi Team ,

Please suggest the solution...I need to highlight the data point or background of line based on data item conditions.Please refer image from above post...

 

<DataTemplate x:Key="LinePointTemplate" >
                       <Rectangle Width="16" Height="28"  Stroke="Transparent" >
                           <Rectangle.Style>
                               <Style  TargetType="Rectangle">
                                   <Setter Property="Fill" Value="Transparent" />
                                   <Style.Triggers>
                                       <DataTrigger Binding="{Binding DataItem.IsPass}" Value="False">
                                           <Setter Property="Fill" Value="Red" />
                                       </DataTrigger>
                                       <DataTrigger Binding="{Binding IsSelected}" Value="True">
                                           <Setter Property="Fill" Value="Yellow" />
                                       </DataTrigger>
                                   </Style.Triggers>
                               </Style>
                           </Rectangle.Style>
                       </Rectangle>
 
                   </DataTemplate>

 

 

0
Accepted
Martin Ivanov
Telerik team
answered on 21 Mar 2016, 10:30 AM
Hello Sivakumar,

In order to highlight the item Rectangle in the PointTemplate based on a condition you can use its Stroke property for example. Or you can change its color as demonstrated in the code snippet from your last reply. Also, another approach of setting the colors in the PointTemplate is instead of using data triggers to binding the Fill property directly to the property from the model (DataItem.IsPass or IsSelected) with an IValueConverter.

About stretching the element in the PointTemplate, since all chart elements are drawn and positioned in a Canvas you will need to manually recalculate the size of the Rectangle element each time the chart's layout is updated. In your case you can do it when the PanOffsetChanged or ZoomChanged events of the chart are fired.

As for accessing the relative parent point template, I am not sure that I understand what this means. Can you please clarify it for me? Also, if you want to change something in the elements in the PointTemplate at runtime you can bind them to the view model of the data point. If you want to get the data point under the mouse you can use the Conversion API of RadChartView.

Regards,
Martin
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Sivakumar
Top achievements
Rank 1
answered on 22 Mar 2016, 03:28 AM
Thanks Martin
Tags
ChartView
Asked by
Sivakumar
Top achievements
Rank 1
Answers by
Sivakumar
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or