Category / Section
How to change the position of the axis?
1 min read
Essential chart for Xamarin.Forms supports positioning the chart axis on its default position or to the other side of the chart. To change the axis position, enable the OpposedPosition property of the ChartAxis. The following code example illustrates this.
XAML
<chart:SfChart> … <chart:SfChart.PrimaryAxis> <chart:CategoryAxis OpposedPosition="True"> … </chart:CategoryAxis> </chart:SfChart.PrimaryAxis> <chart:SfChart.SecondaryAxis> <chart:NumericalAxis OpposedPosition="True"> … </chart:NumericalAxis> </chart:SfChart.SecondaryAxis> … </chart:SfChart>
C#
Chart.PrimaryAxis = new CategoryAxis { //Displays the primary X Axis in opposed position. OpposedPosition = true, … }; Chart.SecondaryAxis = new NumericalAxis { //Displays the primary Y Axis in opposed position. OpposedPosition = true, … };
Output:
Figure 1: Opposite position of the chart axis.