Hi!
I need to get an image from a slide, but I noticed that if the chart uses secondary axes, then the part of the chart that belongs to the secondary axis moves out - as if ignoring the specified minimum value of the axis.
Example:
var pres = new Presentation();
var pptChart = pres.Slides[0].Slide.Shapes.AddChart(ChartType.Line, 0, 0, 700, 300);
pptChart.ChartData.Series.Clear();
pptChart.ChartData.Categories.Clear();
var barSeries = pptChart.ChartData.Series.Add("Bar", ChartType.ClusteredColumn);
barSeries.DataPoints.DataSourceTypeForValues = DataSourceType.DoubleLiterals;
barSeries.DataPoints.AddDataPointForBarSeries(4250);
barSeries.DataPoints.AddDataPointForBarSeries(3300);
pptChart.ChartData.Categories.Add(1);
pptChart.ChartData.Categories.Add(2);
var series = pptChart.ChartData.Series.Add("Example 1", ChartType.ScatterWithStraightLines);
series.PlotOnSecondAxis = true;
series.DataPoints.DataSourceTypeForXValues = DataSourceType.DoubleLiterals;
series.DataPoints.DataSourceTypeForYValues = DataSourceType.DoubleLiterals;
series.DataPoints.AddDataPointForScatterSeries(0.5, 3500);
series.DataPoints.AddDataPointForScatterSeries(1.5, 3500);
pptChart.Axes.SecondaryHorizontalAxis.MinorGridLinesFormat.Line.FillFormat.FillType = FillType.NoFill;
pptChart.Axes.SecondaryHorizontalAxis.MajorGridLinesFormat.Line.FillFormat.FillType = FillType.NoFill;
pptChart.Axes.SecondaryVerticalAxis.MinorGridLinesFormat.Line.FillFormat.FillType = FillType.NoFill;
pptChart.Axes.SecondaryVerticalAxis.MajorGridLinesFormat.Line.FillFormat.FillType = FillType.NoFill;
pptChart.Axes.SecondaryHorizontalAxis.IsAutomaticMaxValue = false;
pptChart.Axes.SecondaryHorizontalAxis.IsAutomaticMinValue = false;
pptChart.Axes.SecondaryHorizontalAxis.MaxValue = pptChart.ChartData.Categories.Count;
pptChart.Axes.SecondaryHorizontalAxis.MinValue = 0;
pptChart.Axes.SecondaryHorizontalAxis.IsVisible = false;
pptChart.Axes.SecondaryVerticalAxis.IsVisible = false;
using var bitmap = pres.Slides[0].GetThumbnail(5f, 5f);
bitmap.Save("TEST_IMAGE.jpeg", ImageFormat.Jpeg);
Image result: TEST_IMAGE.jpeg (140.0 KB)
Presentation result: Test chart.7z (31.0 KB)
Compare: example.png (46.8 KB)
Thanks!