Lineseries PointTempate strech width and height

4 posts, 1 answers
  1. Sivakumar
    Sivakumar avatar
    27 posts
    Member since:
    Dec 2015

    Posted 17 Mar Link to this post

    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 ?

     

     

     

  2. Sivakumar
    Sivakumar avatar
    27 posts
    Member since:
    Dec 2015

    Posted 20 Mar in reply to Sivakumar Link to this post

    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>

     

     

  3. UI for WPF is Visual Studio 2017 Ready
  4. Answer
    Martin
    Admin
    Martin avatar
    1101 posts

    Posted 21 Mar Link to this post

    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.
  5. Sivakumar
    Sivakumar avatar
    27 posts
    Member since:
    Dec 2015

    Posted 21 Mar in reply to Martin Link to this post

    Thanks Martin
Back to Top