CONTENTS
- DESCRIPTION
- SYNOPSIS
- EXAMPLES
- WORKBOOK METHOD
- WORKSHEET METHOD
- PAGE SET-UP METHOD
- CELL FORMATTING
- FORMAT METHODS
- COLORS IN EXCEL
- DATES AND TIME IN EXCEL
- OUTLINES AND GROUPING IN EXCEL
- DATA VALIDATION IN EXCEL
- CONDITIONAL FORMATTING IN EXCEL
- SPARKLINES IN EXCEL
- TABLES IN EXCEL
- FORMURAS AND FUNCTIONS IN EXCEL
- CHART METHODS
- CHART FONTS
- CHART LAYOUT
- SHAPE
- COMPATIBILITY WITH WRITEEXCEL
CHART FONTS
The following font properties can be set for any chart object that they apply to (and that are supported by WriteXLSX) such as chart titles, axis labels, axis numbering and data labels. They correspond to the equivalent Worksheet cell Format object properties. See FORMAT METHODS for more information.
:name
:size
:bold
:italic
:underline
:rotation
:color
The following explains the available font properties:
:name
Set the font name:
chart.set_x_axis( num_font: { name: 'Arial' } )
:size
Set the font size:
chart.set_x_axis( num_font: { name: 'Arial', size: 10 } )
:bold
Set the font bold property, should be 0 or 1:
chart.set_x_axis( num_font: { bold: 1 } )
:italic
Set the font italic property, should be 0 or 1:
chart.set_x_axis( num_font: { italic: 1 } )
:underline
Set the font underline property, should be 0 or 1:
chart.set_x_axis( num_font: { underline: 1 } )
:rotation
Set the font rotation in the integer range -90 to 90, and 270-271:
chart.set_x_axis( num_font: { rotation: 45 } )
This is useful for displaying large axis data such as dates in a more compact format.
There are 2 special case angles outside the range -90 to 90:
- 270: Stacked text, where the text runs from top to bottom.
- 271: A special variant of stacked text for East Asian fonts.
:color
Set the font color property. Can be a color index, a color name or HTML style RGB colour:
chart.set_x_axis( num_font: { color: 'red' } )
chart.set_y_axis( num_font: { color: '#92D050' } )
Here is an example of Font formatting in a Chart program:
# Format the chart title.
chart.set_title(
name: 'Sales Results Chart',
name_font: {
name: 'Calibri',
color: 'yellow',
}
)
# Format the X-axis.
chart.set_x_axis(
name: 'Month',
name_font: {
name: 'Arial',
color: '#92D050'
},
num_font: {
name: 'Courier New',
color: '#00B0F0',
}
)
# Format the Y-axis.
chart.set_y_axis(
name: 'Sales (1000 units)',
name_font: {
name: 'Century',
underline: 1,
color: 'red'
},
num_font: {
bold: 1,
italic: 1,
color: '#7030A0',
}
)