numerical axis set maximum value automatically

hi all,
i have a chart with 2 columnseries.
in both i have this
<chart:NumericalAxis IsVisible="True"  ShowMajorGridLines="False" ShowMinorGridLines="False" OpposedPosition="False" Minimum="0" Maximum="1000"

is there a way in order to set Maximum="1000" in a automatic way based on max value of the serie?
thanks


5 Replies

MP Michael Prabhu M Syncfusion Team October 15, 2018 10:18 AM UTC

Hi Alberto, 
          
Greetings from Syncfusion. We have analyzed your requirement and you can achieve this requirement with the help of RangePadding in NumericalAxis, setting RangePadding has none will automatically set the minimum and maximum values based on series min and max value 
Code snippet: 
<chart:NumericalAxis ShowMajorGridLines="false" EdgeLabelsVisibilityMode="AlwaysVisible"RangePadding="None" > 
</chart:NumericalAxis> 
  
We have prepared a simple sample for your requirement and it can be downloaded from the below link. 
Sample: 140376  
Please refer the below UG link to know more details about RangePadding.                                                
                                                                                                     
UG link - https://help.syncfusion.com/xamarin/sfchart/axis#numeric-axis 
  
Regards, 
Michael 



LU Luca October 15, 2018 01:15 PM UTC

one question: will both series (i have 2 series in the chart) have the same range? because i need to compare them so i need same scale on both.
i wouls like to have as MIN value always 0, and MAX value based on 2 series but of course equal value.
thanks


MP Michael Prabhu M Syncfusion Team October 16, 2018 11:08 AM UTC

Hi Alberto, 
 
By default, Column series and Area series will start from 0 as minimum in the Y axis, but other series if you set RangePadding as None, then as mentioned before, the y axis will set minimum and maximum from the series data either it is one or any number of series. So, to achieve your requirement you must set RangePadding property as None and Minimum as Zero for SecondaryAxis. We have prepared a simple sample for your requirement and it can be downloaded from the below link. 
 
Sample: 140376_sample  
 
Hope this helps. 
 
Thanks, 
Michael 




LU Luca October 16, 2018 09:30 PM UTC

thanks for your reply, but i'm asking a different thing (or maybe i have not understood )
i have 2 series, columns type, and i need to COMPARE them so i need that the have the same scale (same MIN and MAX parameter).
since i can change the ditabinding i need an automatic way in order to have the same scale on both.
if i use your example i have 2 different scale and i can't compare them.
let me know if now it is clear.
thanks


MP Michael Prabhu M Syncfusion Team October 17, 2018 11:44 AM UTC

Hi Alberto, 

Thanks for the detailed explanation, we have achieved this requirement with the help of ActualRangeChanged Event in ChartAxis. You can get the default y axis maximum value from ActualRangeChanged event and set the maximum value to series y axis Maximum Property. Please refer below code snippet.  

Code snippet [XAML]:   
<chart:SfChart.SecondaryAxis> 
                <chart:NumericalAxis Minimum="0" ShowMajorGridLines="false" EdgeLabelsVisibilityMode="AlwaysVisible" RangePadding="None" ActualRangeChanged="SecondaryAxis_ActualRangeChanged" > 
                </chart:NumericalAxis> 
            </chart:SfChart.SecondaryAxis> 
 
            <chart:SfChart.Series> 
                <chart:ColumnSeries ItemsSource="{Binding ColumnData}"  
                                        XBindingPath="XValue" YBindingPath="YValue"  > 
                </chart:ColumnSeries> 
 
                <chart:ColumnSeries ItemsSource="{Binding ColumnData1}"  
                                        XBindingPath="XValue" YBindingPath="YValue"  > 
                    <chart:ColumnSeries.YAxis> 
                        <chart:NumericalAxis OpposedPosition="True" Minimum="0" Maximum="{Binding Maximum}" ShowMajorGridLines="false" EdgeLabelsVisibilityMode="AlwaysVisible" RangePadding="None"/> 
                    </chart:ColumnSeries.YAxis> 
                </chart:ColumnSeries> 
</chart:SfChart.Series> 
 
  
Code snippet [C#]:    
private void SecondaryAxis_ActualRangeChanged(object sender, Syncfusion.SfChart.XForms.ActualRangeChangedEventArgs e) 
var viewmodel = chart.BindingContext as ViewModel; 
           
            viewmodel.Maximum = (double) e.ActualMaximum; 
} 
 

We have prepared a simple sample and it can be downloaded from the link below. 

Sample: 140376  

Thanks, 
Michael 


Loader.
Up arrow icon