Axis rounding up 8 point decimals

My chart range starts from 0.00001090 to 0.00001110, but it automatically rounds up to 0.00001100 for all points. Using the Interval and setting minimum and maximum does not fix the problem.

1 Reply

DS Durgadevi Selvaraj Syncfusion Team January 9, 2018 01:02 PM UTC

Hi Dean, 
 
Thanks for contacting Syncfusion Support. 
 
We have analyzed the reported problem and since we have internally round off of the axis label value in GenerateVisibleLabel() of chart axis so axis label was displaying with rounded value. however, we have resolved this problem by generating axis label with its actual value using GenerateVisibleLabel() with the help of custom axis. Please refer the below codes, 
 
Code Snippet[XAML] 
<chart:SfChart Margin="20"> 
            <chart:SfChart.PrimaryAxis> 
                <chart:CategoryAxis/> 
            </chart:SfChart.PrimaryAxis> 
 
            <chart:SfChart.SecondaryAxis> 
                <local:NumericalExt x:Name="axis"  Interval="0.00000005"  LabelFormat="0.00000000"/> 
            </chart:SfChart.SecondaryAxis> 
 
        </chart:SfChart> 
 
Code Snippet[C#] 
public class NumericalExt:NumericalAxis 
    { 
        protected override void GenerateVisibleLabels() 
        { 
            DoubleRange range = VisibleRange; 
            double interval = Convert.ToDouble(this.Interval); 
            double position; 
 
            if ((Minimum != null && Maximum != null && Interval != null) || this.DesiredIntervalsCount != null 
                ||EdgeLabelsVisibilityMode == EdgeLabelsVisibilityMode.AlwaysVisible 
                || (EdgeLabelsVisibilityMode == EdgeLabelsVisibilityMode.Visible )) 
                position = range.Start; 
            else 
                position = range.Start - (range.Start % interval); 
 
            double previousPosition = double.NaN; 
 
            for (; position <= range.End; position += interval) 
            { 
                if (position == previousPosition) 
                    break; 
 
                if (range.Inside(position)) 
                { 
                    VisibleLabels.Add(new ChartAxisLabel(position, GetActualLabelContent(position), position)); 
                }             
 
                previousPosition = position; 
            } 
 
            if (((Maximum != null && range.End.Equals(Maximum)) 
                || EdgeLabelsVisibilityMode == EdgeLabelsVisibilityMode.AlwaysVisible 
                || (EdgeLabelsVisibilityMode == EdgeLabelsVisibilityMode.Visible )) 
                && !range.End.Equals(position - interval)) 
            { 
                VisibleLabels.Add(new ChartAxisLabel(range.End, GetActualLabelContent(range.End), range.End)); 
            } 
        } 
        internal virtual object GetActualLabelContent(double position) 
        { 
             return position.ToString(this.LabelFormat, CultureInfo.CurrentCulture); 
        } 
    } 
 
 
Please find the output screenshot below, 
 
We have prepared simple sample based on this requirement and it can be downloaded from the below link, 
Please let us know if you have any concerns. 
 
Regards,  
Durgadevi S 



Loader.
Up arrow icon