Chart Plot Area
Contents
[
Hide
]
Get Width, Height of Chart Plot Area
Aspose.Slides for Python via .NET provides a simple API for .
- Create an instance of the Presentation class.
- Access first slide.
- Add chart with default data.
- Call method IChart.ValidateChartLayout() before to get actual values.
- Gets actual X location (left) of the chart element relative to the left top corner of the chart.
- Gets actual top of the chart element relative to the left top corner of the chart.
- Gets actual width of the chart element.
- Gets actual height of the chart element.
import aspose.slides.charts as charts
import aspose.slides as slides
with slides.Presentation() as pres:
chart = pres.slides[0].shapes.add_chart(charts.ChartType.CLUSTERED_COLUMN, 100, 100, 500, 350)
chart.validate_chart_layout()
x = chart.plot_area.actual_x
y = chart.plot_area.actual_y
w = chart.plot_area.actual_width
h = chart.plot_area.actual_height
# Save presentation with chart
pres.save("Chart_out.pptx", slides.export.SaveFormat.PPTX)
Set Layout Mode of Chart Plot Area
Aspose.Slides for Python via .NET provides a simple API to set the layout mode of the chart plot area. Property LayoutTargetType has been added to ChartPlotArea and IChartPlotArea classes. If the layout of the plot area defined manually this property specifies whether to layout the plot area by its inside (not including axis and axis labels) or outside (including axis and axis labels). There are two possible values which are defined in LayoutTargetType enum.
- LayoutTargetType.Inner - specifies that the plot area size shall determine the size of the plot area, not including the tick marks and axis labels.
- LayoutTargetType.Outer - specifies that the plot area size shall determine the size of the plot area, the tick marks, and the axis labels.
Sample code is given below.
import aspose.slides.charts as charts
import aspose.slides as slides
with slides.Presentation() as presentation:
slide = presentation.slides[0]
chart = slide.shapes.add_chart(charts.ChartType.CLUSTERED_COLUMN, 20, 100, 600, 400)
chart.plot_area.as_i_layoutable.x = 0.2
chart.plot_area.as_i_layoutable.y = 0.2
chart.plot_area.as_i_layoutable.width = 0.7
chart.plot_area.as_i_layoutable.height = 0.7
chart.plot_area.layout_target_type = charts.LayoutTargetType.INNER
presentation.save("SetLayoutMode_outer.pptx", slides.export.SaveFormat.PPTX)