Chart Calculations
Calculate Actual Values of Chart Elements
Aspose.Slides for Python via .NET provides a simple API for getting these properties. This will help you to Calculates actual values of chart elements. The actual values include position of elements that implement IActualLayout interface (IActualLayout.ActualX, IActualLayout.ActualY, IActualLayout.ActualWidth, IActualLayout.ActualHeight) and actual axes values (IAxis.ActualMaxValue, IAxis.ActualMinValue, IAxis.ActualMajorUnit, IAxis.ActualMinorUnit, IAxis.ActualMajorUnitScale, IAxis.ActualMinorUnitScale).
import aspose.slides.charts as charts
import aspose.slides as slides
with slides.Presentation("pres.pptx") as pres:
chart = pres.slides[0].shapes.add_chart(charts.ChartType.CLUSTERED_COLUMN, 100, 100, 500, 350)
chart.validate_chart_layout()
maxValue = chart.axes.vertical_axis.actual_max_value
minValue = chart.axes.vertical_axis.actual_min_value
majorUnit = chart.axes.horizontal_axis.actual_major_unit
minorUnit = chart.axes.horizontal_axis.actual_minor_unit
Calculate Actual Position of Parent Chart Elements
Aspose.Slides for Python via .NET provides a simple API for getting these properties. Properties of IActualLayout provide information about actual position of parent chart element. It is necessary to call method IChart.ValidateChartLayout() previously to fill properties with actual values.
import aspose.slides.charts as charts
import aspose.slides as slides
with slides.Presentation("pres.pptx") 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
Hide Information from Chart
This topic helps you to understand how to hide information from chart. Using Aspose.Slides for Python via .NET you can hide Title, Vertical Axis, Horizontal Axis and Grid Lines from chart. Below code example shows how to use these properties.
import aspose.slides.charts as charts
import aspose.slides as slides
with slides.Presentation() as pres:
slide = pres.slides[0]
chart = slide.shapes.add_chart(charts.ChartType.LINE_WITH_MARKERS, 140, 118, 320, 370)
# Hiding chart Title
chart.has_title = False
# Hiding Values axis
chart.axes.vertical_axis.is_visible = False
# Category Axis visibility
chart.axes.horizontal_axis.is_visible = False
# Hiding Legend
chart.has_legend = False
# Hiding MajorGridLines
chart.axes.horizontal_axis.major_grid_lines_format.line.fill_format.fill_type = slides.FillType.NO_FILL
#for i in range(len(chart.chart_data.series)):
# chart.chart_data.series.remove_at(i)
series = chart.chart_data.series[0]
series.marker.symbol = charts.MarkerStyleType.CIRCLE
series.labels.default_data_label_format.show_value = True
series.labels.default_data_label_format.position = charts.LegendDataLabelPosition.TOP
series.marker.size = 15
# Setting series line color
series.format.line.fill_format.fill_type = slides.FillType.SOLID
series.format.line.fill_format.solid_fill_color.color = draw.Color.purple
series.format.line.dash_style = slides.LineDashStyle.SOLID
pres.save("HideInformationFromChart.pptx", slides.export.SaveFormat.PPTX)