Module chart2

class ooodev.office.chart2.Chart2[source]

Chart 2 Class

classmethod add_cat_labels(chart_doc, data_label, data_range)[source]

Add Category Labels.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • data_label (str) – Data label.

  • data_range (str) – Data range.

Raises:

ChartError – If error occurs.

Return type:

None

classmethod add_chart_type(chart_doc: com.sun.star.chart2.XChartDocument, chart_type: ooodev.utils.kind.chart2_types.ChartTypeNameBase) com.sun.star.chart2.XChartType[source]
classmethod add_chart_type(chart_doc: com.sun.star.chart2.XChartDocument, chart_type: str) com.sun.star.chart2.XChartType
classmethod add_chart_type(chart_doc, chart_type)

Adds a chart type.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • chart_doc (XChartDocument) – Chart Document

  • chart_type (ChartTypeNameBase | str) – Chart type.

Raises:

ChartError – If error occurs

Returns:

Chart type object

Return type:

XChartType

Hint

chart_type can be any value of ChartTypes that are of the NAMED value of the various chart types.

Example: chart_type=Chart2.ChartLookup.Stock.NAMED.CANDLE_STICK_CHART

classmethod add_stock_line(chart_doc, data_label, data_range)[source]

Add stock line to chart.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • chart_doc (XChartDocument) – Chart Document

  • data_label (str) – Data label

  • data_range (str) – Data range

Raises:

ChartError – If error occurs.

Return type:

None

static add_table_chart(sheet, chart_name, cells_range, cell_name, width, height)[source]

Adds a new table chart at a given cell name and size, using cells range.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet

  • chart_name (str) – Chart name.

  • cells_range (CellRangeAddress) – Cell Range

  • cell_name (str) – Cell Name such as A1

  • width (int) – Chart Width

  • height (int) – Chart Height

Raises:

ChartError – If error occurs.

Return type:

None

classmethod calc_regressions(chart_doc)[source]

Several different regression functions are calculated using the chart’s data. Their equations and R2 values are printed to the console

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:

chart_doc (XChartDocument) – Chart Document

Return type:

None

static color_stock_bars(ct, w_day_color, b_day_color)[source]

Set color of stock bars for a CandleStickChartType chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • ct (XChartType) – Chart Type.

  • w_day_color (Color) – Chart white day color

  • b_day_color (Color) – Chart black day color

Raises:
Return type:

None

See also

CommonColor

classmethod copy_chart(ssdoc, sheet, chart_name='')[source]

Copies a chart to the clipboard using a dispatch command.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • ssdoc (XSpreadsheetDocument) – Spreadsheet Document.

  • sheet (XSpreadsheet) – Spreadsheet.

  • chart_name (str, optional) – Chart name. Defaults to “”. If "" then first chart is copied.

Raises:

ChartError – If error occurs.

Return type:

None

Changed in version 0.9.4: Added chart_name parameter.

static create_curve(curve_kind)[source]

Creates a regression curve.

Matches the regression constants defined in curve_kind to regression services offered by the API:

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:

curve_kind (CurveKind) – Curve kind.

Raises:

ChartError – If error occurs.

Returns:

Regression Curve object.

Return type:

XRegressionCurve

static create_data_series()[source]

Gets an instance of Chart2 DataSeries.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Raises:

ChartError – If error occurs.

Returns:

Data Series instance.

Return type:

XDataSeries

static create_ld_seq(dp, role, data_label, data_range)[source]

Creates a XLabeledDataSequence instance from two XDataSequence objects, one acting as a label the other as data.

The XDataSequence object representing the data must have its “Role” property set to indicate the type of the data.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • dp (XDataProvider) – Data Provider

  • role (DataRoleKind | str) – Role that indicate the type of the data.

  • data_label (str) – Data label

  • data_range (str) – Data range

Raises:

ChartError – If error occurs

Returns:

Labeled data sequence object.

Return type:

XLabeledDataSequence

classmethod create_title(title, styles=None)[source]

Creates a title object.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • title (str) – Title text.

  • styles (Sequence[StyleT], optional) – Styles to apply to title.

Raises:

ChartError – If error occurs.

Returns:

Title object.

Return type:

XTitle

Note

The title has a default font size of 14 and the font name applied is the font returned by Info.get_font_general_name().

Hint

Styles that can be applied are found in ooodev.format.chart2.direct.title subpackages.

classmethod dash_lines(chart_doc)[source]

Sets chart data series to dashed lines.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

chart_doc (XChartDocument) – Chart Document

Raises:

ChartError – If error occurs.

Return type:

None

classmethod draw_regression_curve(chart_doc, curve_kind, styles=None)[source]

