format_code property

ChartYValueCollection.format_code property

Gets or sets the format code applied to the Y values.

@property
def format_code(self) -> str:
    ...

@format_code.setter
def format_code(self, value: str):
    ...

Remarks

Number formatting is used to change the way values appears in the chart. The examples of number formats: Number - “#,##0.00”

Currency - “\"$\”#,##0.00"

Time - “[$-x-systime]h:mm:ss AM/PM”

Date - “d/mm/yyyy”

Percentage - “0.00%”

Fraction - “# ?/?”

Scientific - “0.00E+00”

Accounting - “-\"$\”* #,##0.00-;-\"$\"* #,##0.00_-;-\"$\"* \"-\"??-;-@-"

Custom with color - “[Red]-#,##0.0”

Examples

Shows how to work with the format code of the chart data.

doc = aw.Document()
builder = aw.DocumentBuilder(doc=doc)
# Insert a Bubble chart.
shape = builder.insert_chart(chart_type=aw.drawing.charts.ChartType.BUBBLE, width=432, height=252)
chart = shape.chart
# Delete default generated series.
chart.series.clear()
series = chart.series.add(series_name='Series1', x_values=[1, 1.9, 2.45, 3], y_values=[1, -0.9, 1.82, 0], bubble_sizes=[2, 1.1, 2.95, 2])
# Show data labels.
series.has_data_labels = True
series.data_labels.show_category_name = True
series.data_labels.show_value = True
series.data_labels.show_bubble_size = True
# Set data format codes.
series.x_values.format_code = '#,##0.0#'
series.y_values.format_code = '#,##0.0#;[Red]\\-#,##0.0#'
series.bubble_sizes.format_code = '#,##0.0#'
doc.save(file_name=ARTIFACTS_DIR + 'Charts.FormatCode.docx')

See Also