We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Multiple axis for multiple series

Hello, I have a chart with 4 line series.
I would like 2 series to use the default Y Axis, and the other 2 to use a custom Y Axis positioned at the right side of the chart.

This is my current code, but it will create a third Y axis (that I don't want):
<sfChart:SfChart>
    <!--  Horizontal axis for SfChart (Dates)  -->
    <sfChart:SfChart.PrimaryAxis>
        <sfChart:DateTimeAxis FontSize="14" LabelFormat="{x:Bind model:Salary.GraphDateFormat, Mode=OneTime}" />
    </sfChart:SfChart.PrimaryAxis>
 
    <!--  Vertical axis for SfChart (Cumulative Money)  -->
    <sfChart:SfChart.SecondaryAxis>
        <sfChart:NumericalAxis FontSize="14" LabelFormat="C0" />
    </sfChart:SfChart.SecondaryAxis>
 
    <sfChart:SfChart.Legend>
        <sfChart:ChartLegend Visibility="Visible" />
    </sfChart:SfChart.Legend>
 
    <!--  Series for SfChart  -->
    <sfChart:LineSeries ItemsSource="{Binding LucaSerie}"
                        Label="Luca"
                        XBindingPath="Key.Date"
                        YBindingPath="Value" />
    <sfChart:LineSeries ItemsSource="{Binding KatyaSerie}"
                        Label="Katya"
                        XBindingPath="Key.Date"
                        YBindingPath="Value" />
    <sfChart:LineSeries ItemsSource="{Binding LucaCumulativeSerie}"
                        Label="Luca (Cumulative)"
                        XBindingPath="Key.Date"
                        YBindingPath="Value">
        <sfChart:LineSeries.YAxis>
            <sfChart:NumericalAxis FontSize="14"
                                   Header="Cumulative"
                                   LabelFormat="C0"
                                   OpposedPosition="True" />
        </sfChart:LineSeries.YAxis>
    </sfChart:LineSeries>
    <sfChart:LineSeries ItemsSource="{Binding KatyaCumulativeSerie}"
                        Label="Katya (Cumulative)"
                        XBindingPath="Key.Date"
                        YBindingPath="Value">
        <sfChart:LineSeries.YAxis>
            <sfChart:NumericalAxis FontSize="14"
                                   Header="Cumulative"
                                   LabelFormat="C0"
                                   OpposedPosition="True" />
        </sfChart:LineSeries.YAxis>
 
    </sfChart:LineSeries>
</sfChart:SfChart>

This is the result (as you can see there are 3 Y axes, I would like just 2):

thanks for the help!

4 Replies

DA Devi Aruna Maharasi Murugan Syncfusion Team December 1, 2016 10:13 AM UTC

Hi Luca, 
  
Thanks for contacting Syncfusion Support. 
  
We are able to achieve your requirement (using single axis for multiple series) by sharing same YAxis to multiple series as shown in the below code snippet, 
 
      <chart:LineSeries.YAxis> 
          <chart:NumericalAxis Name="yaxis"  /> 
      </chart:LineSeries.YAxis> 
         
      </chart:LineSeries> 
             
        <chart:LineSeries YAxis="{Binding ElementName=yaxis}"/> 
  
We have prepared a demos sample based on this requirement and it can be downloaded from below link, 
  
Sample: LineSeriesUWP 
  
Regards, 
Devi 






LS Luca Spolidoro December 1, 2016 08:07 PM UTC

Thanks a lot, I solved the problem!
At first I tried at first by adding the Y Axis as resource, but I got an error that the Axis couldn't be added to 2 series.
With binding everything works!


LS Luca Spolidoro December 1, 2016 09:30 PM UTC

PS: I think it would be very useful if you add this scenario in the axis documentation:
https://help.syncfusion.com/uwp/sfchart/axis


DA Devi Aruna Maharasi Murugan Syncfusion Team December 2, 2016 11:51 AM UTC

Hi Luca, 
  
Thanks for your update. 
  
We will include this scenario in our UG documentation and please let us know if you need any further assistance. 
  
Regards, 
Devi 


Loader.
Up arrow icon