Draws a regression curve.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • chart_doc (XChartDocument) – Chart Document

  • curve_kind (CurveKind) – Curve kind.

  • styles (Sequence[StyleT], optional) – Styles to apply to the curve. Defaults to None.

Raises:

ChartError – If error occurs.

Returns:

Regression curve property set.

Return type:

XPropertySet

Hint

Styles that can be applied are found in the following subpackages:

Changed in version 0.9.4: Added styles argument, and now returns the regression curve property set.

classmethod eval_curve(chart_doc, curve)[source]

Uses XRegressionCurve.getCalculator() to access the XRegressionCurveCalculator interface. It sets up the data and parameters for a particular curve, and prints the results of curve fitting to the console.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document

  • curve (XRegressionCurve) – Regression Curve object.

Return type:

None

classmethod find_chart_type(chart_doc, chart_type)[source]

Finds a chart for a given chart type.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document

  • chart_type (ChartTypeNameBase | str) – Chart type.

Raises:
Returns:

Found chart type.

Return type:

XChartType

Hint

chart_type can be any value of ChartTypes that are of the NAMED value of the various chart types.

Example: chart_type=Chart2.ChartLookup.Stock.NAMED.CANDLE_STICK_CHART

classmethod get_axis(chart_doc, axis_val, idx)[source]

Gets axis.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document

  • axis_val (AxisKind) – Axis Kind

  • idx (int) – Axis index

Raises:

ChartError – If error occurs.

Returns:

Axis object.

Return type:

XAxis

classmethod get_axis_title(chart_doc, axis_val, idx)[source]

Gets axis Title.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • axis_val (AxisKind) – Axis Kind.

  • idx (int) – Index.

Raises:

ChartError – If error occurs.

Returns:

Title object.

Return type:

XTitle

See also

get_axis()

static get_axis_type_string(axis_type)[source]

Gets axis type as string.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

axis_type (AxisTypeKind) – Axis Type

Raises:

UnKnownError – If unable to determine axis_type

Returns:

Axis type as string.

Return type:

str

static get_chart_data(data_source, idx)[source]

Gets chart data.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • data_source (XDataSource) – Data Source.

  • idx (int) – Index

Raises:
  • IndexError – If index is out of range.

  • ChartError – If any other error occurs.

Returns:

Chart data.

Return type:

Tuple[float]

classmethod get_chart_doc(sheet, chart_name)[source]

Gets the chart document from the sheet.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • chart_name (str) – Chart Name.

Raises:

ChartError – If error occurs.

Returns:

Spreadsheet document.

Return type:

XChartDocument

classmethod get_chart_draw_page(sheet, chart_name='')[source]

Gets chart draw page.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet

  • chart_name (str, optional) – Chart name. Defaults to “”. If "" then first chart Draw Page is returned.

Raises:

ChartError – If error occurs.

Returns:

Draw Page object

Return type:

XDrawPage

Changed in version 0.9.4: Added chart_name parameter.

classmethod get_chart_image(sheet, chart_name='')[source]

Get chart image as XGraphic.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • chart_name (str, optional) – Chart name. Defaults to “”. If "" then first chart image is returned.

Raises:

ChartError – If error occurs.

Returns:

Graphic object

Return type:

XGraphic

Changed in version 0.9.4: Added chart_name parameter.

static get_chart_shape(sheet, chart_name='')[source]

Gets chart shape.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • chart_name (str, optional) – Chart name. Defaults to “”. If "" then first chart is returned.

Raises:
Returns:

Shape object.

Return type:

XShape

Changed in version 0.9.4: Added chart_name parameter.

static get_chart_templates(chart_doc)[source]

Gets a list of chart templates (services).

Method is Lo Instance Safe for use with multiple documents.

Parameters:

chart_doc (XChartDocument) – Chart Document.

Raises:

ChartError – If error occurs

Returns:

List of chart templates

Return type:

List[str]

classmethod get_chart_type(chart_doc)[source]

Gets a chart type for a chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

chart_doc (XChartDocument) – Chart Document.

Raises:

ChartError – If error occurs.

Returns:

Chart type object.

Return type:

XChartType

classmethod get_chart_types(chart_doc)[source]

Gets chart types for a chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

chart_doc (XChartDocument) – Chart Document.

Raises:

ChartError – If error occurs.

Returns:

Tuple of chart types.

Return type:

Tuple[XChartType, …]

See also

get_chart_type()

static get_coord_system(chart_doc)[source]

Gets coordinate system.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

chart_doc (XChartDocument) – Chart Document.

Raises:

ChartError – If error occurs.

Returns:

Coordinate system object.

Return type:

XCoordinateSystem

static get_curve_type(curve)[source]

Gets curve kind from regression object.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

