gvisSankey
gvisSankey(data, from = "", to = "", weight = "", options = list(), chartid)data for the source nodes to be useddata for the destination nodes to be usedhttps://developers.google.com/chart/interactive/docs/gallery/sankey#Configuration_Options
The parameters can be set via a named list. The parameters have to map those of the Google documentation.
TRUE or FALSE, using the R syntax.
options=list(width=200, height=300).
Exceptions to this rule are the width and height options for
gvisAnnotatedTimeLine and gvisAnnotationChart.
For those two functions, width and height must be character strings of the
format "Xpx", where X is a number, or "automatic".
For example,
options=list(width="200px", height="300px").
options=list(colors="['#cbb69d', '#603913', '#c69c6e']")
'true' or 'false'.
For example the Google documentaion states the formating options for the
vertical axis and states the parameter as vAxis.format.
Then this paramter can be set in R as:options=list(vAxis="{format:'#,###%'}").
titleTextStyle.color, titleTextStyle.fontName and
titleTextStyle.fontSize, then those can be combined in one list item
such as:
options=list(titleTextStyle="{color:'red', fontName:'Courier', fontSize:16}")
options=list(vAxes="[{title:'val1'}, {title:'val2'}]")
gvis.editor a character label for an
on-page button that opens an in-page dialog box enabling
users to edit, change and customise the chart. By default no
value is given and therefore no button is displayed.
For more details see the Google API documentation and the R examples below.
tempfileclass
"gvis" and "list".
An object of class "gvis" is a list containing at least the
following components:
typechartidhtmlheader...,chartjsHeader tag and
reference to Google's JavaScript library.
jsDatadata as a JSON object.
jsDrawChartjsDisplayChartjsFooter.
jsChartjsDisplayChart function.
divChart container to embed the chart
into the page.
captionfooter..., including the used R and googleVis version
and link to Google's Terms of Use.
dat <- data.frame(From=c(rep("A",3), rep("B", 3)),
To=c(rep(c("X", "Y", "Z"),2)),
Weight=c(5,7,6,2,9,4))
sk1 <- gvisSankey(dat, from="From", to="To", weight="Weight")
plot(sk1)
sk2 <- gvisSankey(dat, from="From", to="To", weight="Weight",
options=list(sankey="{link: {color: { fill: '#d799ae' } },
node: { color: { fill: '#a61d4c' },
label: { color: '#871b47' } }}"))
plot(sk2)
Run the code above in your browser using DataLab