---
title: "Interactive Pedigree Plotting with ggPedigreeInteractive"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Interactive Pedigree Plotting with ggPedigreeInteractive}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 7,
  fig.height = 5
)
```

# Introduction

The `ggPedigreeInteractive()` function extends the static pedigree plots generated by `ggPedigree()` into fully interactive `Plotly` widgets. This allows users to explore pedigree data in a more dynamic way, with features such as hover text, zooming, and panning.
This vignette walks through:
- Basic usage of `ggPedigreeInteractive()`
- Customizing the interactive plot
- Adding tooltips for additional information


```{r load-packages}
# Load required packages
library(BGmisc) # ships the sample 'potter' pedigree
library(ggplot2) # used internally by ggPedigree*
library(viridis) # viridis for color palettes
library(plotly) # conversion layer for interactivity
library(ggpedigree) # the package itself
```


# Example data

The package includes a small toy pedigree for the Harry Potter universe:

```{r load-data}
# Load the example data
data("potter")
# Display the first few rows of the dataset
head(potter)
```


# Basic Usage

A minimal call is just:

```r
ggPedigreeInteractive(potter)
```

...but you will usually want to identify the core primary‑key columns in advance:

```{r basic-usage-2}
plt <- ggPedigreeInteractive(
  potter,
  famID    = "famID",
  personID = "personID",
  momID    = "momID",
  dadID    = "dadID"
) |> plotly::hide_legend()
```

```{r eval=FALSE, include=TRUE}
plt
```

```{r echo=FALSE}
# reduce file size for CRAN
if (interactive()) {
  # If running interactively, use plotly::partial_bundle
  # to reduce file size for CRAN
  plotly::partial_bundle(plt)
} else {
  plotly::partial_bundle(plt, local = TRUE)
}
```

The above code generates an interactive pedigree plot of the Potter family tree. You can zoom in, pan around, and hover over nodes to see more information. You can do much more with the `ggPedigreeInteractive()` function, including customizing labels, colors, and tooltips. To experience the full list of options, refer to the online article.