curve (XRegressionCurve) – Regression curve object.

Raises:

NotFoundError – If unable to detect curve kind.

Returns:

Curve Kind

Return type:

CurveKind

classmethod get_data_point_props(chart_doc, series_idx, idx)[source]

Get the proprieties for a specific index within the data points.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • series_idx (int) – Series Index

  • idx (int) – Index to extract from the data points data. If idx=-1 then the last data point is returned.

Raises:
  • NotFoundError – If series_idx did not find any data points.

  • IndexError – If an index is out of range.

Returns:

A single property set from the data points series.

Return type:

XPropertySet

Changed in version 0.9.0: idx value of -1 returns last data point.

classmethod get_data_points_props(chart_doc, idx)[source]

Gets all the properties for the data in the specified series.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • idx (int) – Index.

Raises:

IndexError – If idx is out of range.

Returns:

Property set list.

Return type:

List[XPropertySet]

classmethod get_data_series(chart_doc: com.sun.star.chart2.XChartDocument) Tuple[com.sun.star.chart2.XDataSeries, ...][source]
classmethod get_data_series(chart_doc: com.sun.star.chart2.XChartDocument, chart_type: ooodev.utils.kind.chart2_types.ChartTypeNameBase) Tuple[com.sun.star.chart2.XDataSeries, ...]
classmethod get_data_series(chart_doc: com.sun.star.chart2.XChartDocument, chart_type: str) Tuple[com.sun.star.chart2.XDataSeries, ...]
classmethod get_data_series(chart_doc, chart_type='')

Gets data series for a chart of a given chart type.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document

  • chart_type (ChartTypeNameBase, str, optional) – Chart Type.

Raises:

ChartError – If any other error occurs.

Returns:

Data Series

Return type:

Tuple[XDataSeries, …]

Hint

chart_type can be any value of ChartTypes that are of the NAMED value of the various chart types.

Example: chart_type=Chart2.ChartLookup.Stock.NAMED.CANDLE_STICK_CHART

classmethod get_data_source(chart_doc: com.sun.star.chart2.XChartDocument) com.sun.star.chart2.data.XDataSource[source]
classmethod get_data_source(chart_doc: com.sun.star.chart2.XChartDocument, chart_type: ooodev.utils.kind.chart2_types.ChartTypeNameBase) com.sun.star.chart2.data.XDataSource
classmethod get_data_source(chart_doc: com.sun.star.chart2.XChartDocument, chart_type: str) com.sun.star.chart2.data.XDataSource
classmethod get_data_source(chart_doc, chart_type='')

Get data source of a chart for a given chart type.

This method assumes that the programmer wants the first data source in the data series. This is adequate for most charts which only use one data source.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • chart_type (ChartTypeNameBase | str) – Chart type.

Raises:
Returns:

Chart data source.

Return type:

XDataSource

Hint

chart_type can be any value of ChartTypes that are of the NAMED value of the various chart types.

Example: chart_type=Chart2.ChartLookup.Stock.NAMED.CANDLE_STICK_CHART

static get_legend(chart_doc)[source]

Gets chart legend.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

chart_doc (XChartDocument) – Chart Document.

Raises:

ChartError – If error occurs.

Returns:

Legend object or None if no legend exists.

Return type:

XLegend

New in version 0.9.4.

static get_number_format_key(chart_doc, nf_str)[source]

Converts a number format string into a number format key, which can be assigned to NumberFormat property.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document

  • nf_str (str) – Number format string.

Raises:

ChartError – If error occurs.

Returns:

Number format key.

Return type:

int

Note

The string-to-key conversion is straight forward if you know what number format string to use, but there’s little documentation on them. Probably the best approach is to use the Format Cells menu item in a spreadsheet document, and examine the dialog

static get_subtitle(chart_doc)[source]

Gets subtitle from chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

chart_doc (XChartDocument) – Chart Document.

Raises:

ChartError – If error occurs.

Returns:

Title object.

Return type:

XTitle

static get_table_chart(sheet, chart_name)[source]

Gets the named table chart from the sheet.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet.

  • chart_name (str) – Chart Name.

Raises:

ChartError – If error occurs.

Returns:

Table Chart.

Return type:

XTableChart

static get_title(chart_doc)[source]

Gets Title from chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

chart_doc (XChartDocument) – Chart Document.

Raises:

ChartError – If error occurs.

Returns:

Title object.

Return type:

XTitle

classmethod get_x_axis(chart_doc)[source]

Get Chart X axis.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

chart_doc (XChartDocument) – Chart Document.

Raises:

ChartError – If error occurs.

Returns:

Chart X Axis object.

Return type:

XAxis

See also

get_axis()

