| EncharterBase | R Documentation |
Abstract base class inherited by Chart and ChartEx. Holds all
shared fields (palette, titles, axis params, legend/label settings) and the
shared private helpers (render_color_core, render_color,
set_axis_params, validate_input).
Users should not instantiate EncharterBase directly; use
encharter() instead.
xmlThe raw xml2 object containing the chart space.
series_dataA list containing all added data series and their styles.
typeThe default chart type for the object (e.g., "lineChart").
paletteA character vector of six-digit hex colors used for series when no explicit color is supplied. Defaults to the standard Office theme palette.
chart_titleNamed list with elements text (character) and
style (list of font/fill/line options) for the main chart title.
x_titleNamed list with elements text and style for
the primary X-axis title.
y_titleNamed list with elements text and style for
the primary Y-axis title.
chart_styleNamed list controlling the outer chart area:
fill (hex), line (hex), line_width (numeric).
plot_styleNamed list controlling the inner plot area:
fill (hex), line (hex), line_width (numeric).
label_paramsNamed list of global data label defaults:
show_val, show_cat, show_legend_key, leader_lines (logicals),
pos, sep, fill (character), style (list).
legend_paramsNamed list of legend defaults:
pos (character), overlay ("0"/"1"), style (list).
axis_paramsNamed list with one entry per axis (x, x2,
y, y2). Each entry is a named list of scaling, formatting,
and style parameters. Modified via $set_x_axis(), etc.
EncharterBase$set_chart_title()Set the chart's main title.
EncharterBase$set_chart_title( text, font_size = NULL, font_name = NULL, font_color = NULL, bold = NULL, italic = NULL, fill = NULL, line = NULL, line_width = NULL )
textTitle string. Accepts a plain character or an
openxlsx2::fmt_txt() object for rich-text formatting.
font_sizeNumeric font size in points (e.g. 14).
font_nameFont typeface name (e.g. "Arial").
font_colorSix-digit hex color for the title text (e.g.
"FF0000" for red).
boldLogical; TRUE renders the title in bold.
italicLogical; TRUE renders the title in italics.
fillSix-digit hex color for the title background box.
lineSix-digit hex color for the title border.
line_widthNumeric border width in points.
ec("line")$set_chart_title("Monthly Sales", font_size = 14, bold = TRUE)
EncharterBase$set_x_title()Set the primary X-axis title.
EncharterBase$set_x_title( text, font_size = NULL, font_name = NULL, font_color = NULL, bold = NULL, italic = NULL, fill = NULL, line = NULL, line_width = NULL )
textTitle string.
font_sizeNumeric font size in points.
font_nameFont typeface name.
font_colorSix-digit hex color for the title text.
boldLogical.
italicLogical.
fillSix-digit hex color for the title background box.
lineSix-digit hex color for the title border.
line_widthNumeric border width in points.
ec("line")$set_x_title("Month", font_color = "888888", italic = TRUE)
EncharterBase$set_y_title()Set the primary Y-axis title.
EncharterBase$set_y_title( text, font_size = NULL, font_name = NULL, font_color = NULL, bold = NULL, italic = NULL, fill = NULL, line = NULL, line_width = NULL )
textTitle string.
font_sizeNumeric font size in points.
font_nameFont typeface name.
font_colorSix-digit hex color for the title text.
boldLogical.
italicLogical.
fillSix-digit hex color for the title background box.
lineSix-digit hex color for the title border.
line_widthNumeric border width in points.
ec("line")$set_y_title("Revenue (USD)", bold = TRUE)
EncharterBase$set_x_axis()Set primary X-axis scaling, tick marks, and label formatting.
EncharterBase$set_x_axis( min = NULL, max = NULL, major = NULL, minor = NULL, major_time = NULL, minor_time = NULL, base_time = NULL, major_tick = NULL, minor_tick = NULL, format = NULL, log_base = NULL, rev = NULL, color = NULL, font_name = NULL, font_size = NULL, bold = NULL, italic = NULL, font_color = NULL, rotation = NULL, grid_color = NULL, grid_lines = NULL, minor_grid_color = NULL, minor_grid_lines = NULL, cross_between = NULL, line_width = NULL, grid_width = NULL, minor_grid_width = NULL, crosses = NULL, crosses_at = NULL, label_pos = NULL, tick_lbl_skip = NULL, tick_mark_skip = NULL, disp_units = NULL )
min, maxNumeric axis limits.
major, minorNumeric major/minor unit intervals. For date axes, unit
is set by major_time/minor_time.
major_time, minor_timeTime unit for major/minor steps on date axes:
"days", "months", or "years".
base_timeBase time unit for date axes: "days",
"months", or "years".
major_tick, minor_tickTick mark style: "cross",
"in", "out", or "none".
formatNumber or date format string (e.g. "#,##0",
"yyyy-mm-dd").
log_baseNumeric base for logarithmic scaling (e.g. 10).
revLogical to reverse the value order
colorSix-digit hex color for the axis line.
font_nameFont typeface name for tick labels.
font_sizeNumeric label font size in points.
bold, italicLogical font style for tick labels.
font_colorSix-digit hex color for axis tick labels. Defaults to
color when not set.
rotationNumeric label rotation in degrees.
grid_color, minor_grid_colorSix-digit hex colors for major/minor grid_lines.
grid_lines, minor_grid_linesShow grid lines. TRUE/FALSE
to toggle; or a dash style string ("dash", "dot",
"dashDot", etc.) to show styled lines.
cross_betweenWhere the value axis crosses: "between"
(default, between categories) or "midCat" (through categories).
line_width, grid_width, minor_grid_widthNumeric widths in points for the axis line, major grid lines, and minor grid lines respectively.
crossesWhere this axis crosses its perpendicular axis:
"autoZero" (default), "min", or "max".
crosses_atNumeric axis value at which to cross. Overrides
crosses when supplied.
label_posTick label position: "nextTo" (default),
"high", "low", or "none".
tick_lbl_skipInteger (>= 1); draw a tick label only every n-th category (category axes only).
tick_mark_skipInteger (>= 1); draw a tick mark only every n-th category (category axes only).
disp_unitsDisplay units for value axes: a built-in unit string
("hundreds", "thousands", "tenThousands",
"hundredThousands", "millions", "tenMillions",
"hundredMillions", "billions", "trillions") or a
positive number for a custom unit.
ec("line")$set_x_axis(
min = 0, max = 12,
major_tick = "out",
grid_lines = TRUE,
font_color = "666666",
rotation = -45
)
EncharterBase$set_y_axis()Set primary Y-axis scaling, tick marks, and label formatting.
EncharterBase$set_y_axis( min = NULL, max = NULL, major = NULL, minor = NULL, major_time = NULL, minor_time = NULL, base_time = NULL, major_tick = NULL, minor_tick = NULL, format = NULL, log_base = NULL, rev = NULL, color = NULL, font_name = NULL, font_size = NULL, bold = NULL, italic = NULL, font_color = NULL, rotation = NULL, grid_color = NULL, grid_lines = NULL, minor_grid_color = NULL, minor_grid_lines = NULL, cross_between = NULL, line_width = NULL, grid_width = NULL, minor_grid_width = NULL, crosses = NULL, crosses_at = NULL, label_pos = NULL, tick_lbl_skip = NULL, tick_mark_skip = NULL, disp_units = NULL )
min, maxNumeric axis limits.
major, minorNumeric major/minor unit intervals.
major_time, minor_timeTime unit for date axes: "days",
"months", or "years".
base_timeBase time unit for date axes.
major_tick, minor_tickTick mark style: "cross",
"in", "out", or "none".
formatNumber format string.
log_baseNumeric base for logarithmic scaling.
revLogical to reverse the value order
colorSix-digit hex color for the axis line.
font_nameFont typeface name.
font_sizeNumeric label font size in points.
bold, italicLogical font style.
font_colorSix-digit hex color for axis tick labels.
rotationNumeric label rotation in degrees.
grid_color, minor_grid_colorHex colors for major/minor grid lines.
grid_lines, minor_grid_linesTRUE/FALSE or a dash style
string.
cross_between"between" or "midCat".
line_width, grid_width, minor_grid_widthNumeric widths in points.
crosses"autoZero", "min", or "max".
crosses_atNumeric crossing value; overrides crosses.
label_pos"nextTo", "high", "low", or
"none".
tick_lbl_skip, tick_mark_skipInteger (>= 1); label/tick every n-th category (category axes only).
disp_unitsDisplay units: a built-in unit string (e.g.
"thousands", "millions") or a positive number for a custom
unit. Value axes only.
ec("bar")$set_y_axis(
min = 0,
max = 1000,
major = 200,
format = "#,##0",
grid_lines = TRUE,
grid_color = "DDDDDD"
)
EncharterBase$set_data_label_style()Configure global data label defaults for all series.
Per-series overrides can be set via the show_val/show_cat
arguments in $add_series().
EncharterBase$set_data_label_style( show_val = TRUE, show_cat = FALSE, show_legend_key = FALSE, pos = "t", show_ser_name = FALSE, show_percent = FALSE, show_bubble_size = FALSE, format = NULL, ... )
show_valLogical; show the data point value. Default TRUE.
show_catLogical; show the category name. Default FALSE.
show_legend_keyLogical; show the series color swatch next to each
label. Default FALSE.
posLabel position: "t" (top, default), "b"
(bottom), "l", "r", "ctr", "inEnd",
"outEnd", "bestFit".
show_ser_nameLogical; show the series name. Default FALSE.
show_percentLogical; show the percentage (pie-type charts).
Default FALSE.
show_bubble_sizeLogical; show the bubble size (bubble charts).
Default FALSE.
formatNumber format string for the labels (e.g. "#,##0",
"0.0%").
...Additional font style arguments passed to the label text
properties (e.g. font_size, font_color, bold).
ec("bar")$set_data_label_style(show_val = TRUE, pos = "outEnd", font_size = 9)
EncharterBase$set_legend_style()Configure the chart legend.
EncharterBase$set_legend_style( pos = "t", align = "ctr", overlay = FALSE, font_size = NULL, font_name = NULL, bold = NULL, italic = NULL, color = NULL )
posLegend position: "t", "b", "l",
"r" (default), or "none" to hide.
alignLegend alignment relative to the chart: "ctr"
(default), "min", or "max".
overlayLogical; if TRUE the legend overlaps the plot area.
font_sizeNumeric font size in points.
font_nameFont typeface name.
bold, italicLogical font style.
colorSix-digit hex color for the legend text.
ec("line")$set_legend_style(pos = "b", font_size = 9)
EncharterBase$set_chart_style()Style the outer chart area (background and border).
EncharterBase$set_chart_style(fill = "FFFFFF", line = NULL, line_width = 1)
fillSix-digit hex color for the chart background.
Default "FFFFFF".
lineSix-digit hex color for the chart border. NULL for no
border.
line_widthNumeric border width in points. Default 1.
ec("bar")$set_chart_style(fill = "F5F5F5", line = "CCCCCC", line_width = 0.5)
EncharterBase$set_plot_style()Style the inner plot area (background and border).
EncharterBase$set_plot_style(fill = NULL, line = NULL, line_width = 1)
fillSix-digit hex color for the plot area background.
NULL for transparent.
lineSix-digit hex color for the plot area border.
line_widthNumeric border width in points. Default 1.
ec("line")$set_plot_style(fill = "FAFAFA")
EncharterBase$print()Print a summary of the chart object.
EncharterBase$print()
ec("line")
EncharterBase$clone()The objects of this class are cloneable with this method.
EncharterBase$clone(deep = FALSE)
deepWhether to make a deep clone.
## ------------------------------------------------
## Method `EncharterBase$set_chart_title()`
## ------------------------------------------------
ec("line")$set_chart_title("Monthly Sales", font_size = 14, bold = TRUE)
## ------------------------------------------------
## Method `EncharterBase$set_x_title()`
## ------------------------------------------------
ec("line")$set_x_title("Month", font_color = "888888", italic = TRUE)
## ------------------------------------------------
## Method `EncharterBase$set_y_title()`
## ------------------------------------------------
ec("line")$set_y_title("Revenue (USD)", bold = TRUE)
## ------------------------------------------------
## Method `EncharterBase$set_x_axis()`
## ------------------------------------------------
ec("line")$set_x_axis(
min = 0, max = 12,
major_tick = "out",
grid_lines = TRUE,
font_color = "666666",
rotation = -45
)
## ------------------------------------------------
## Method `EncharterBase$set_y_axis()`
## ------------------------------------------------
ec("bar")$set_y_axis(
min = 0,
max = 1000,
major = 200,
format = "#,##0",
grid_lines = TRUE,
grid_color = "DDDDDD"
)
## ------------------------------------------------
## Method `EncharterBase$set_data_label_style()`
## ------------------------------------------------
ec("bar")$set_data_label_style(show_val = TRUE, pos = "outEnd", font_size = 9)
## ------------------------------------------------
## Method `EncharterBase$set_legend_style()`
## ------------------------------------------------
ec("line")$set_legend_style(pos = "b", font_size = 9)
## ------------------------------------------------
## Method `EncharterBase$set_chart_style()`
## ------------------------------------------------
ec("bar")$set_chart_style(fill = "F5F5F5", line = "CCCCCC", line_width = 0.5)
## ------------------------------------------------
## Method `EncharterBase$set_plot_style()`
## ------------------------------------------------
ec("line")$set_plot_style(fill = "FAFAFA")
## ------------------------------------------------
## Method `EncharterBase$print()`
## ------------------------------------------------
ec("line")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.