Free Support Forum - aspose.com

[C#] Unable to have a Vertical Secondary Axis on the right side

Hello Aspose Team,

I’m trying currently trying to create a simple chart containing a serie with a secondary vertical axis, and it doesn’t work :confused:
So I tried with this simple code, using series generated when you call Shapes.AddChart(…), and it also doesn’t work.

I don’t know what am I doing wrong, but when I set PlotOnSecondAxis = true, the associated axes configuration for the chart looks good (chart.Axes.SecondaryVerticalAxis.Position == Right ), but the output file have only left axis.

[Fact]
    public async Task Create_Chart_With_Secondary_Axis()
    {
        Presentation pres = new Presentation();

        ISlide slide = pres.Slides[0];
        IChart chart = slide.Shapes.AddChart(ChartType.LineWithMarkers, 50, 50, 500, 400);

        var theSerie = chart.ChartData.Series[0];
        theSerie.PlotOnSecondAxis = true;

        
        pres.Save("Create_Chart_With_Secondary_Axis.pptx", SaveFormat.Pptx);
    }

I’m using the lastest version of your the packageCreate_Chart_With_Secondary_Axis_19-Dec-02 10-35-00.zip (32.5 KB)
: Aspose.Slides.NET (19.10)

@jkapps1,

I have observed your requirements and suggest you to please try using sample code given over following thread link using latest Aspose.Slides for .NET 19.11.

Hello @mudassir.fayyaz,

Thank you for your answer, I have already seen this sample code you share, and was also working for me.

But if in this sample, if I just comment the following line (in the “Move Primary and Secondary vertical axis” section) :

// chart.Axes.SecondaryHorizontalAxis.CrossType = CrossesType.Maximum;

Which is absolutely not linked to the vertical axis, the 2 vertical axis moves to the left …

I don’t know if it’s “normal”, but it’s very difficult to understand how to use the library when you have parameters on the vertical axis that have no impact on the vertical axis, but parameters on the horizontal axis that moves the vertical axis to the right :crazy_face:

Thanks again for your answer, and I will have a look on all details in samples I can find in this forum to have my answers :wink:

John

I have observed your comments. Can you please share the generated presentation on your end using Aspose.Slides for .NET 19.11. As per my assumption, if you commit the above line of code, both vertical axis move to left. This is strange. Please do provide the sample project used as it is to reproduce the issue on our end.