classmethod get_x_axis2(chart_doc)[source]

Get Chart X axis2.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

chart_doc (XChartDocument) – Chart Document.

Raises:

ChartError – If error occurs.

Returns:

Chart X Axis2 object.

Return type:

XAxis

See also

get_axis()

classmethod get_x_axis2_title(chart_doc)[source]

Gets X axis2 title.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

chart_doc (XChartDocument) – Chart Document

Raises:

ChartError – If error occurs

Returns:

Title object.

Return type:

XTitle

See also

get_axis_title()

classmethod get_x_axis_title(chart_doc)[source]

Gets X axis title.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

chart_doc (XChartDocument) – Chart Document

Raises:

ChartError – If error occurs

Returns:

Title object.

Return type:

XTitle

See also

get_axis_title()

classmethod get_y_axis(chart_doc)[source]

Get Chart Y axis.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

chart_doc (XChartDocument) – Chart Document.

Raises:

ChartError – If error occurs.

Returns:

Chart Y Axis object.

Return type:

XAxis

See also

get_axis()

classmethod get_y_axis2(chart_doc)[source]

Get Chart Y axis2.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

chart_doc (XChartDocument) – Chart Document.

Raises:

ChartError – If error occurs.

Returns:

Chart Y Axis2 object.

Return type:

XAxis

See also

get_axis()

classmethod get_y_axis2_title(chart_doc)[source]

Gets Y axis2 title.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

chart_doc (XChartDocument) – Chart Document

Raises:

ChartError – If error occurs

Returns:

Title object.

Return type:

XTitle

See also

get_axis_title()

classmethod get_y_axis_title(chart_doc)[source]

Gets Y axis title.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

chart_doc (XChartDocument) – Chart Document

Raises:

ChartError – If error occurs

Returns:

Title object.

Return type:

XTitle

See also

get_axis_title()

static has_categories(diagram_name)[source]

Gets if diagram name has categories.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

diagram_name (ChartTemplateBase | str) – Diagram Name/

Returns:

True if has categories; Otherwise, False.

Return type:

bool

Hint

diagram_name can be any value of ChartTypes that starts with TEMPLATE_

Example: diagram_name=Chart2.ChartLookup.Line.TEMPLATE_PERCENT.PERCENT_STACKED_LINE

classmethod insert_chart(*, sheet=None, cells_range=None, cell_name='', width=16, height=9, diagram_name='Column', color_bg=14085119, color_wall=11393254, **kwargs)[source]

Insert a new chart.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • sheet (XSpreadsheet, optional) – Spreadsheet

  • cells_range (CellRangeAddress, optional) – Cell range address. Defaults to current selected cells.

  • cell_name (str, optional) – Cell name such as A1.

  • width (int, optional) – Width. Default 16.

  • height (int, optional) – Height. Default 9.

  • diagram_name (ChartTemplateBase | str) – Diagram Name. Defaults to Column.

  • color_bg (Color, optional) – Color Background. Defaults to CommonColor.PALE_BLUE. If set to None then no color is applied.

  • color_wall (Color, optional) – Color Wall. Defaults to CommonColor.LIGHT_BLUE. If set to None then no color is applied.

Keyword Arguments:
  • chart_name (str, optional) – Chart name

  • is_row (bool, optional) – Determines if the data is row data or column data.

  • first_cell_as_label (bool, optional) – Set is first row is to be used as a label.

  • set_data_point_labels (bool, optional) – Determines if the data point labels are set.

Raises:

ChartError – If error occurs

Returns:

Chart Document that was created and inserted

Return type:

XChartDocument

Note

Keyword Arguments are to mostly be ignored. If finer control over chart creation is needed then Keyword Arguments can be used.

Note

See Open Office Wiki - The Structure of Charts for more information.

Hint

diagram_name can be any value of ChartTypes that starts with TEMPLATE_

Example: diagram_name=Chart2.ChartLookup.Line.TEMPLATE_PERCENT.PERCENT_STACKED_LINE

Changed in version 0.8.1: All parameters made optional. Added chart_name parameter.

classmethod lock_controllers(chart_doc)[source]

Suspends some notifications to the controllers which are used for display updates.

The calls to lock_controllers() and unlock_controllers() may be nested and even overlapping, but they must be in pairs. While there is at least one lock remaining, some notifications for display updates are not broadcast.

Method is Lo Instance Safe for use with multiple documents.

Returns:

False if CONTROLLERS_LOCKING event is canceled; Otherwise, True

Return type:

bool

Events:
Parameters:

chart_doc (XChartDocument) –

New in version 0.9.4.

classmethod print_chart_types(chart_doc)[source]

Prints chart types to the console.

Method is Lo Instance Safe for use with multiple documents.

Parameters:

chart_doc (XChartDocument) – Chart Document.

Return type:

None

static print_labeled_seqs(data_source)[source]

Prints labeled sequence information to console.

Method is Lo Instance Safe for use with multiple documents.

A diagnostic function for printing all the labeled data sequences stored in an XDataSource:

Parameters:

data_source (XDataSource) – Data Source.

Return type:

None

classmethod print_scale_data(axis_name, axis)[source]

Prints axis info to console.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • axis_name (str) – Axis Name

  • axis (XAxis) – Axis

Return type:

None

static remove_chart(sheet, chart_name)[source]

Removes a chart from Spreadsheet.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • sheet (XSpreadsheet) – Spreadsheet

  • chart_name (str) – Chart Name

Returns:

True if chart was removed; Otherwise, False

Return type:

bool

New in version 0.8.1.

classmethod rotate_axis_title(chart_doc, axis_val, idx, angle)[source]

Rotates axis title.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • axis_val (AxisKind) – Axis kind.

  • idx (int) – Index

  • angle (Angle, int) – Angle

Raises:

ChartError – If error occurs.

Return type:

None

classmethod rotate_x_axis2_title(chart_doc, angle)[source]

Rotates X axis2 title.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • angle (Angle, int) – Angle

Raises:

ChartError – If error occurs.

Return type:

None

classmethod rotate_x_axis_title(chart_doc, angle)[source]

Rotates X axis title.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • angle (Angle, int) – Angle

Raises:

ChartError – If error occurs.

Return type:

None

classmethod rotate_y_axis2_title(chart_doc, angle)[source]

Rotates Y axis2 title.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • angle (Angle, int) – Angle

Raises:

ChartError – If error occurs.

Return type:

None

classmethod rotate_y_axis_title(chart_doc, angle)[source]

Rotates Y axis title.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • angle (Angle, int) – Angle

Raises:

ChartError – If error occurs.

Return type:

None

classmethod scale_axis(chart_doc, axis_val, idx, scale_type)[source]

Scales the chart axis.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • axis_val (AxisKind) – Axis kind.

  • idx (int) – Index

  • scale_type (CurveKind) – Scale kind

Raises:

ChartError – If error occurs.

Returns:

Axis object.

Return type:

XAxis

Note

Supported types of scale_type are LINEAR, LOGARITHMIC, EXPONENTIAL and POWER. If scale_type is not supported then the Scaling is not set.

classmethod scale_x_axis(chart_doc, scale_type)[source]

Scales the chart X axis.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • scale_type (CurveKind) – Scale kind

Raises:

ChartError – If error occurs.

Returns:

Axis object.

Return type:

XAxis

Note

Supported types of scale_type are LINEAR, LOGARITHMIC, EXPONENTIAL and POWER. If scale_type is not supported then the Scaling is not set.

See also

scale_axis()

classmethod scale_y_axis(chart_doc, scale_type)[source]

Scales the chart Y axis.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • scale_type (CurveKind) – Scale kind

Raises:

ChartError – If error occurs.

Returns:

Axis object.

Return type:

XAxis

Note

Supported types of scale_type are LINEAR, LOGARITHMIC, EXPONENTIAL and POWER. If scale_type is not supported then the Scaling is not set.

See also

scale_axis()

classmethod set_axis_title(chart_doc, title, axis_val, idx, styles=None)[source]

Sets axis title.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • title (str) – Title text.

  • axis_val (AxisKind) – Axis kind.

  • idx (int) – Index

  • styles (Sequence[StyleT], optional) – Styles to apply to title.

Raises:

ChartError – If error occurs.

Returns:

Axis Title.

Return type:

XTitle

Note

The title is set to a font size of 12 and the font applied is the font returned by Info.get_font_general_name()

Hint

Styles that can be applied are found in ooodev.format.chart2.direct.title subpackages.

See also

get_axis()

static set_background_colors(chart_doc, bg_color, wall_color)[source]

Set the background colors for a chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • bg_color (Color) – Color Value for background. If value < 0 then no color is set.

  • wall_color (Color) – Color Value for wall. If value < 0 then no color is set.

Raises:

ChartError – If error occurs.

Return type:

None

See also

CommonColor

classmethod set_chart_shape_3d(chart_doc, shape)[source]

Sets chart 3d shape.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • shape (DataPointGeometry3DEnum) – Shape kind.

Raises:

ChartError – If an error occurs.

Return type:

None

classmethod set_data_point_labels(chart_doc, label_type)[source]

Sets the data point label of a chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
Raises:

ChartError – If error occurs.

Return type:

None

classmethod set_grid_lines(chart_doc: com.sun.star.chart2.XChartDocument, axis_val: ooodev.utils.kind.axis_kind.AxisKind) com.sun.star.beans.XPropertySet[source]
classmethod set_grid_lines(chart_doc: com.sun.star.chart2.XChartDocument, axis_val: ooodev.utils.kind.axis_kind.AxisKind, *, styles: Sequence[ooodev.proto.style_obj.StyleT]) com.sun.star.beans.XPropertySet
classmethod set_grid_lines(chart_doc: com.sun.star.chart2.XChartDocument, axis_val: ooodev.utils.kind.axis_kind.AxisKind, idx: int) com.sun.star.beans.XPropertySet
classmethod set_grid_lines(chart_doc: com.sun.star.chart2.XChartDocument, axis_val: ooodev.utils.kind.axis_kind.AxisKind, idx: int, styles: Sequence[ooodev.proto.style_obj.StyleT]) com.sun.star.beans.XPropertySet
classmethod set_grid_lines(chart_doc, axis_val, idx=0, styles=None)

Set the grid lines for a chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • axis_val (AxisKind) – Axis kind.

  • idx (int, optional) – Index. Defaults to 0.

  • styles (Sequence[StyleT], optional) – Styles to apply.

Raises:

ChartError – If error occurs.

Returns:

Property Set of Grid Properties.

Return type:

XPropertySet

Hint

Styles that can be applied are found in ooodev.format.chart2.direct.grid.

classmethod set_subtitle(chart_doc, subtitle, styles=None)[source]

Gets subtitle.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • subtitle (str) – Subtitle text.

  • styles (Sequence[StyleT], optional) – Styles to apply to subtitle.

Raises:

ChartError – If error occurs.

Returns:

Title object.

Return type:

XTitle

Note

The subtitle is set to a font size of 12 and the font applied is the font returned by Info.get_font_general_name().

Hint

Styles that can be applied are found in ooodev.format.chart2.direct.title subpackages.

static set_template(chart_doc, diagram, diagram_name)[source]

Sets template of chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document

  • diagram (XDiagram) – diagram

  • diagram_name (ChartTemplateBase | str) – Diagram template name

Raises:

ChartError – If error occurs.

Returns:

Chart Template

Return type:

XInterface

Note

If unable to create template from diagram_name for any reason then ChartTypes.Column.TEMPLATE_STACKED.COLUMN ("Column") is used as a fallback.

Hint

diagram_name can be any value of ChartTypes that starts with TEMPLATE_

Example: diagram_name=Chart2.ChartLookup.Line.TEMPLATE_PERCENT.PERCENT_STACKED_LINE

classmethod set_title(chart_doc, title, styles=None)[source]

Sets the title of chart.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • title (str) – Title as string.

  • styles (Sequence[StyleT], optional) – Styles to apply to title.

Raises:

ChartError – If error occurs.

Returns:

Title Object

Return type:

XTitle

Note

The title has a default font size of 14 and the font name applied is the font returned by Info.get_font_general_name().

Hint

Styles that can be applied are found in ooodev.format.chart2.direct.title subpackages.

classmethod set_x_axis2_title(chart_doc, title, styles=None)[source]

Sets X axis2 Title.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • title (str) – Title Text.

  • styles (Sequence[StyleT], optional) – Styles to apply to title.

Returns:

Title object.

Return type:

XTitle

Hint

Styles that can be applied are found in ooodev.format.chart2.direct.title subpackages.

See also

set_axis_title()

classmethod set_x_axis_title(chart_doc, title, styles=None)[source]

Sets X axis Title.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • title (str) – Title Text.

  • styles (Sequence[StyleT], optional) – Styles to apply to title.

Returns:

Title object.

Return type:

XTitle

Hint

Styles that can be applied are found in ooodev.format.chart2.direct.title subpackages.

See also

set_axis_title()

static set_x_title_font(xtitle, font_name, pt_size)[source]

Sets X title font.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • xtitle (XTitle) – Title instance.

  • font_name (str) – Font Name

  • pt_size (int) – Font point size

Raises:

ChartError – If error occurs.

Return type:

None

classmethod set_y_axis2_title(chart_doc, title, styles=None)[source]

Sets Y axis2 Title.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • title (str) – Title Text.

  • styles (Sequence[StyleT], optional) – Styles to apply to title.

Returns:

Title object.

Return type:

XTitle

Hint

Styles that can be applied are found in ooodev.format.chart2.direct.title subpackages.

See also

set_axis_title()

classmethod set_y_axis_title(chart_doc, title, styles=None)[source]

Sets Y axis Title.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • title (str) – Title Text.

  • styles (Sequence[StyleT], optional) – Styles to apply to title.

Returns:

