forked from davidgohel/ggiraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinteractive_parameters.Rd
135 lines (108 loc) · 7.14 KB
/
interactive_parameters.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ipar.R
\name{interactive_parameters}
\alias{interactive_parameters}
\title{Interactive parameters}
\arguments{
\item{tooltip}{Tooltip text to associate with one or more elements.
If this is supplied a tooltip is shown when the element is hovered.
Plain text or html is supported.
To use html markup it is advised to use \code{\link[htmltools:HTML]{htmltools::HTML()}} function
in order to mark the text as html markup.
If the text is not marked as html and no opening/closing tags were detected,
then any existing newline characters (\verb{\\r\\n}, \verb{\\r} and \verb{\\n})
are replaced with the \verb{<br/>} tag.}
\item{onclick}{Javascript code to associate with one or more elements.
This code will be executed when the element is clicked.}
\item{hover_css}{Individual css style associate with one or more elements.
This css style is applied when the element is hovered and overrides the default style,
set via \code{\link[=opts_hover]{opts_hover()}}, \code{\link[=opts_hover_key]{opts_hover_key()}} or \code{\link[=opts_hover_theme]{opts_hover_theme()}}.
It can also be constructed with \code{\link[=girafe_css]{girafe_css()}},
to give more control over the css for different element types (see \code{\link[=opts_hover]{opts_hover()}} note).}
\item{selected_css}{Individual css style associate with one or more elements.
This css style is applied when the element is selected and overrides the default style,
set via \code{\link[=opts_selection]{opts_selection()}}, \code{\link[=opts_selection_key]{opts_selection_key()}} or \code{\link[=opts_selection_theme]{opts_selection_theme()}}.
It can also be constructed with \code{\link[=girafe_css]{girafe_css()}},
to give more control over the css for different element types (see \code{\link[=opts_selection]{opts_selection()}} note).}
\item{data_id}{Identifier to associate with one or more elements.
This is mandatory parameter if hover and selection interactivity is desired.
Identifiers are available as reactive input values in Shiny applications.}
\item{tooltip_fill}{Color to use for tooltip background when \code{\link[=opts_tooltip]{opts_tooltip()}} \code{use_fill} is TRUE.
Useful for setting the tooltip background color in \code{\link[=geom_text_interactive]{geom_text_interactive()}} or
\code{\link[=geom_label_interactive]{geom_label_interactive()}}, when the geom text color may be the same as the tooltip text color.}
\item{hover_nearest}{Set to TRUE to apply the hover effect on the nearest element
while moving the mouse. In this case it is mandatory to also set the \code{data_id} parameter}
}
\description{
Throughout ggiraph there are functions that add interactivity to ggplot plot elements.
The user can control the various aspects of interactivity by supplying
a special set of parameters to these functions.
}
\section{Details for interactive geom functions}{
The interactive parameters can be supplied with two ways:
\itemize{
\item As aesthetics with the mapping argument (via \code{\link[=aes]{aes()}}).
In this way they can be mapped to data columns and apply to a set of geometries.
\item As plain arguments into the geom_*_interactive function.
In this way they can be set to a scalar value.
}
}
\section{Details for annotate_*_interactive functions}{
The interactive parameters can be supplied as arguments in the relevant function
and they can be scalar values or vectors depending on params on base function.
}
\section{Details for interactive scale and interactive guide functions}{
For scales, the interactive parameters can be supplied as arguments in the relevant function
and they can be scalar values or vectors, depending on the number of breaks (levels) and
the type of the guide used.
The guides do not accept any interactive parameter directly, they receive them from the scales.
When guide of type \code{legend}, \code{bins}, \code{colourbar} or \code{coloursteps} is used,
it will be converted to a \code{\link[=guide_legend_interactive]{guide_legend_interactive()}}, \code{\link[=guide_bins_interactive]{guide_bins_interactive()}},
\code{\link[=guide_colourbar_interactive]{guide_colourbar_interactive()}} or \code{\link[=guide_coloursteps_interactive]{guide_coloursteps_interactive()}} respectively,
if it's not already.
The length of each scale interactive parameter vector should match the length of the breaks.
It can also be a named vector, where each name should correspond to the same break name.
It can also be defined as function that takes the breaks as input and returns a named or
unnamed vector of values as output.
For binned guides like \code{bins} and \code{coloursteps} the breaks include the label breaks and the limits.
The number of bins will be one less than the number of breaks and the interactive parameters can be
constructed for each bin separately (look at the examples).
For \code{colourbar} guide in raster mode, the breaks vector, is scalar 1 always, meaning the interactive
parameters should be scalar too. For \code{colourbar} guide in non-raster mode, the bar is drawn using
rectangles, and the breaks are the midpoints of each rectangle.
The interactive parameters here, give interactivity only to the key elements of the guide.
To provide interactivity to the rest of the elements of a guide, (title, labels, background, etc),
the relevant theme elements or relevant guide arguments can be used.
The \code{guide} arguments \code{title.theme} and \code{label.theme} can be defined as
\code{element_text_interactive} (in fact, they will be converted to that if they are not
already), either directly or via the theme.
See the element_*_interactive section for more details.
}
\section{Details for element_*_interactive functions}{
The interactive parameters can be supplied as arguments in the relevant function
and they should be scalar values.
For theme text elements (\code{\link[=element_text_interactive]{element_text_interactive()}}), the interactive parameters
can also be supplied while setting a label value, via the \code{\link[=labs]{labs()}} family
of functions or when setting a scale/guide title or key label.
Instead of setting a character value for the element, function
\code{\link[=label_interactive]{label_interactive()}} can be used to define interactive parameters
to go along with the label.
When the parameters are supplied that way, they override the default values
that are set at the theme via \code{\link[=element_text_interactive]{element_text_interactive()}} or via the \code{guide}'s
theme parameters.
}
\section{Details for interactive_*_grob functions}{
The interactive parameters can be supplied as arguments in the relevant function
and they can be scalar values or vectors depending on params on base function.
}
\section{Custom interactive parameters}{
The argument \code{extra_interactive_params} can be passed to any of the *_interactive functions
(geoms, grobs, scales, labeller, labels and theme elements),
It should be a character vector of additional names to be treated as interactive parameters
when evaluating the aesthetics.
The values will eventually end up as attributes in the SVG elements of the output.
Intended only for expert use.
}
\seealso{
\code{\link[=girafe_options]{girafe_options()}}, \code{\link[=girafe]{girafe()}}
}