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. Image for the cookie policy date

Stripline and Label

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.

7 Replies

MK Muneesh Kumar G Syncfusion Team 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.   



TO Tom 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


MK Muneesh Kumar G Syncfusion Team 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.  
 



TO Tom 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,


MK Muneesh Kumar G Syncfusion Team 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.    



TO Tom 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.


MK Muneesh Kumar G Syncfusion Team 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.   
 


Loader.
Live Chat Icon For mobile
Up arrow icon