We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Stripline and Label

Thread ID:

Created:

Updated:

Platform:

Replies:

145521 Jun 26,2019 02:22 PM UTC Aug 1,2019 01:17 PM UTC WPF 7
loading
Tags: SfChart
Tom
Asked On June 26, 2019 02:22 PM UTC

If I have a stripline with a label, and the stripline is small, the label is clipped. Is there any way of forcing the whole of the label to be visible in these circumstances,
thanks.

Muneesh Kumar G [Syncfusion]
Replied On June 27, 2019 09:42 AM UTC

Hi Tom, 
 
Greetings from Syncfusion.  
 
We have analyzed your requirement and we would like to inform you that this is our default behavior of strip line. But you can achieve your requirement by adding TextAnnotation with required position as per the below code snippet.  
 
Code snippet 
 
<chart:SfChart  Margin="10" 
                       x:Name="chart" > 
            <chart:SfChart.Annotations> 
                <chart:TextAnnotation X1="1" Y1="20" 
                       Text="This text shows the stripline"/> 
            </chart:SfChart.Annotations> 
 
            <chart:SfChart.PrimaryAxis> 
                <chart:NumericalAxis> 
                    <chart:NumericalAxis.StripLines> 
                        <chart:ChartStripLine Start="1" Width="1"  
                                              Background="Yellow" 
                    </chart:NumericalAxis.StripLines> 
                </chart:NumericalAxis> 
            </chart:SfChart.PrimaryAxis> 
 
            <chart:ScatterSeries XBindingPath="XValue" YBindingPath="YValue" 
                            
                         .. 
 
  
We have prepared a sample based on this, please find the sample from the following location.  
 
 
Screenshot: 
 
 
Please refer below user documentation for more details about TextAnnotation.  
 
 
Please let us know if you have any other queries.  
 
Thanks, 
Muneesh Kumar G.   


Tom
Replied On July 2, 2019 06:57 AM UTC

Thank you, this essentially works, however using the Label property of a strip line on the yaxis, the text is centred in the middle of the chart. Is there any way to achieve this with the TextAnnotation .. ie I can set my y-value for it, so it appears vertically in the middle of my strip line, but if I don't know how the chart is going to scale the x-axis, is there a way to auto centre it horizontally?
thanks

Muneesh Kumar G [Syncfusion]
Replied On July 3, 2019 10:10 AM UTC

Hi Tom, 
 
Thanks for your update,  
 
You can achieve this requirement by setting annotation X1 position based on stripline Start and Width value as per the below code snippet.  
 
Code snippet 
 
public MainWindow() 
        { 
            InitializeComponent(); 
 
            annotation.X1 = stripline.Start + (stripline.Width / 2); 
        } 
 
 
Set HorizontalAlignment as Center in TextAnnotation.  
 
   <chart:SfChart.Annotations> 
                <chart:TextAnnotation x:Name="annotation" 
                                      HorizontalAlignment="Center" 
                                      Y1="20" Text="This text shows the stripline"/> 
            </chart:SfChart.Annotations> 
            <chart:SfChart.PrimaryAxis> 
                <chart:NumericalAxis> 
                    <chart:NumericalAxis.StripLines> 
                        <chart:ChartStripLine Start="1" Width="1" x:Name="stripline" 
                                              Background="Yellow"/> 
                    </chart:NumericalAxis.StripLines> 
                </chart:NumericalAxis> 
            </chart:SfChart.PrimaryAxis> 
 
 
Please let us know if you have any other queries.  
 
Regards,
Muneesh Kumar G.  
 


Tom
Replied On July 3, 2019 11:25 AM UTC

Sorry I meant it rather the other way round,
So if I take your chart below as an example, if i set the label of the stripline as "This text shows the stripline" it would be automatically vertically centred in the middle of the stripline vertically. You have achieved the same by setting y1="20" on the TextAnnotation, but if my y-axis was to be autoscaled and thus I don't know at that point the y1 co-ordinate to give it, how can it be centred vertically automatically?
Hope that makes sense,

Muneesh Kumar G [Syncfusion]
Replied On July 3, 2019 01:03 PM UTC

Hi Tom,, 
 
We have analyzed your requirement and you can achieve this by setting VerticalAlignment as Center and Setting annotation’s Y1 position in Y-Axis ActualRangeChanged event as per the below code snippet.  
 
Code snippet 
 
  <chart:SfChart.Annotations> 
                <chart:TextAnnotation x:Name="annotation" 
                                      VerticalAlignment="Center" 
                                      HorizontalAlignment="Center" 
                                     Text="This text shows the stripline"/> 
            </chart:SfChart.Annotations> 
 
 
 
  private void NumericalAxis_ActualRangeChanged(object sender, ActualRangeChangedEventArgs e) 
        { 
            annotation.Y1 = ((double)e.ActualMaximum + (double)e.ActualMinimum) / 2; 
        } 
 
 
Please let us know if you have any other queries.  
 
Regards, 
Muneesh Kumar G.    


Tom
Replied On August 1, 2019 12:49 PM UTC

This works great. I think you should have a section in the documentation to give an example of using the various events - there is so much customerization that can be achieved which is not obvious in the documentation. would probably save a lot of questions that are asked on here too.
Thanks again.

Muneesh Kumar G [Syncfusion]
Replied On August 1, 2019 01:17 PM UTC

Hi Tom, 
 
Thanks for your update.  
 
Already we have created report for add this requirement in our KB section, it will be published in live before our Vol 3 release.   
 
Thanks,   
Muneesh Kumar G.   
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon