Skip to content

Style an Individual Element ​

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 ​

r
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 ​

ArgumentDescription
GC_chartA GC chart object.
componentThe component to edit: "genes", "labels", "coordinates", "clusterTitle", "clusterFooter", "clusterLabel", "legend", "title", "scaleBar" or "scale".
row_idFor genes, labels and coordinates: the gene's rowID, its row number in the chart's data once rows without a start or end are left out, also returned in input$<outputId>_select$data$rowID and double-click event data.
...Named element options, using JavaScript names, e.g. fill, stroke, strokeWidth, marker, markerSize, fontSize, dx, dy or rotate. Labels, titles and subtitles also accept text to override their displayed text. Gene labels, chart titles, cluster text, whole scale bars and axes, and legend labels and markers (each on its own) accept moveX and moveY, pixel offsets from their configured position. Coordinates accept show = FALSE to leave them out and tick, a list of options for their tick.
clusterFor cluster titles, footers, labels, scale bars and axes: the name or number of the cluster.
partFor chart and cluster titles, footers and labels: "title" or "subtitle"; for the legend: "label" or "marker".
endFor coordinates: "start" or "end" for the coordinate of the start or end of the gene, or NULL (default) for both.
resetLogical, remove this element's override instead of updating it.
groupFor the legend: its original group value, also returned as data in 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.

Value ​

The chart with the element override updated.

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 ​

r
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")