Class Chart
- class ooodev.office.chart.Chart[source]
Chart Class
- classmethod get_chart_doc(shape: com.sun.star.drawing.XShape)[source]
- classmethod get_chart_doc(tbl_chart: com.sun.star.table.XTableChart)
- classmethod get_chart_doc(sheet: com.sun.star.sheet.XSpreadsheet, chart_name: str)
- classmethod get_chart_doc(*args, **kwargs)
Gets chart document
- Parameters:
shape (XShape) – Shape object
tbl_chart (XTableChart) – Table Chart
sheet – SpreadSheet
chart_name (str) – Chart Name
- Raises:
ChartNotExistingError – If chart is not existing.
ChartError – If chart error occurs.
- Returns:
Chart Document Interface
- Return type:
XChartDocument
- classmethod get_chart_names_list(sheet)[source]
Gets Tuple of chart names as strings
- Parameters:
sheet (XSpreadsheet) – Spreadsheet
- Returns:
Tuple of strings or empty tuple if no charts are found
- Return type:
Tuple[str]
- static get_chart_shape(sheet)[source]
Gets the shape of the first found chart
- Parameters:
sheet (XSpreadsheet) – Spreadsheet
- Raises:
ShapeMissingError – If unable to find a chart on the sheet.
ShapeError – If any other error occurs.
- Returns:
Chart Shape.
- Return type:
XShape
- static get_chart_type(chart_doc)[source]
Gets chart document chart type
- Parameters:
chart_doc (XChartDocument) – Chart Document
- Returns:
Chart Type
- Return type:
str
- static get_sub_title(chart_doc)[source]
Gets subtitle for a chart document.
- Parameters:
chart_doc (XChartDocument) – Chart document
- Raises:
ChartError – If error occurs.
- Returns:
Chart Subtitle
- Return type:
str
- static get_table_chart(tc_access, chart_name)[source]
Gets a table chart.
- Parameters:
tc_access (XNameAccess) – Name Access
chart_name (str) – Chart Name
- Raises:
ChartError – If unable to get Table Chart
- Returns:
Table Chart Interface.
- Return type:
XTableChart
- classmethod get_table_chart_access(sheet)[source]
Get XNameAccess interface of sheet charts
- Parameters:
sheet (XSpreadsheet) – Spreadsheet
- Raises:
ChartError – if error occurs.
- Returns:
Named Access interface
- Return type:
XNameAccess
- static get_table_charts(sheet)[source]
Gets Table Charts of a sheet
- Parameters:
sheet (XSpreadsheet) – Spreadsheet
- Raises:
ChartError – if error occurs.
- Returns:
Table Charts interface
- Return type:
XTableCharts
- static get_title(chart_doc)[source]
Gets title for a chart document.
- Parameters:
chart_doc (XChartDocument) – Chart document
- Raises:
ChartError – If error occurs.
- Returns:
Chart Title
- Return type:
str
- classmethod insert_chart(*, slide: com.sun.star.drawing.XDrawPage, x: int) com.sun.star.chart.XChartDocument [source]
- classmethod insert_chart(*, doc: com.sun.star.text.XTextDocument, x: int) com.sun.star.chart.XChartDocument
- classmethod insert_chart(*, sheet: com.sun.star.sheet.XSpreadsheet, chart_name: str) com.sun.star.chart.XChartDocument
- classmethod insert_chart(*, sheet: com.sun.star.sheet.XSpreadsheet, chart_name: str) com.sun.star.chart.XChartDocument
- classmethod insert_chart(*args, **kwargs)
Insert a chart using the given name as name of the OLE object and the range as corresponding range of data to be used for rendering. The chart is placed in the sheet for charts at position (1,1) extending as large as given in chart size.
The diagram name must be the name of a diagram service (i.e one in
com.sun.star.chart
) that can be instantiated via the factory of the chart document- Parameters:
slide (XDrawPage) – Draw page
doc (XTextDocument) – Document
sheet (XSpreadsheet) – Spreadsheet
chart_name (str) – Name of chart
cells_range (CellRangeAddress) – Cells range
width (int) – Width
height (int) – Height
diagram_name (DiagramKind | str) – Diagram Name
x (int, optional) – Chart X position. Defaults to 1.
y (int, optional) – Chart y Position. Defaults to 1.
- Raises:
ChartNoAccessError – If unable to get access to chart table.
ChartExistingError – If chart already exist.
ChartError – If unable to insert chart.
- Returns:
Chart Document on success; Otherwise,
None
.- Return type:
XChartDocument
- classmethod remove_chart(sheet, chart_name)[source]
Removes a chart from spreadsheet current charts
- Parameters:
sheet (XSpreadsheet) – Spreadsheet
chart_name (str) – Chart Name to remove
- Returns:
True
if chart is found and removed; Otherwise,False
- Return type:
bool
- static set_3d(chart_doc: com.sun.star.chart.XChartDocument, is_3d: bool) None [source]
- static set_3d(chart_doc: com.sun.star.chart.XChartDocument, is_3d: bool, solid_type: ooo.dyn.chart.chart_solid_type.ChartSolidTypeEnum) None
- static set_3d(chart_doc, is_3d, solid_type=None)
Sets chart 3d option.
- Parameters:
chart_doc (XChartDocument) – Chart Document.
is_3d (bool) – Specifies if chart is 3d.
solid_type (ChartSolidTypeEnum) – Chart Solid Type. Defaults to
ChartSolidTypeEnum.CYLINDER
.
- Raises:
DiagramNotExistingError – If
chart_doc
diagram does not existChartError – If any other error occurs.
- Return type:
None
- static set_area_transparency(chart_doc, val)[source]
Set the transparency of chart areas surrounding the diagram/
- Parameters:
chart_doc (XChartDocument) – Chart Document.
val (Intensity) – Transparency intensity, Higher values is more transparent.
- Raises:
ChartError – If error occurs.
- Return type:
None
- static set_chart_type(chart_doc, diagram_name)[source]
Sets chart diagram name
- Parameters:
chart_doc (XChartDocument) – Chart Document
diagram_name (DiagramEnum | str) – Diagram Name
- Raises:
ChartError – If error occurs.
- Return type:
None
Sets how the caption of data points is displayed.
- Parameters:
chart_doc (XChartDocument) – Chart Document
label_types (ChartDataCaptionEnum) – Flags, specifies how the caption of data points is displayed.
- Raises:
DiagramNotExistingError – If
chart_doc
diagram does not existServiceNotSupported – If
com.sun.star.chart.Diagram
service is not supported by diagram.ChartError – If any other error occurs.
- Return type:
None
- static set_data_placement(chart_doc, placement)[source]
Sets the relative position for the data label.
- Parameters:
chart_doc (XChartDocument) – Chart Document.
placement (DataLabelPlacementEnum) – Specifies a relative position for the data label.
- Raises:
DiagramNotExistingError – If
chart_doc
diagram does not existServiceNotSupported – If
com.sun.star.chart.ChartDataPointProperties
service is not supported by diagram.ChartError – If any other error occurs.
- Return type:
None
- static set_data_row_descriptions(chart_doc, *descs)[source]
Set data row descriptions for chart.
- Parameters:
chart_doc (XChartDocument) – Chart Document.
*descs (str) – Variable length argument list of descriptions. Must match the same number of descriptions in the chart.
- Raises:
ValueError – If wrong number of descriptions are provided.
ChartError – If any other error occurs
- Return type:
None
Note
This method works, but affects the graphic data point position.
- static set_second_y_axis(chart_doc, title)[source]
Sets the second Y Axis Title
- Parameters:
chart_doc (XChartDocument) – Chart Document
title (str) – Title text
- Raises:
DiagramNotExistingError – If
chart_doc
diagram does not existServiceNotSupported – If
com.sun.star.chart.ChartTwoAxisYSupplier
service is not supported by diagram.ChartError – If any other error occurs.
- Return type:
None
- static set_subtitle(chart_doc, subtitle)[source]
Set subtitle for a chart document
- Parameters:
chart_doc (XChartDocument) – Chart document
subtitle (str) – Subtitle text
- Raises:
ChartError – If error occurs
- Return type:
None
- static set_symbol(chart_doc, has_symbol)[source]
Sets chart symbol.
- Parameters:
chart_doc (XChartDocument) – Chart Document.
has_symbol (bool) – Specifies if chart is 3d.
- Raises:
DiagramNotExistingError – If
chart_doc
diagram does not existServiceNotSupported – If chart document is not a
LineDiagram
orXYDiagram
ChartError – If any other error occurs.
- Return type:
None
- static set_title(chart_doc, title)[source]
Set title for a chart document
- Parameters:
chart_doc (XChartDocument) – Chart document
title (str) – Title text
- Raises:
ChartError – If error occurs
- Return type:
None
- static set_trend(chart_doc, curve_type)[source]
Sets chart trend
- Parameters:
chart_doc (XChartDocument) – Chart Document.
curve_type (ChartRegressionCurveType) – determines a type of regression for the data row values.
- Raises:
DiagramNotExistingError – If
chart_doc
diagram does not existServiceNotSupported – If
com.sun.star.chart.ChartStatistics
service is not supported by diagram.ChartError – If any other error occurs.
- Return type:
None
- static set_use_horizontals(chart_doc, is_vertical=True)[source]
Determines if the bars of a Bar Diagram chart are drawn vertically or horizontally. Default is vertical.
If
is_vertical
isFalse
you get a column chart rather than a bar chart.- Parameters:
chart_doc (XChartDocument) – Bar Diagram chart document
is_vertical (bool, optional) – Determines if chart is drawn vertically or horizontally. Default
True
.
- Raises:
DiagramNotExistingError – If
chart_doc
diagram does not existServiceNotSupported – If
com.sun.star.chart.BarDiagram
service is not supported by diagram.ChartError – If any other error occurs.
- Return type:
None
- static set_use_lines(chart_doc, has_lines)[source]
Sets if the chart type has lines connecting the data points or contains just symbols.
- Parameters:
chart_doc (XChartDocument) –
LineDiagram
orXYDiagram
chart document.has_lines (bool) – Determines if the chart type has lines connecting the data points or contains just symbols.
- Raises:
DiagramNotExistingError – If
chart_doc
diagram does not existServiceNotSupported – If chart document is not a
LineDiagram
orXYDiagram
ChartError – If any other error occurs.
- Return type:
None
- static set_visible(sheet, is_visible)[source]
Set visible state of charts.
- Parameters:
sheet (XSpreadsheet) – Spreadsheet
is_visible (bool) – Visible State.
True
shows charts,False
hides charts.
- Raises:
ChartError – If error occurs.
- Return type:
None
Note
Any chart on sheet errors when attempting to set visibility then then it is skipped and no error is raised.
- static set_x_axis_title(chart_doc, title)[source]
Sets the X Axis Title
- Parameters:
chart_doc (XChartDocument) – Chart Document
title (str) – Title text
- Raises:
DiagramNotExistingError – If
chart_doc
diagram does not existServiceNotSupported – If
com.sun.star.chart.ChartAxisXSupplier
service is not supported by diagram.ChartError – If any other error occurs.
- Return type:
None
- static set_y_axis_title(chart_doc, title)[source]
Sets the Y Axis Title
- Parameters:
chart_doc (XChartDocument) – Chart Document
title (str) – Title text
- Raises:
DiagramNotExistingError – If
chart_doc
diagram does not existServiceNotSupported – If
com.sun.star.chart.ChartAxisYSupplier
service is not supported by diagram.ChartError – If any other error occurs.
- Return type:
None
- static show_data_array(chart_doc)[source]
Prints data array info to console.
- Parameters:
chart_doc (XChartDocument) – Chart Document.
- Return type:
None
- static show_data_row_props(chart_doc)[source]
Prints data row info to console.
- Parameters:
chart_doc (XChartDocument) – Chart Document.
- Return type:
None
- static view_legend(chart_doc, is_visible)[source]
Set the visibility of chart document legend
- Parameters:
chart_doc (XChartDocument) – Chart Document
is_visible (bool) – Visibility
- Raises:
ServiceNotSupported – If
com.sun.star.chart.ChartDocument
service is not supported.ChartError – If any other error occurs.
- Return type:
None