Adding duplicate axis in SfChart

29 Apr 20221 minute to read

Duplicate axis can be added in the SfChart using the chart Axes collection property. The axis added in the Axes collection will be aligned to the horizontal position by default. The axis position can be changed using the IsVertical bool property of ChartAxis. When the IsVertical property is set true, the axis will be placed vertically and vice versa.

The following code sample demonstrates this.

<chart:SfChart>

...

    <chart:SfChart.Axes>
        <chart:NumericalAxis Minimum="0" 
                             Maximum="70" 
                             IsVertical="True" 
                             OpposedPosition="True" />
    </chart:SfChart.Axes>

</chart:SfChart>
SfChart chart = new SfChart();

. . .

chart.Axes.Add(new NumericalAxis()
{
    Minimum = 0,
    Maximum = 70,
    IsVertical = true,
    OpposedPosition = true
});

Duplicate axis support in Xamarin.Forms Chart

NOTE

  • The ChartAxis added in the Axes collection will not be removed until removing it from the Axes collection.
  • The Axes collection does not support the clear method.
  • Same axis cannot be added more than once in Axes; only distinct axis will be added to the Axes collection.