Pierre
Pierre

Reputation: 741

R - Markdown - Highcharter - Reduce size of plot in table

Im trying to include a highcharter plot in a table in markdown. What I would like to achieve is somethink like https://www.highcharts.com/demo/sparkline (I have tried to use knitr::kable and DT:datatable instead without success)

Is it possible to change the height of the plots? None of hc_size() / highcharter() works.

---
title: "Title"
author: "Author"
date: "Date"
output: 
  flexdashboard::flex_dashboard:
    self_contained: no
    orientation: row
    vertical_layout: scroll
---

```{r, message=F, warning=F, echo=F}
library(flexdashboard)
library(highcharter)
library(tidyverse)
```

DB {data-orientation=rows}
=======================================================================

```{r}
h1 <- hc_size(hchart(data.frame(x = 1:10, y = rnorm(10)), type = "line", mapping = hcaes(x = x, y = y)), 1,1)
h2 <- hchart(data.frame(x = 1:10, y = rnorm(10)), type = "line", mapping = hcaes(x = x, y = y))
```

Row {data-width=600 data-height=1500}
-----------------------------------------------------------------------

### {data-height=1000 data-width=400}

|<font size="4">**A**</font> |<font size="4">B</font> | <font size="4">C</font> | <font size="4">D</font>  | <font size="4">E</font>  | <font size="4">F</font> | <font size="4">G</font> | 
|:-------------------|:----:|:-----------: |:----: |:----:|:-------------------- |:----:
| | | <br> <font size="3">**AA**</font> | | | 
|A | B | C | D | E | F | `r h1 %>% hc_add_theme(hc_theme_sparkline())` |
|A | B | C | D | E | F | `r hc_size(h2 %>% hc_add_theme(hc_theme_sparkline()), 1, 1)` |
|A | B | C | D | E | F | `r highchart(width = 1, height = 1) %>% hc_add_series(data.frame(x = 1:10, y = rnorm(10)), type = "line", mapping = hcaes(x = x, y = y)) %>% hc_add_theme(hc_theme_sparkline())` |

enter image description here

Upvotes: 0

Views: 423

Answers (1)

mnist
mnist

Reputation: 6956

Have a look at https://github.com/nuno-agostinho/Highcharter-in-DataTables Their code worked pretty good for me.

Upvotes: 1

Related Questions