Title object

Return type:

XTitle

Hint

Styles that can be applied are found in ooodev.format.chart2.direct.title subpackages.

See also

set_axis_title()

classmethod set_y_error_bars(chart_doc, data_label, data_range)[source]

Sets Y error Bars.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • data_label (str) – Data Label.

  • data_range (str) – Data Range.

Raises:

ChartError – If error occurs.

Return type:

None

classmethod show_axis_label(chart_doc, axis_val, idx, is_visible)[source]

Sets the visibility for chart axis label.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • axis_val (AxisKind) – Axis kind.

  • idx (int) – Index

  • is_visible (bool) – Visible state

Raises:

ChartError – If error occurs.

Return type:

None

static show_data_source_args(chart_doc, data_source)[source]

Prints data information to console.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • data_source (XDataSource) – Data Source.

Return type:

None

classmethod show_x_axis2_label(chart_doc, is_visible)[source]

Sets the visibility for chart X axis2 label.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • is_visible (bool) – Visible state

Raises:

ChartError – If error occurs.

Return type:

None

classmethod show_x_axis_label(chart_doc, is_visible)[source]

Sets the visibility for chart X axis label.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • is_visible (bool) – Visible state

Raises:

ChartError – If error occurs.

Return type:

None

classmethod show_y_axis2_label(chart_doc, is_visible)[source]

Sets the visibility for chart Y axis2 label.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • is_visible (bool) – Visible state

Raises:

ChartError – If error occurs.

Return type:

None

classmethod show_y_axis_label(chart_doc, is_visible)[source]

Sets the visibility for chart Y axis label.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • is_visible (bool) – Visible state

Raises:

ChartError – If error occurs.

Return type:

None

static style_background(chart_doc, styles)[source]

Styles background of chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • styles (Sequence[StyleT]) – One or more styles to apply chart background.

Return type:

None

New in version 0.9.0.

classmethod style_data_point(chart_doc, series_idx, idx, styles)[source]

Styles a data point of chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • series_idx (int) – Series Index.

  • idx (int) – Index to extract from the data points data. If idx=-1 then the last data point is styled.

  • styles (Sequence[StyleT]) – One or more styles to apply chart data point.

Return type:

None

Hint

Styles that can be applied are found in the following packages.

New in version 0.9.0.

classmethod style_data_series(chart_doc, styles, idx=-1)[source]

Styles one or more data series of chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • styles (Sequence[StyleT]) – One or more styles to apply chart data series.

  • idx (int, optional) – Zero based series index. If value is -1 then styles all data series are styled, Otherwise only data series specified by index is styled. Defaults to -1.

Return type:

None

Hint

Styles that can be applied are found in the following packages.

New in version 0.9.4.

static style_floor(chart_doc, styles)[source]

Styles Floor of 3D chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • styles (Sequence[StyleT]) – One or more styles to apply chart floor.

Return type:

None

Hint

Styles that can be applied are found in ooodev.format.chart2.direct.wall subpackages.

New in version 0.9.4.

classmethod style_grid(chart_doc, axis_val, styles, idx=0)[source]

Style Grid.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • axis_val (AxisKind) – Axis kind.

  • styles (Sequence[StyleT]) – Styles to apply.

  • idx (int, optional) – Index. Defaults to 0.

Return type:

None

Hint

Styles that can be applied are found in ooodev.format.chart2.direct.grid.

classmethod style_legend(chart_doc, styles)[source]

Styles legend of chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • styles (Sequence[StyleT]) – One or more styles to apply chart legend.

Return type:

None

Hint

Styles that can be applied are found in the following packages.

New in version 0.9.0.

classmethod style_subtitle(chart_doc, styles)[source]

Styles subtitle of chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • styles (Sequence[StyleT]) – One or more styles to apply chart subtitle.

Return type:

None

Hint

Styles that can be applied are found in ooodev.format.chart2.direct.title subpackages.

New in version 0.9.4.

classmethod style_title(chart_doc, styles)[source]

Styles title of chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • styles (Sequence[StyleT]) – One or more styles to apply chart title.

Return type:

None

Hint

Styles that can be applied are found in ooodev.format.chart2.direct.title subpackages.

New in version 0.9.4.

static style_wall(chart_doc, styles)[source]

Styles Wall of chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • styles (Sequence[StyleT]) – One or more styles to apply chart wall.

Return type:

None

Hint

Styles that can be applied are found in ooodev.format.chart2.direct.wall subpackages.

New in version 0.9.0.

classmethod style_x_axis(chart_doc, styles)[source]

Styles X axis of chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • styles (Sequence[StyleT]) – One or more styles to apply chart X axis.

Return type:

None

