We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Chart Plot Area Position

Dear,


I need to set the Plot Area position in a “Pie Chart”, in pptx presentation using aspose.slides.dll version 6.7.0.0 . In fact I need to align the Plot Area to the bottom of the chart. I tried to set the following:

chart.PlotArea.Y = (float) aNumber;

where aNumber is a float. If aNumber is greater than 1 or less than 0 nothing happens, the Plot Area stays at the center of the chart. If aNumber is between 1 and 0 the Plot Area is aligned to the top of the chart.

Could you please tell me what I’m I doing wrong? And could you please provide me with a code snippet that allows me to align my Plot Area to the bottom of the chart?

Thank you so much,
Sami Simon

Hi Sami Simon,


I have observed the requirements shared by you and like to share that setting plot area height has already been identified as issue and have been logged in our issue tracking system with ID SLIDESNET-33803. The issue is in progress and I have linked this thread with the issue so that you may be automatically notified once the issue will be resolved.

We are sorry for your inconvenience,

Hi Sami Simon,


I like to share that the issue shared has been resolved in Aspose.Slides for .NET 6.9.0. Please use the following code snippet to observe the values being applied.

PresentationEx pres = new PresentationEx();
SlideEx slide = pres.Slides[0];
ChartEx chart = slide.Shapes.AddChart(ChartTypeEx.ClusteredColumn, 50, 50, 500, 400);
//set plot area
chart.PlotArea.Height = 0.5f; // chart.Heigh * 0.5 = 400 * 0.5 = 200
chart.PlotArea.Width = 0.5f; // Chart.Width * 0.5 = 500 * 0.5 = 250
chart.PlotArea.X = 0.25f; // chart.X = 500 * 0.25 = 125
chart.PlotArea.Y = 0.25f; // chart.Y = 400 * 0.25 = 100
pres.Write(“D:\Aspose Data\result.pptx”);

Many Thanks,

The issues you have found earlier (filed as SLIDESNET-33803) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Dear,


Thank you for the fix. I tried the code but I was not able to align the chart to the bottom of the chart area. Please bellow the code i am using:
{
SlideEx sld = pres.Slides[0];
Aspose.Slides.Pptx.ChartEx chart = sld.Shapes.AddChart(ChartTypeEx.Pie, 10, 60, 600, 400);
ChartDataCellFactory fact = chart.ChartData.ChartDataCellFactory;

chart.HasLegend = false;
chart.ChartTitle.Text.Text = “”;
chart.ChartData.Series.Clear();
chart.ChartData.Categories.Clear();

chart.PlotArea.Height = 0.2f;
chart.PlotArea.Width = 0.2f;
chart.PlotArea.Y = 0.1f; //<-- here is the problem

chart.ChartData.Categories.Add(fact.GetCell(0, 0, 0, “C1”));
chart.ChartData.Categories.Add(fact.GetCell(0, 1, 0, “C2”));
chart.ChartData.Categories.Add(fact.GetCell(0, 2, 0, “C3”));

chart.ChartData.Series.Add(fact.GetCell(0, 0, 1, “Series 1”), chart.Type);
ChartSeriesEx series = chart.ChartData.Series[0];
series.Values.Add(fact.GetCell(0, 0, 1, 24));
series.Values.Add(fact.GetCell(0, 1, 1, 74));
series.Values.Add(fact.GetCell(0, 2, 1, 25));
}

Please find a screenshot showing how i need to position the plotting area

Can you please share a code snippet that allows me to do that.

Thank you in advance,
Sami Simon

Hi Sami Simon,


I have observed the requirement shared by you and like to share that you can set the position of the chart with defined boundary of chart from scale of 0 to 1. (0f,0f) (x,y) value means top left corner of the chart. (1f,1f) (x,y) means the bottom right corner of the chart, the maximum height and width of the chart. I hope this will make you understand about the concept. Please use the following sample code to serve the purpose.

public static void setChartPlotAreaHeight()
{
PresentationEx pres = new PresentationEx();
{
SlideEx sld = pres.Slides[0];
Aspose.Slides.Pptx.ChartEx chart = sld.Shapes.AddChart(ChartTypeEx.Pie, 10, 60, 600, 400);
ChartDataCellFactory fact = chart.ChartData.ChartDataCellFactory;

chart.HasLegend = false;
chart.ChartTitle.Text.Text = “”;
chart.ChartData.Series.Clear();
chart.ChartData.Categories.Clear();


chart.PlotArea.Height = 0.25f; // chart.Heigh * 0.5 = 400 * 0.5 = 200
chart.PlotArea.Width = 0.25f; // Chart.Width * 0.5 = 500 * 0.5 = 250

//The range of X and Y values is given on scale of 0 to 1. 0 mean minimum height or width. 1 mean maximum height or width of chart.

chart.PlotArea.X = 0.0f;// 1.0f; // chart.X = 500 * 0.25 = 125
chart.PlotArea.Y = 1.0f; // chart.Y = 400 * 0.25 = 100

chart.ChartData.Categories.Add(fact.GetCell(0, 0, 0, “C1”));
chart.ChartData.Categories.Add(fact.GetCell(0, 1, 0, “C2”));
chart.ChartData.Categories.Add(fact.GetCell(0, 2, 0, “C3”));

chart.ChartData.Series.Add(fact.GetCell(0, 0, 1, “Series 1”), chart.Type);
ChartSeriesEx series = chart.ChartData.Series[0];
series.Values.Add(fact.GetCell(0, 0, 1, 24));
series.Values.Add(fact.GetCell(0, 1, 1, 74));
series.Values.Add(fact.GetCell(0, 2, 1, 25));
}
pres.Write(“D:\Aspose Data\PlotAreaHeight.pptx”);
}

Many Thanks,