diff --git a/DESCRIPTION b/DESCRIPTION index 1180dbb6..e64de454 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -26,7 +26,7 @@ Imports: stats Suggests: network LinkingTo: Rcpp -RoxygenNote: 6.0.0.9000 +RoxygenNote: 6.0.1 Depends: R (>= 2.10), ggplot2 (>= 2.0.0) @@ -63,6 +63,7 @@ Collate: 'layout_dendrogram.R' 'layout_igraph.R' 'layout_sec.R' + 'plotly.R' 'scale_edge_alpha.R' 'scale_edge_colour.R' 'scale_edge_fill.R' diff --git a/NAMESPACE b/NAMESPACE index 08ed8a10..71a5afa3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -152,6 +152,12 @@ export(scale_edge_width_continuous) export(scale_edge_width_discrete) export(scale_edge_width_identity) export(scale_edge_width_manual) +export(to_basic.GeomEdgeBezier) +export(to_basic.GeomEdgeBspline) +export(to_basic.GeomEdgeDensity) +export(to_basic.GeomEdgePath) +export(to_basic.GeomEdgeSegment) +export(to_basic.GeomTreemap) export(treeApply) import(ggplot2) importFrom(MASS,bandwidth.nrd) diff --git a/R/plotly.R b/R/plotly.R new file mode 100644 index 00000000..d5a05ee5 --- /dev/null +++ b/R/plotly.R @@ -0,0 +1,58 @@ +# --------------------------------------------------------------------------- +# Translations for R/geom_axis_hive.R +# --------------------------------------------------------------------------- + +# TODO: waiting for an example + +# --------------------------------------------------------------------------- +# Translations for R/geom_edge.R +# --------------------------------------------------------------------------- + +toPath <- function(data, prestats_data, layout, params, p, ...) { + prefix_class(data, "GeomPath") +} + +#' @export +to_basic.GeomEdgePath <- toPath + +#' @export +to_basic.GeomEdgeSegment <- toPath + +#' @export +to_basic.GeomEdgeBezier <- toPath + +#' @export +to_basic.GeomEdgeBspline <- toPath + +# --------------------------------------------------------------------------- +# Translations for R/geom_edge_density.R +# --------------------------------------------------------------------------- + +#' @export +to_basic.GeomEdgeDensity <- function(data, prestats_data, layout, params, p, ...) { + # avoid a weird precision issue + data$density[data$density < 0.005] <- 0 + data$fill_plotlyDomain <- data$density + data$fill <- toRGB( + data$edge_fill, scales::rescale(data$density) + ) + prefix_class(data, "GeomTile") +} + +# --------------------------------------------------------------------------- +# Translations for R/geom_treemap.R +# --------------------------------------------------------------------------- + +#' @export +to_basic.GeomTreemap <- getFromNamespace("to_basic.GeomRect", asNamespace("plotly")) + + +# --------------------------------------------------------------------------- +# Helper functions +# --------------------------------------------------------------------------- + +prefix_class <- function(x, y) { + structure(x, class = unique(c(y, class(x)))) +} + +