Open brp221 opened 1 year ago
IMHO this is a bug. But as long as you want to remove the lines for all series you can achieve that by setting the style of the linchart to "marker"
using chart_settings()
.
Using a minimized reprex based on mtcars
:
library(officer)
library(mschart)
diamondLineWrapper <- function(data, x, y, group) {
chart <- ms_linechart(data = data, x = x, y = y, group = group)
chart_settings(chart, style = "marker")
}
diamond_chart <- mtcars |>
transform(cyl = factor(cyl)) |>
diamondLineWrapper(x = "hp", y = "mpg", group = "cyl")
doc <- read_pptx()
doc <- add_slide(doc, layout = "Title and Content", master = "Office Theme")
doc <- ph_with(doc, value = diamond_chart, location = ph_location_fullsize())
print(doc, target = "example.pptx")
Hi mschart community,
I am trying to create a line chart over a bar chart without displaying an actual line like in the image below. However despite specifying chart_data_line_style('none') in the code, the line still shows up. Here is the code with the reproducible R example with sample iris data and the way I am currently implementing ms_linchart(). :
library(officer) library(mschart) library(reshape) library(dplyr)
diamondLineWrapper <- function(data, x, y, group){ print("diamondLineWrapper")
data_text_style <- fp_text(font.size = 12, bold = F, color = "#5a5a5a" )
g <- ms_linechart(data = data, x = x, y = y, group = group) %>% chart_settings( grouping = "standard") %>% chart_data_fill( "#002c77") %>% chart_ax_x(display=1,cross_between = "midCat",major_tick_mark = "none",minor_tick_mark = "none", rotation = -30) %>% chart_ax_y(display=1, major_tick_mark = "none", minor_tick_mark = "none", rotation = 0) %>% chart_data_labels(show_val = F) %>% chart_labels(title = NULL, xlab = "", ylab = "") %>%
chart_data_line_width(values = c( "Peer Group" = 0) ) %>%
}
iris <- select(iris, c("Species", "Sepal.Length", "Sepal.Width")) iris_melted <- melt(iris, id.vars = c("Species"))
diamond_chart<- diamondLineWrapper(iris_melted, x = "variable", y = "value", group = "Species")
doc <- read_pptx() doc <- add_slide(doc, layout = "Title and Content", master = "Office Theme") doc <- ph_with(doc, value = diamond_chart, location = ph_location_fullsize()) print(doc, target = "example.pptx")
The view I want :
The view I currently get :
Please let me know if there is something that Im doing wrong or am missing. Or if you think there is a better way to create the view as in the image
Thank You !