Closed JaniceShu closed 4 years ago
This will fail, from tests/testthat/test_module_tabs.R
:
histogram <- output$plot_histogram
# Check y values (name of health trusts)
expect_equal_to_reference(histogram[["coordmap"]][["panels"]][[1]][["domain"]][["discrete_limits"]][["y"]],
"data/plot_histogram_y.rds")
expect_equal(histogram[["coordmap"]][["panels"]][[1]][["mapping"]][["x"]], "get(\"value\")")
expect_equal(histogram[["coordmap"]][["panels"]][[1]][["mapping"]][["y"]], "get(\"area_name\")")
expect_equal(histogram[["coordmap"]][["panels"]][[1]][["mapping"]][["fill"]], "get(\"brks\")")
It seems like output$plot_histogram
is now a json-object. Maybe test it with something like this (as been done for output$plot_map
and output$make_table
)?
histogram <- as.character(output$plot_histogram)
expect_true(grepl("<SOME STRING>", histogram))
tests/testthat/test_plot_variation.R
is of course also failing. Seems like the data in data <- readRDS("data/start_plot.rds")
is not good enough for the new histogram code. Maybe use something like this instead?
data <- testdata %>%
dplyr::filter(level1 == 1) %>%
dplyr::filter(level2 == 1) %>%
dplyr::filter(level3 == 1)
I am considering deactivating these tests... It will just make our life harder with all these tests during development. The plots will change a lot...
I forgot about your config
question...
Not sure what you have tried. You can send the config
directly in your function by adding config = config
# BARCHART
output$plot_histogram <- plotly::renderPlotly({
plot <- helseatlas::plot_variation(
input_data = data(),
xlab = config$plot$xlab[[language()]],
ylab = as.character(data()$type),
config = config # New line
)
and add it to the plot_variation
plot_variation <- function(input_data = NULL, xlab = "Area", ylab = "Rate", type = "histogram", num_groups = 5, config = NULL) {
Or maybe better: only send in what is needed. Thus, something like this:
# BARCHART
output$plot_histogram <- plotly::renderPlotly({
plot <- helseatlas::plot_variation(
input_data = data(),
xlab = config$plot$xlab[[language()]],
ylab = as.character(data()$type),
big_mark = config$num$big[[language()]],
decimal_mark = config$num$decimal[[language()]]
)
We can do it in another PR:)
Use plotly to display hover info.
Remove legend and caption (related issue #150).
Add x-axis label.
Hover info the numbers are not formatted correctly. I tried to format it, but couldn't get config to pass into the code properly. @arnfinn, if there is an easy way, please enlighten me!
I have taken the legend away completely. I don't think it is necessary as the range of the bins are easily obtained from the plot.