plot(chart, wb) reads the series from the ranges in wb and skips cells
in hidden rows and columns, as a spreadsheet application does unless "Show
data in hidden rows and columns" is switched on. The workbook takes
precedence over the wb_data() caches, so one chart can be drawn for
different workbooks; plot(chart) still uses the caches. The new
plot_vis_only field and set_plot_vis_only() control this; the setting is
written as c:plotVisOnly and read back by ec_load(). Extended charts are
not affected.
Series from a wb_data() object whose header spans several rows (see the
header_rows argument of wb_data() in the development version of
openxlsx2) use the cells of all header rows as series name, so the legend
shows them as one multi-level name. plot() joins the non-empty cells of
such a name range with a space. Merged header cells give every cell of the
merged range the value of the merged cell.
Several columns can be given as label of a series from a wb_data()
object, e.g. label = c(Region, Sex), if they are adjacent and in the order
of the sheet. The first column is the outer level of the multi-level
categories, and the levels are written to the category cache.
plot() draws the depth of 3D charts with right-angle axes (columns, lines,
areas) at the same angle for every chart size. Before, the vertical share of
the depth was too small in wide charts, so the rows of a 3D chart sat too
close together.
plot() draws the slabs of a 3D area chart as deep as a column (reduced by
the gap depth) and centered in their row, and lists the series of a stacked
3D area chart in reverse order in the legend.
The wall of a 3D pie is drawn with a brightness gradient from left to right instead of one flat shade.
Bubble charts no longer write the default point colors on every series. A
chart with several series, or a series with its own color, now keeps the
series colors; only a single series with the default color varies the color
by point. plot() draws bubbles the same way.
plot() shades 3D cylinder columns with a gradient across the mantle, and
draws 3D line ribbons filled with the theme color and outlined in the
series color.
plot() lights the faces of 3D surface charts, so slopes facing the light are
brighter and the others darker.
plot() takes dir, grouping, overlap and gap_width of a chart group
from its first series, as the writer does. Before, bars were drawn on top of
each other when grouping = "stacked" was set on the first series only.
plot() removes locale tags such as [$-en-US] from date formats instead of
printing them in the axis labels, and handles dddd and ddd.
plot() on Windows no longer warns about font families missing from the
font database; such fonts fall back to the device default.
Radar series are written with their color (line color, or the fill of a filled radar); before, Excel used its automatic colors for them.
Loaded series without a color of their own take the theme accents in
turn, as the application colors them, instead of all becoming blue;
plot() does the same for series without a color.
c:logBase is written first within c:scaling, as the schema requires.
A logarithmic axis produced a chart that Excel removed on opening.
Scatter and bubble series with text x values write them as a string
reference (c:strRef) instead of a number cache holding text, which
made Excel repair the file.
3D bar and area charts only get a series axis (c:serAx) with the
"standard" grouping. With a series axis present, a "clustered" 3D
column chart was rendered with its series in rows along the depth rather
than side by side.
Bar series are written with <c:invertIfNegative val="0"/> unless
invert_if_negative = TRUE. Without the element, negative bars appeared
inverted (white with an outline) in Excel.
encharter_load() / ec_load() read a chart from a workbook back into a
Chart or ChartEx object, so charts can be reloaded, modified and added
again. Charts written by other applications load as well. New $update_series()
on both classes to change an existing series. Loading has seen limited testing;
unusual charts may not survive a round trip unchanged.
Chart templates: encharter_to_crtx() / ec_to_crtx() save a Chart as a
chart template (.crtx), encharter_from_crtx() / ec_from_crtx()
read one into a Chart whose $add_series() picks up the template's series
styling, and $apply_crtx() copies a template's styling onto an existing
chart.
Loading keeps more of what a file says: deleted axes, per-series data
label settings, labels and formatting of single points (c:dLbl,
c:dPt, including manual label offsets), and a fixed plot area position
(c:manualLayout). render() writes all of these back.
Text properties round-trip more faithfully: a chart-level default text
style (c:chartSpace/c:txPr, new field $text_style) is loaded, written and
used by plot() for text without its own; the paragraph alignment of data
labels (align), leader line settings (leader_lines), explicit "no fill"
and "no line" of the chart and plot area ("none"), and literal categories
next to referenced values are kept, as are text box insets and anchoring
and the category axis label offset (label_offset). Text without an
explicit size no longer gets sz="1000" written, so it inherits the chart
default. Axis bounds, units and cached values are written without
scientific notation. Outlines of bars, areas and single points (border)
and the line width of category axes are kept, and horizontal bar charts
get their axes positioned left and bottom. Templates hand bar direction,
grouping, overlap, gap width, outlines and label settings of their series
to series added later, and $apply_crtx() copies the chart text defaults.
plot() methods for Chart and ChartEx objects draw the chart with grid,
following what a spreadsheet application renders from the written OOXML:
automatic axis scaling, primary and secondary axes, tick marks, gridlines,
legend, data labels, trendlines, error bars, stock charts (high-low lines,
drop lines, up-down bars), pie of pie and bar of pie, the 3D column, bar,
line, area and pie types and surface charts (contour and 3D, including
wireframes), and the extended types waterfall, box-and-whisker, histogram,
Pareto, funnel, treemap and sunburst. Region maps are not drawn; they need
shape data the package does not ship. Value axes of data well away from
zero start below the values, as in Excel, and date axes label the base
units rather than their boundaries. Also drawn: data tables, overlaid
legends, legend keys and bubble sizes in data labels, trendline intercepts,
value axes crossing at the categories (cross_between = "midCat"),
doughnut rings for every series and pie labels outside the slices.
Complete coverage of the ECMA-376 plot area chart types. Newly supported:
ofPieChart (Pie of Pie / Bar of Pie, incl. barOfPie alias and
$set_of_pie_options() for subtype, second plot size, and split logic) and
the 3D types bar3DChart, line3DChart, pie3DChart, area3DChart, and
surface3DChart with a new $set_3d_options() for the 3D view (rotation,
perspective, height/depth percent, right-angle axes, gap depth, bar shape).
New niche axis options: tick_lbl_skip, tick_mark_skip (category axes)
and disp_units (value axes, built-in units like "thousands" or a custom
numeric unit) on all set_*_axis() methods.
$set_data_label_style() gains show_ser_name, show_percent,
show_bubble_size, and a format number format string (the latter now
also works for ChartEx labels).
Input validation against the OOXML schema (ECMA-376 dml-chart.xsd). Values
that would produce files Excel repairs or refuses to load now error at input
time (e.g. overlap outside -100..100, gap_width > 500, marker_size
outside 2..72, log_base outside 2..1000, polynomial trendline order
outside 2..6). Structural problems Excel bails on despite valid XML are
warned about at render time (stock charts without 3-4 series, pie types
combined with axis-based types, log scale with non-positive minimum).
Harmless out-of-schema values that Excel renders fine (e.g. hole_size = 0)
remain accepted.
Colors are validated at input time; R color names (e.g. "red",
"steelblue") are now converted to hex instead of silently rendering black.
ChartEx$set_waterfall_colors(increase, decrease, total) sets the semantic
waterfall colors by replacing the first three entries of the chart's color
style part (colors{n}.xml), which is what waterfall maps Increase,
Decrease, and Total onto. Both the bars and the legend keys reflect the
colors. Accepts hex, R color names, and openxlsx2::wb_color() including
theme colors. Use a per-point color vector in add_series() for
individual outliers instead.
ChartEx$set_color_cycle(colors) replaces (and if needed extends) the
color style part's cycle for all extended chart types: treemap/sunburst
category colors, box & whisker and histogram series, funnel and Pareto
colors — bars and legend alike. ChartEx$set_region_map_colors(min, max, mid) sets a region map's two- or three-color scale via the series'
cx:valueColors.
Chart options newly covered: trendline forward/backward/intercept,
error_bars$axis ("x" error bars on scatter charts),
invert_if_negative for bar series, and size_represents ("area"/"w")
in set_bubble_options().
error_bars$direction was documented but ignored (always "both"); it is
now written to errBarType.
ChartEx per-point colors were written as cx:dPt and ignored by Excel;
the correct element is cx:dataPt, so passing a color vector (e.g. a
corporate palette) to add_series() now colors extended charts the same
way it colors standard charts.
Legend settings that are valid for standard charts no longer produce broken
ChartEx XML: pos = "tr" maps to "t" and side-style align values map
onto the chartex min/ctr/max enum.
ChartEx axes emitted cx:spPr before the gridline/tick/label elements;
CT_Axis places it after tickLabels and numFmt. Excel tolerated the
old order, but SDK-based validation (e.g. OOXMLValidator) flags it. Output
changes for chartex axes: identical elements, schema order. A structural
chartex validator driven by the Open XML SDK schema data ships in
inst/tools/cx_structure_check.py.
Color name resolution is delegated to openxlsx2::wb_color() instead of a
separate implementation.
rev to reverse axis #11