Show NumericAxis only type Interger

Hello Syncfusion, 
I want to show NumericAxis (Y Axis) only type Interger not using LabelFormat when My Chart has no data. How to do that?
Thanks you. 
Sample: 




10 Replies 1 reply marked as answer

SJ Suyamburaja Jayakumar Syncfusion Team December 28, 2020 05:24 PM UTC

Hi Nguyen Khoa Lu, 
 
Greetings from Syncfusion.  
 
We would like to let you know that your requirement has been achieved by using the ActualRangeChanged event and Check the ActualMinimum as 0 and ActualMaximum as 1 to set the interval as 1. Please refer the below code snippet, 
 
XAML: 
<chart:SfChart.SecondaryAxis> 
                <chart:NumericalAxis ActualRangeChanged="NumericalAxis_ActualRangeChanged"/> 
            </chart:SfChart.SecondaryAxis> 
 
C#: 
private void NumericalAxis_ActualRangeChanged(object sender, Syncfusion.SfChart.XForms.ActualRangeChangedEventArgs e) 
        { 
            var chartAxis = sender as NumericalAxis; 
            if(e.ActualMinimum.ToString() == "0" && e.ActualMaximum.ToString() == "1") 
            { 
                chartAxis.Interval = 1; 
            } 
            else 
            { 
                chartAxis.Interval = double.NaN; 
            } 
        } 
 
More information please refer the below UG link, 
 
Please let us know if you need any further assistance.     
 
Regards, 
Suyamburaja J. 



NK Nguyen Khoa Lu December 29, 2020 09:31 AM UTC

Thanks for your solution,
But after using that, IOS show well, Android have small problem.
Label Android show center line Axis
Like here:



NK Nguyen Khoa Lu December 30, 2020 08:03 AM UTC

Add event: NumericalAxis_ActualRangeChanged
Android when I click legend hide all Series, after that I click show 1 series and Android busy not response..


SJ Suyamburaja Jayakumar Syncfusion Team December 30, 2020 12:09 PM UTC

Hi Nguyen Khoa Lu, 
 
We have prepared a sample based on your scenario and tested the reported issue at our end, which is working fine at our end. Please find the tested sample and screenshot below,  
 
Screenshot: (Android) 
 
 
 
For the information, you can customize the axis tick line customization, can you please check your end, whether you are using the same at your end or not. 
 
More information please refer the UG link, 
 
Query: Android when I click legend hide all Series, after that I click show 1 series and Android busy not response. 
 
We have checked the simple sample that is working fine. Please check the provided sample at your end and ensure us whether you are using the same at your end or not. Please share more details and the complete SfChart related code snippet and viewmodel. 
 
 
Regards, 
Suyamburaja J.


NK Nguyen Khoa Lu December 31, 2020 01:46 AM UTC

Thanks you, I provide my code:

I using LabelCreated event for format number. I can plus string space "   " at end LabelContent but your code using TrimEnd.
If YValue is big value, clicking the legend icon cause app busy.. and if YValue smaller than 10, label of axis show over line.
Try your code after I added my code.


Attachment: LabelCreatedEvent_d0548844.zip


SJ Suyamburaja Jayakumar Syncfusion Team December 31, 2020 04:52 PM UTC

Hi Nguyen Khoa Lu, 
 
Thanks for your update.   
 
Currently we have validated the reported issue and we will update the complete details on or before January 4, 2020. 
 
Regards, 
Suyamburaja J. 



SJ Suyamburaja Jayakumar Syncfusion Team January 4, 2021 10:10 AM UTC

 
Thanks for your patience.  
 
If your requirement is to display the default secondary axis label display without interval label. You can achieve your requirement by setting the EdgeLabelsVisibilityMode as AlwaysVisible and overriding the Numerical axis and get the visible label collection to check the 0 indexes as 0 and last index as 1 and set another label as empty, please refer to the below code snippet, 
 
XAML: 
<chart:SfChart.SecondaryAxis> 
                <local:ChartSecondaryAxis x:Name="secondaryAxis" EdgeLabelsVisibilityMode="AlwaysVisible"  LabelCreated="secondaryAxis_LabelCreated" > 
                </local:ChartSecondaryAxis> 
            </chart:SfChart.SecondaryAxis> 
 
public class ChartSecondaryAxis : NumericalAxis 
    { 
        protected override void OnCreateLabels() 
        { 
            base.OnCreateLabels(); 
            if (VisibleLabels[VisibleLabels.Count - 1].LabelContent == "1" && VisibleLabels[0].LabelContent == "0") 
            { 
                for (int i = 0; i < VisibleLabels.Count - 1; i++) 
                { 
                    if (i != 0 && i != VisibleLabels.Count - 1) 
                    { 
                        VisibleLabels[i].LabelContent = " "; 
                    } 
                } 
            } 
        } 
    } 
 
Query2: Label Android show center line Axis 
 
We have validated your provided sample and we would like to let you know that it will be resolved by convert the labelContent as double then apply the LabelFormat as per in below code snippet 
 
private void secondaryAxis_LabelCreated(object sender, ChartAxisLabelEventArgs e) 
        { 
                var value = Convert.ToDouble(e.LabelContent); 
                e.LabelContent = Convert.ToDouble(value).ToString("### ### ### ### ##0"); 
. . . . 
        } 
 
 
Reference link 
 
Please let us know if you need any further assistance on this. 
 
Regards, 
Suyamburaja J. 


Marked as answer

NK Nguyen Khoa Lu January 5, 2021 01:28 AM UTC

Thank for your update, but Axis labels still showed at mid line:
Current:


I want same here:

Thanks you.

If label value smaller than 10, it will be show error position. 


NK Nguyen Khoa Lu January 5, 2021 04:24 AM UTC

I sloved prolem when using: e.LabelContent = Convert.ToDouble(value).ToString("### ### ### ### ##0").TrimStart(); 
Thanks you.


HM Hemalatha Marikumar Syncfusion Team January 6, 2021 04:33 AM UTC

Hi Nguyen Khoa Lu, 
 
We glad to hear that you have resolved it.  
 
Regards,
Hemalatha M. 


Loader.
Up arrow icon