---
title: "ggiraph in dashboard"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)

```

Column {data-width=650}
-----------------------------------------------------------------------

### Chart A

```{r}
library(ggiraph)
library(ggplot2)
library(magrittr)

dataset = iris
dataset$tooltip = dataset$Species
dataset$clickjs = paste0("alert(\"",dataset$Species, "\")" )

# plots
gg_point = ggplot(dataset, aes(x = Sepal.Length, y = Petal.Width,
                               color = Species, data_id = Species, 
                               tooltip = tooltip, onclick = clickjs) ) +
  geom_point_interactive() + theme_light()

x <- girafe(code = {print(gg_point)}, width_svg = 8, height_svg = 5)
x
```

Column {data-width=350}
-----------------------------------------------------------------------

### Table

```{r}
DT::datatable(dataset)
```

