updateCharts {rlc} | R Documentation |
Update a chart
Description
updateCharts
redraws a chart or a single layer of a chart to make it up
to date with the current state of the environment variables.
Usage
updateCharts(chartId = NULL, layerId = NULL, updateOnly = NULL)
Arguments
chartId |
ID of the chart to be updated (or vector of IDs). If |
layerId |
ID of the layer to be updated (or vector of IDs). If |
updateOnly |
To improve performance it may be useful to change only certain
aspects of a chart (e.g. positions of points, colour of heatmap cells,
etc.). This argument can specify which part of chart to update. Possible options are
|
Details
Linked charts of the rlc package are based on the idea that the variables that are
used to define a chart are not constant, but can change as a result of user's
actions. Each time the updateCharts
function is called, all the properties that were set inside
the dat
function are re-evaluated and the chart is redrawn in accordance with the
new state.
If this function is called from the R session, changes will be applied
to all currently opened pages. If it is used as a part of any rlc
callback, only the page
that triggered the call will be affected.
This function is a wrapper around method updateCharts
of class LCApp
.
Update types
To improve performance you can update only a certain part of a chart (e.g. colours,
size, etc.). This can be done by setting the updateOnly
argument. Here are all
possible values for this argument.
These are valid for all the charts:
-
Size
changes the size of the chart (and consequently position of all its elements). -
Title
changes the title of the chart. -
Canvas
If number of elements is too high the charts switch to the canvas mode and instead of multiple SVG point or cells a single Canvas image is generated. This type of update redraws the Canvas image. It is not recommended to use this option, since it will be used automatically when necessary.
These can be updated only in heatmaps (lc_heatmap
):
-
Labels
adds new row and column labels and removes those that are no longer needed. Also updatesCells
. -
Cells
adds new cells and removes those that are no longer needed. Also updatesTexts
if necessary. -
Texts
adds or remove text inside cells where needed. -
LabelPosition
updates coordinates of all existing row and column labels. Also updatesCellPosition
. -
CellPosition
updates coordinates of all existing cells. Also updatesTextPosition
if necessary. -
LabelText
updates text of all existing labels. -
CellColour
updates colour of all existing cells. Also updatesTextValues
if necessary. -
TextValues
updates text inside cells to make it up to date with current data values.
These aspects are present in all the charts with axes.
-
Axes
updates axes of a chart and changes position of its elements (points, lines, etc.) accordingly. -
Elements
updates (add or removes) all the elements of the layer. -
ElementPosition
updates positions of all the elements in the layer. -
ElementStyle
updates the style (colour, opacity, etc.) of all the elements of the layer.
Examples
## Not run: data(iris)
#store some properties in global variables
width <- 300
height <- 300
colour <- iris$Sepal.Width
#create a chart
lc_scatter(dat(x = iris$Sepal.Length, y = iris$Petal.Length, colourValue = colour,
width = width, height = height), chartId = "iris")
#change the variables
height <- 400
colour <- iris$Petal.Width
#this will change colour of points and chart height
updateCharts("iris")
#this will change only height
updateCharts("iris", updateOnly = "Size")
#add another property
setProperties(dat(symbolValue = iris$Species), "iris")
#this will change only colour and symbols
updateCharts("iris", updateOnly = "ElementStyle")
## End(Not run)