Hint

Styles that can be applied are found in ooodev.format.chart2.direct.axis subpackages.

New in version 0.9.4.

classmethod style_x_axis2(chart_doc, styles)[source]

Styles X axis2 of chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • styles (Sequence[StyleT]) – One or more styles to apply chart X axis2.

Return type:

None

Hint

Styles that can be applied are found in ooodev.format.chart2.direct.axis subpackages.

New in version 0.9.4.

classmethod style_x_axis2_title(chart_doc, styles)[source]

Styles X axis2 title of chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • styles (Sequence[StyleT]) – One or more styles to apply chart X axis2 title.

Return type:

None

Hint

Styles that can be applied are found in ooodev.format.chart2.direct.title subpackages.

New in version 0.9.4.

classmethod style_x_axis_title(chart_doc, styles)[source]

Styles X axis title of chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • styles (Sequence[StyleT]) – One or more styles to apply chart X axis title.

Return type:

None

Hint

Styles that can be applied are found in ooodev.format.chart2.direct.title subpackages.

New in version 0.9.4.

classmethod style_y_axis(chart_doc, styles)[source]

Styles Y axis of chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • styles (Sequence[StyleT]) – One or more styles to apply chart Y axis.

Return type:

None

Hint

Styles that can be applied are found in ooodev.format.chart2.direct.axis subpackages.

New in version 0.9.4.

classmethod style_y_axis2(chart_doc, styles)[source]

Styles Y axis2 of chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • styles (Sequence[StyleT]) – One or more styles to apply chart Y axis2.

Return type:

None

Hint

Styles that can be applied are found in ooodev.format.chart2.direct.axis subpackages.

New in version 0.9.4.

classmethod style_y_axis2_title(chart_doc, styles)[source]

Styles X axis2 title of chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • styles (Sequence[StyleT]) – One or more styles to apply chart Y axis2 title.

Return type:

None

Hint

Styles that can be applied are found in ooodev.format.chart2.direct.title subpackages.

New in version 0.9.4.

classmethod style_y_axis_title(chart_doc, styles)[source]

Styles X axis title of chart.

Method is Lo Instance Safe for use with multiple documents.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • styles (Sequence[StyleT]) – One or more styles to apply chart Y axis title.

Return type:

None

Hint

Styles that can be applied are found in ooodev.format.chart2.direct.title subpackages.

New in version 0.9.4.

static unlock_controllers(chart_doc)[source]

Resumes the notifications which were suspended by lock_controllers().

The calls to lock_controllers() and unlock_controllers() may be nested and even overlapping, but they must be in pairs. While there is at least one lock remaining, some notifications for display updates are not broadcast.

Method is Lo Instance Safe for use with multiple documents.

Returns:

False if CONTROLLERS_UNLOCKING event is canceled; Otherwise, True

Return type:

bool

Events:
Parameters:

chart_doc (XChartDocument) –

New in version 0.9.4.

static view_legend(chart_doc, is_visible)[source]

Sets charts legend visibility.

Method NOT is Lo Instance Safe. Use Class LoContext when using with multiple document instances.

Parameters:
  • chart_doc (XChartDocument) – Chart Document.

  • is_visible (bool) – Visible State

Raises:

ChartError – If error occurs.

Return type:

None

class ooodev.office.chart2.Chart2ControllerLock(chart_doc)[source]

Context manager for Locking Chart2 Controller

In the following example ControllerLock is called using with.

All code inside the with Chart2ControllerLock.ControllerLock(chart_doc) block is updated with controller locked. This means the ui will not update chart until the block is done. A soon as the block is processed the controller is unlocked and the ui is updated.

Example

from ooodev.utils.color import CommonColor
from ooodev.office.chart2 import Chart2
from ooodev.office.chart2 import Chart2ControllerLock
from ooodev.format.chart2.direct.title.area import Color as ChartTitleBgColor
from ooodev.format.chart2.direct.title.font import Font as TitleFont
from ooodev.format.chart2.direct.title.borders import LineProperties as TitleBorderLineProperties, BorderLineKind
# ... other imports

with Chart2ControllerLock.ControllerLock(chart_doc):
    title_area_bg_color = ChartTitleBgColor(CommonColor.LIGHT_YELLOW)
    title_font = TitleFont(b=True, size=14, color=CommonColor.DARK_GREEN)
    title_border = TitleBorderLineProperties(style=BorderLineKind.DASH_DOT, width=1.0, color=CommonColor.DARK_RED)
    Chart2.style_title(chart_doc=chart_doc, styles=[title_area_bg_color, title_font, title_border])
    # ... other code

New in version 0.9.4.

Parameters:

chart_doc (XChartDocument) –