Adds or updates an override for one element of a chart, without replacing the styles of other elements: a gene, a gene label, a gene coordinate, or the title or subtitle of a cluster title, footer or label. Use this in an editor and in the R code generated by it. Legend labels and markers can also be edited individually by group and part.
Usage
GC_element_style(
GC_chart,
component = c("genes", "labels", "coordinates", "clusterTitle", "clusterFooter",
"clusterLabel", "legend", "title", "scaleBar", "scale"),
row_id = NULL,
...,
cluster = NULL,
part = NULL,
end = NULL,
reset = FALSE,
group = NULL
)Arguments
- GC_chart
A GC chart object.
- component
The component to edit:
"genes","labels","coordinates","clusterTitle","clusterFooter","clusterLabel","legend","title","scaleBar"or"scale".- row_id
For genes, labels and coordinates: the gene's
rowIDinGC_chart$x$data, also returned ininput$<outputId>_select$data$rowIDand double-click event data.- ...
Named element options, using JavaScript names, e.g.
fill,stroke,strokeWidth,marker,markerSize,fontSize,dx,dyorrotate. Labels, titles and subtitles also accepttextto override their displayed text. Gene labels, chart titles, cluster text, whole scale bars and axes, and legend labels and markers (each on its own) acceptmoveXandmoveY, pixel offsets from their configured position. Coordinates acceptshow = FALSEto leave them out andtick, a list of options for their tick.- cluster
For cluster titles, footers, labels, scale bars and axes: the name or number of the cluster.
- part
For chart and cluster titles, footers and labels:
"title"or"subtitle"; for the legend:"label"or"marker".- end
For coordinates:
"start"or"end"for the coordinate of the start or end of the gene, orNULL(default) for both.- reset
Logical, remove this element's override instead of updating it.
- group
For the legend: its original group value, also returned as
datain click, selection and double-click events. Editing label text does not change this value or the input data. Marker edits affect only the legend patch.
Details
Overrides of genes, labels and coordinates match the row ID rather
than the element's drawing index, so sorting, reverse clusters, resize and
repeated gene names do not change their target. Row IDs are assigned by
GC_chart() after filtering missing coordinates. Reproducing an edit
requires the same input rows in the same order; replacing or reordering
the input data requires remapping edits. These overrides take precedence
over group styles and index-based styles. Reset removes the override,
restoring underlying styles. Call this after the component's normal
configuration (e.g. GC_clusterTitle()), which replaces its overrides.
Legend overrides also take precedence over GC_legend(groupStyle = ...);
resetting one part restores its group and global styles.
Examples
genes <- data.frame(start = c(90, 10), end = c(130, 50), name = c("a", "a"))
GC_chart(genes) %>%
GC_labels("name") %>%
GC_clusterTitle("Cluster", subtitle = "Subtitle") %>%
GC_element_style("genes", row_id = 1, fill = "red", marker = "box") %>%
GC_element_style("labels", row_id = 1, text = "Edited", fontSize = "16px") %>%
GC_element_style("clusterTitle", cluster = 1, part = "subtitle",
fontStyle = "italic", fill = "grey")
GC_chart(data.frame(start = 10, end = 40, family = "A"), group = "family") %>%
GC_element_style("legend", group = "A", part = "label", text = "Family A") %>%
GC_element_style("legend", group = "A", part = "marker", fill = "red")
