Skip to content

Commit

Permalink
Get the function working outside of reportinggrofwild & INBOtheme
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderDevisscher committed Jul 7, 2020
1 parent d7373b9 commit c2ed621
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions R/indicator_native_range_year.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
countYearNativerange <- function(data, jaartallen = NULL,
type = c("native_continent", "native_range"),
width = NULL, height = NULL) {
require(plotly)
require(data.table)

type <- match.arg(type)

Expand Down Expand Up @@ -58,15 +60,12 @@ countYearNativerange <- function(data, jaartallen = NULL,
summaryData$locatie <- factor(summaryData$locatie, levels = rev(levels(summaryData$locatie)))
summaryData$first_observed <- as.factor(summaryData$first_observed)

colors <- rev(inbo.2015.colours(n = nlevels(summaryData$locatie)))
title <- yearToTitleString(year = c(jaartallen[1], tail(jaartallen, 1)), brackets = FALSE)


# Create plot
pl <- plot_ly(data = summaryData, x = ~first_observed, y = ~value, color = ~locatie,
colors = colors, type = "bar", width = width, height = height) %>%
layout(title = title,
xaxis = list(title = "Jaar"),
yaxis = list(title = "Aantal", tickformat = ",d"),
pl <- plot_ly(data = summaryData, x = ~first_observed, y = ~value, color = ~locatie, type = "bar", width = width, height = height) %>%
margin = list(b = 80, t = 100),
barmode = ifelse(nlevels(summaryData$first_observed) == 1, "group", "stack"),
annotations = list(x = levels(summaryData$first_observed),
Expand Down

0 comments on commit c2ed621

Please sign in to comment.