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.
Unfortunately, activation email could not send to your email. Please try again.

Custom Label

Thread ID:

Created:

Updated:

Platform:

Replies:

132818 Sep 22,2017 10:35 AM Sep 29,2017 12:30 AM Xamarin.Android 5
loading
Tags: SfChart
Alex
Asked On September 22, 2017 10:35 AM

Hello,


I am using Sfchart, and on numerical axis (vertical one)  I want to add specific labels and the other one I want to hide. For example on the y axis I just want to have 3 labels specify by me. I can't find any solution for that.  
So how should I do that? 

Thank you.

Parthiban Sundaram [Syncfusion]
Replied On September 25, 2017 06:53 AM

Hi Alex,  
  
Thanks for using Syncfusion products.  
  
You can achieve this requirement using LabelCreated event of NumericalAxis. Please refer the following code snippet for more details.  
  
Code snippet:  
  
  
           private void YAxis_LabelCreated(object sender, ChartAxis.LabelCreatedEventArgs e)  
        {  
            // Specify the label to show  
            if (e.AxisLabel.Position != 20 && e.AxisLabel.Position != 80 && e.AxisLabel.Position != 150)   
                e.AxisLabel.IsVisible = false;  
        }  
  
  
We have created a simple demo sample to demonstrate this. Please download it from below location.    
  
  
Please let us know, if you need further assistance on this.  
  
Regards,  
Parthiban S   


Alex
Replied On September 26, 2017 03:21 AM

Thank you for your answer.

Another thing that I want to do is to add a label to specific position, where I have no data.


Parthiban Sundaram [Syncfusion]
Replied On September 27, 2017 04:33 PM

Hi Alex, 
  
 
Thanks for the update. 
 
We have achieved your requirement by extending NumericalAxis and overriding GenerateVisibleLabels method to add the labels in specified position. Please refer the NumericalAxisExt files for more details. 
 
Code snippet: 
  
        protected override void GenerateVisibleLabels() 
        { 
            base.GenerateVisibleLabels(); 
            VisibleLabels.Clear(); 
            for (double i = VisibleRange.Start; i < VisibleRange.End; i++) 
            { 
                if(i == 20 || i == 40 || i == 60) // specify the label you need 
                    VisibleLabels.Add(new ChartAxisLabel(i, i.ToString())); 
            } 
        } 
 
 
Please download the sample from following location. 
 
 
Please let us know, if you need further assistance. 
 
Regards, 
Parthiban S 


Alex
Replied On September 28, 2017 04:52 AM

Hi Parthiban,

Thanks a lot for the solution! That helped a lot.

Best regards,

Alex


Parthiban Sundaram [Syncfusion]
Replied On September 29, 2017 12:30 AM

Hi Alex,

Thanks for the update. We are glad that the given solution has helped to achieve your requirement. Please let us know, if you need further assistance on this.

Regards,
Parthiban S


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.

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.

;